|
Thank you very much Galatei
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
How about ALWAYS trying to create, instead of open and THEN create.
You leave a small window of opportunity for your thread to be switched out, and then you try the create, and it can fail, and you are not chekcing for that failure (error already exists...).
If you always try create in the first place, you can get back 'error alrady exists', and you know that you are already there, or else you ae the first one.
Your exmaple is generally acceptable, but not technically correct.
|
|
|
|
|
In my example, you can use Opened semaphore for IPC.
Generally, creating to fail and then checking is not correct, it may be cause of serious problems.
If you try to create file which should be reported as existing, but it wasn't reported because of some disk I/O failure, you may end up scratching your desk with your teeths.
It's like this
"go shopping, get new MP3 player, go to the cash-desk, and finally find out that you don't have enough money." <- How about checking your wallet before you even leave your home?
Regards
|
|
|
|
|
Correct, in all accounts, except we were not talking about creating a file, we were creating a sempahore WHICH you were going to create anwyays.
On a fairly loaded terminal services server, I have ALREADy seen code like yours fail. For exactly the reasons I mentioned.
|
|
|
|
|
You mean BADLY implemented apps, sure.
My implementation wouldn't fail, because of error checking on every important step!
So, if OpenSemaphore is NOT_EXISTS, and CreateSemaphore return EXISTS, I still have correct information.
Implementation like yours is like M$ way of security. Always trying to harm first, hoping that its security system will prevent from that.
You should learn from linux implementation (check first, and act if it is possible).
Regards
|
|
|
|
|
i have dll file and header for dll but i ont hev .lib file for that how to get that .can anybody help me out
|
|
|
|
|
abrakadbra wrote: i have dll file and header for dll but i ont hev .lib file for that how to get that .can anybody help me out
then you have to dynamically load function or take long route.. i never tried, but have a try make a new dll based project with same dll name .. this will generate you new lib file.. which i believe can be used with existing dll... my assumption is that dll lib file contain runtime declaration of function signature
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
You need to have some exported symbol/function to generate .lib .
|
|
|
|
|
can you pls tell me in more detail how to do this
|
|
|
|
|
A Quick search on CP gives me list of articles.
Here one of them[^].
|
|
|
|
|
|
I can use FindWindow("#32770", "MFCProgramName") to find a MFC program's dialog, and then I can PostMessage() to the dialog.
How can I send message to a Win32 Console Application?
Thanks!
|
|
|
|
|
In general a console application has no message pump and so can't process messages. If you're coding a console application there's nothing stopping you from adding a message pump however.
Steve
|
|
|
|
|
Hi
You can try creating a CFrameWnd derived class . Overwrite OnCreate of this windows make it hidden . And you can use the message map for framewnd easily to receive messages into the app
redindian
|
|
|
|
|
MFC: CPropertySheet -- how do you get rid of default APPLY + HELP button
Thanks!
Norman Fung
|
|
|
|
|
What I do is disable them and move them to a position that is off the property sheet.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
No you don't actually put in the buttons yourself... It's created for you by default (not by dialog designer) - I was expecting you'd need to specify you don't want APPLY/HELP button from dwStyle or dwExStyle:
virtual BOOL Create(CWnd* pParentWnd = NULL, DWORD dwStyle = WS_POPUP | WS_CAPTION | DS_MODALFRAME | WS_VISIBLE, DWORD dwExStyle = WS_EX_DLGMODALFRAME);
Any idea? Thanks.
Norman Fung
|
|
|
|
|
norm wrote: No you don't actually put in the buttons yourself... It's created for you by default
Yeah, that is correct. So what you do, in your sheet's OnInitDialog function is:
CWnd *pWnd = GetDlgItem(ID_HELP);
pWnd->EnableWindow(FALSE);
pWnd->MoveWindow(-100, -100, 0, 0, FALSE);
pWnd->ModifyStyle(WS_TABSTOP, 0); And do the same for the Apply button.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Thanks but:
<br />
BOOL ClsXXXSettingsSheet::OnInitDialog() <br />
{<br />
BOOL rc = CPropertySheet::OnInitDialog();<br />
<br />
...<br />
<br />
CWnd * pbtnHelp = GetDlgItem(ID_HELP);<br />
<br />
pbtnHelp->ShowWindow(FALSE); <-- Crashed here<br />
<br />
...<br />
<br />
return rc;<br />
}<br />
<br />
<br />
<br />
BOOL CWnd::ShowWindow(int nCmdShow)<br />
{<br />
ASSERT(::IsWindow(m_hWnd)); <-- Crashed here<br />
<br />
if (m_pCtrlSite == NULL)<br />
return ::ShowWindow(m_hWnd, nCmdShow);<br />
else<br />
return m_pCtrlSite->ShowWindow(nCmdShow);<br />
}
Norman Fung
|
|
|
|
|
Sorry, that's what I get for doing it off the top of my head. The ID of the help button is IDHELP , not ID_HELP . The ID of the Apply button is ID_APPLY_NOW .
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Thanks, it works. How do you set alignment to bottom right of dialog/property sheet though?
I found CBRS_ALIGN_BOTTOM and other stuff from AFXRES.h but not sure which API to call. Thanks a bunch.
Norman Fung
|
|
|
|
|
In the propertysheet constructor you put the following
m_psh.dwFlags |= PSH_NOAPPLYNOW;
m_psh.dwFlags &= ~(PSH_HASHELP);
and in each of the propertypage constructors put
m_psp.dwFlags &= ~PSP_HASHELP;
Then the help and apply buttons will be removed.
|
|
|
|
|
i was wondering, in a combo box, in order to add item we can just go to properties and add them one by one n separate them by pressing ctrl+Enter. But, do I still need to declare those items in the codes(eg. using AddString)? I'm using VC6 and using a dialog based application.
Thanks in advance.
|
|
|
|
|
Did you try it? What happened?
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
cyn8 wrote: But, do I still need to declare those items in the codes(eg. using AddString)? I'm using VC6 and using a dialog based application.
no, you already added them to control!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|