|
If your child dialog is modal dialog, then the message processing of parent wil be blocked. Better passing parent window pointer to child dialog and call the desired function.
Check this to know how to create user defined messages[^]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Thank you Sarath,
I have createed my child dialog as model dialog. And child dialog able to send message to parent dialog in debug mode but it is not working with Release EXE... Why it is so?
|
|
|
|
|
zakkas2483 wrote: but it is not working with Release EXE... Why it is so?
Because you are not handling the WPARAM and LPARAM.
Even if you do not wish to use them you have to handle them.
Modify
DoSoemthing()
to
DoSomething(WPARAM wParam, LPARAM lParam)
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
Yes, It's working...
After modify the defination of DoSomething( ) to DoSomething(WPARAM wParam, LPARAM lParam)
It's working find.
Thanks a lot for your kind support.
But i am not getting this think why it is working in debug mode and not with release mode. anyways thank a lot budy.. i am thankful to you.
|
|
|
|
|
Can u post code snippet for the same?
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
two File ..
one
//PostDialog.cpp
#define WM_UPDATE_SERVER_LIST WM_USER + 1
BEGIN_MESSAGE_MAP(CPortsDialog, CDialog)
//{{AFX_MSG_MAP(CPortsDialog)
ON_MESSAGE( WM_UPDATE_SERVER_LIST, UpdateServerList )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CPortsDialog::UpdateServerList( )
{
//do some work
}
/// function to create new dialog...
void CPortsDialog::OnButtonAdd()
{
CAddSMTPServer SMTPServer;
SMTPServer.ptrPortDialog = this;
SMTPServer.DoModal();
}
///AddSMTPServer.cpp
void CAddSMTPServer::OnOK()
{
if( ptrPortDialog ) // where ptrPortDialog is pointer to parent dialog
::SendMessage( ptrPortDialog->m_hWnd,WM_UPDATE_SERVER_LIST, 0,0);
//alternative
// ptrPortDialog->UpdateServerList( )
}
|
|
|
|
|
After modify the UpdateServerList( ) function to UpdateServerList(WPARAM, LPARAM ) it's working fine.
But i am not getting why the previouse funcation defination work in debug mode and not work for release mode.. any idea. Anyway thank you very much for nice support.
|
|
|
|
|
The message handlers should have to format afx_msg LRESULT (CWnd::*)(WPARAM, LPARAM).
which means the void CPortsDialog::UpdateServerList( )
should be changed to LRESULT CPortsDialog::UpdateServerList(WPARAM, LPARAM)
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
You already have the solution to your problem - add in the WPARAM & LPARAM parameters.
But you want to know why it worked in debug, and not in release mode?
Do a search in the MFC code directorys for ON_MESSAGE, and you can see the definition of the macro. You can see that MFC is calling casting your function to a format that includes the two parameters.
In release mode, calling a function with parameters will put those parameters on the stack. Your function does not use them, so it does not pull them off the stack. I got "stack corruption" errors when I had this same fault (a long time ago now!)
In debug mode, my theory there is plenty of padded memory about, or the calling conventions do not use the stack. Either way - when it worked in debug mode, you were just lucky.
(Or unlucky - I'd prefer to fix the problem as soon as possible!)
My experience was with VC++ 6 - I think later versions of MFC do things a little differently, without casts in the ON_xxxxx message maps, so it's harder to have this fault.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Thank Iain,
Now i have my answer.
Thank you for sharing your nice exp. with us.
|
|
|
|
|
How to make two check boxes mutually exclusive?
Thanks in advance,
Anandi VC
|
|
|
|
|
You will have to handle it in code.
In the check box click handler, check or uncheck the other.
Or you should consider using radio buttons.
«_Superman_»
|
|
|
|
|
Thank you.I am handling it in code.
Anandi VC
|
|
|
|
|
Unless you have a REEEEEEEEEEEALLY good reason to make these checkboxes, your customers will thank you for making them radio buttons. The standard window controls look different for a reason - to give the user different expectations about how they work.
And if your work is not about keeping users of the software happy [and therefore giving you money to buy food], why are you doing this?
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Anandi.VC wrote: How to make two check boxes mutually exclusive?
Is that why Radio buttons where invented for??
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Tell them they are radio buttons.
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
[My articles]
|
|
|
|
|
Radio buttons can handle "one and only one" functionality.
But mutually exclusive check boxes can handle "zero or one" functionality which is not possible with radio buttons. Microsoft also uses mutually exclusive check boxes in their products.
«_Superman_»
|
|
|
|
|
«_Superman_» wrote: But mutually exclusive check boxes can handle "zero or one" functionality which is not possible with radio buttons.
Uh, yeah, it is. You add another radio button, label it "none of the above", and give it the same meaning in your program that the somewhat-less-than-obvious fewer than the maximum number of checkable checkboxes are checked state would have had, should you have been mad enough to actually implement such an atrocity.
Now you have a finite number of states, all of which are explicitly named, and all of which can be selected with a single click. Radio buttons - learn to love 'em.
|
|
|
|
|
Okay.
In VC++ 6.0, take a look at the properties dialog of a button.
You will see 2 check boxes for Icon and Bitmap .
So if this is an atrocity, how better would it be to do it in that space with radio buttons?
«_Superman_»
|
|
|
|
|
Space constraints? Combo box!
|
|
|
|
|
Hi All,
I have created ATL DLL with function Add(int var1, ibt var2), also registered dll using regsrv32 command, and I created another MFC project so plz tell me how to use this function of DLL in MFc project.? which files to include in new project?
|
|
|
|
|
#import the dll and then follow the steps underneatch
CoInitialize(NULL);
HRESULT hr = S_OK;
IITestObj* pTest = NULL;
hr = CoCreateInstance(__uuidof(ITestObj),NULL,CLSCTX_ALL,__uuidof(IITestObj),(void**)&pTest);
if(SUCCEEDED(hr))
{
pTest ->Add(5,10);
}
else
{
MessageBox("Failed to get the component",NULL,MB_OK);
CoUninitialize();
}
CoUninitialize ();
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
What is IITestObj* pTest = NULL; in your case?
In mine case , IITestobj is class, but compiler is giving error undeclared identifier,
I have imported DLL at start.
|
|
|
|
|
it is an interface pointer. ITestObj is the Atl Simple Object that I added using the class wizard.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi below code may help you,
#import "../MathOperations.dll" named_guids
using namespace MathOperationsLib;
Create instance for dll
HRESULT hresult;
CoInitialize(NULL);
IOperationsPtr ptr;
hresult=CoCreateInstance(MathOperationsLib::CLSID_Operations,NULL,CLSCTX_INPROC_SERVER,MathOperationsLib::IID_IOperations,(LPVOID *) &ptr);
if(FAILED(hresult))
{
MessageBox(L"Creation Failed",0,0);
return;
}
LONG Z;
ptr->AddNumbers(4,6,&Z);
CoUninitialize();
|
|
|
|