|
Hmm, have forgotten how to do they escape key bit, there's a function in one of the MFC classes your Dialog is deriving from that turns Esc into a WM_CLOSE, you need to override that or prevent it being called, a PreTranslateMessage override might be able to do it.
When it comes to closing the Dialog your best bet is probably to use a timer, MFCs timers are fine and when it goes off use PostMessage to have the dialog send itself a WM_CLOSE. Don't use SendMessage or things may go horribly wrong when you return to run code in a deleted dialog.
If the dialog closing is conditional then set your timer to a short period, like a 10/th of a second and check the condition. If it's not met just set the timer again.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
tom groezer wrote: When my MFC application is run, it invokes a dialog. Though I have removed the OK and the cancel button from the dialog my dialog can be dismissed by pressing the esc key
Override PreTranslateMessage , for instance
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
if ( pMsg->message == WM_KEYDOWN )
{
if (pMsg->wParam == VK_ESCAPE)
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
BTW probably you'll have also to handle RETURN key.
tom groezer wrote: Also i like to dismiss the dialog by posting a message after some time. how to I post a destroy message to the dialog.
What about a TIMER ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
In this context how do I destroy the window.
|
|
|
|
|
nothing forbids you to overload the WM_CLOSE event or to create your own button which will call EndDialog(IDC_CANCEL) for instance...
|
|
|
|
|
Is there any way to find current MMC's version on a system, Does there any "registry key" or win32 API exists to find that?
Thanks,
Mushq
|
|
|
|
|
|
Why cant we have a Virtual Constructor ?
Anandi VC
|
|
|
|
|
Think what you can/are going to do with that.
|
|
|
|
|
Well ... What do you think you can do with a virtual constructor?
|
|
|
|
|
this question has been asked tons of times.
look in the FAQ please !
|
|
|
|
|
Anandi.VC wrote: Why cant we have a Virtual Constructor ?
What would you expect this constructor to do?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hi,
I have created a com dll for context menu and want to add icon. So could you please tell me how "DefaultIcon" can help me?
I have used SetMenuItemBitmap(), but could not succeed.
|
|
|
|
|
I deveplop an application under Windows XP pro editon,
It can't run under Window XP home edition, I copied the dependency dlls with the exe.
why?
|
|
|
|
|
Is this Win XP problem or the vcredist need to be installed in the WinXP HE.
I personally don't prefer the messy way of copying dependency dlls. Try install the appropriate VC redistribute package of your development VS Version.
|
|
|
|
|
|
In which version of VC you developed?
web search: Vc redistribute <your vc version>
|
|
|
|
|
|
followait wrote: Any doc?
Thanks.
Hope this helps: Download VCRedist[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
followait wrote: It can't run under Window XP home edition
do you have any error message my any chance ?
|
|
|
|
|
Hello friend,
I am using VC6.0 IDE.
I have created MyDll.dll and write one exported function as below.
#ifdef TNS_EXPORTS
#define MyDll_API __declspec(dllexport)
#else
#define MyDll_API __declspec(dllimport)
#endif
...DllMain()....
extern "C" MyDll_API int CALLBACK DLLPRoc(char *pMsg,int nVal)
{
MessageBox(NULL,"DLLPRoc","MyDll_API",MB_OK);
return 1;
}
Inside Main.cpp
typedef int (CALLBACK *MYPROC)(char *pMsg,int nVal);
int Proc(char *pMsg,int nVal)
{
ret
}
int main(int argc, char* argv[])
{
HINSTANCE hIns=LoadLibrary("..MyDll\\Release\\MyDll.dll");
if(hIns==NULL)
return 0;
MYPROC pProc=(MYPROC)GetProcAddress(hIns,"DLLPRoc");
pProc=&Proc;
}
My problem is Proc doesn't receive acknowlegement.
I want the Proc will continuosly run as a callback procedure and receive the messages inside DLLProc in MyDLL.
Please give me suggestion and if po
ssible give some sample application
abhi
|
|
|
|
|
Please format your code properly so that it is a bit easier to read.
AbhijitAkude wrote: My problem is Proc doesn't receive acknowlegement.
What do you mean by "receive acknowlegement" ?
AbhijitAkude wrote: int Proc(char *pMsg,int nVal)
{
ret
}
What's that and what is that doing in main.cpp ?
So please explain what you are trying to achieve and what the exact problem is.
|
|
|
|
|
AbhijitAkude wrote: MYPROC pProc=(MYPROC)GetProcAddress(hIns,"DLLPRoc");
BTW, you just want to call the function
MyDll_API int CALLBACK DLLPRoc(char *pMsg,int nVal)
as it is.
int main(int argc, char* argv[])
{
char msg = 10;
DLLPRoc (&msg, 10);
}
provided the declaration is visible to the exe as __declspec(dllimport) for MyDll_API
modified on Saturday, May 10, 2008 4:06 AM
|
|
|
|
|
Hi,
What is mean by the following statement
<br />
MYPROC pProc=(MYPROC)GetProcAddress(hIns,"DLLPRoc");<br />
pProc=&Proc;<br />
u got the address of DLLProc in pProc then you are replacing it with address of local function
<br />
int Proc(char *pMsg,int nVal)<br />
{<br />
ret<br />
}<br />
<br />
thanks
Nitheesh
|
|
|
|
|
Its defensive approach, if he didn't get DLLPRoc (it's sure), use the local function.
|
|
|
|