|
Thanks for the reply can i set the color of text ?..
|
|
|
|
|
Hello every one,
I have child - parent dialog in my application. I wants to call parent class function from child class. using WM_USER. please provide me the example code. i have already code this but having problem in realse exe.
Thank you.
|
|
|
|
|
zakkas2483 wrote: . i have already code this but having problem in realse exe.
What problem? How do you implement it.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
I have Two Dialog box. Abc and Def ok. From Add button of Abc i have created Def Dialog box. I need to do some work in Abc on OK of Def.
CODE:
// Abc.cpp
#define USER_MSG WM_USER + 100
BEGIN_MESSAGE_MAP(Abc, CDialog)
//{{AFX_MSG_MAP(Abc)
ON_MESSAGE( USER_MSG, DoSomeWork )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void Abc::OnAdd()
{
Def d;
d.ptrParent = this;
d.DoModel();
}
void Abc::DoSomeWork()
{
}
/// From def.cpp
void def::OnOK()
{
if( ptrParent )
::sendMessage( ptrParent->m_hWnd, WM_USER + 100,0,0);
// i can do like ptrParent->DoSomeWork() but i wants to user USER MSG.
}
Thank you for your interest.
|
|
|
|
|
Why you need messages for this purpose??
You can simply do something like this..
void Abc::OnAdd()
{
Def d;
d.ptrParent = this;
if(d.DoModel()==IDOK)
{
...
}
else
{
...
}
}
I hope it helps..
BTW: Plese use code block button below posting area for posting code snippets.
Regards,
Sandip.
|
|
|
|
|
HI Sandip,
U r very right.
i wants learn metod of sending USER message.
Also i don't have member veriables for Def Dialog box. I am using GetDlgItem()
Thanks.
|
|
|
|
|
|
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.
|
|
|
|