Click here to Skip to main content
15,914,071 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: migrate a program to other OS Pin
includeh104-Feb-03 4:02
includeh104-Feb-03 4:02 
GeneralRe: migrate a program to other OS Pin
Abbas_Riazi4-Feb-03 6:18
professionalAbbas_Riazi4-Feb-03 6:18 
QuestionDo "Print Screen" images have a file name? Pin
WREY4-Feb-03 3:02
WREY4-Feb-03 3:02 
AnswerRe: Do "Print Screen" images have a file name? Pin
Nitron4-Feb-03 3:33
Nitron4-Feb-03 3:33 
GeneralRe: Do "Print Screen" images have a file name? Pin
Abbas_Riazi4-Feb-03 3:39
professionalAbbas_Riazi4-Feb-03 3:39 
GeneralRe: Do "Print Screen" images have a file name? Pin
Rickard Andersson204-Feb-03 4:47
Rickard Andersson204-Feb-03 4:47 
AnswerRe: Do "Print Screen" images have a file name? Pin
cramezul4-Feb-03 3:53
cramezul4-Feb-03 3:53 
GeneralSending customized messages to parent window Pin
Abin4-Feb-03 3:04
Abin4-Feb-03 3:04 
I have a class derived from CListCtrl, and I want it send a customized message to its parent window(which is derived from CDialog) when in need. So I defined a message ID, say, "#define WM_SOMETHING WM_APP + 100" in my project and handle this message by the following way:

////////////////////////////////////////////////////
// in implementation of CMyListCtrl
////////////////////////////////////////////////////
  
void CMyListCtrl::OnSomething
{
    CWnd* pParent = GetParent();
    if (pParent != NULL)
        pParent->PostMessage(WM_SOMETHING, 0, 0);
}
  
  
////////////////////////////////////////////////////
// in header of CMyDlg
////////////////////////////////////////////////////
  
// ...
afx_msg void OnSomethingHappened();
// ...
  
  
////////////////////////////////////////////////////
// in implementation of CMyDlg
////////////////////////////////////////////////////
  
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
    // ...
    ON_MESSAGE(WM_SOMETHING, OnSomethingHappened)
END_MESSAGE_MAP()
  
  
void CMyDlg::OnSomethingHappened()
{
    // do something
}


Now, in debug mode it works great, but in release mode it crashes. If I remove the "PostMessage..." code from implementation of CMyListCtrl, it will not crash so the problem must be there... What am I doing wrong? Thank you.
GeneralRe: Sending customized messages to parent window Pin
HENDRIK R4-Feb-03 3:14
HENDRIK R4-Feb-03 3:14 
GeneralYes, YES Pin
Abin4-Feb-03 3:34
Abin4-Feb-03 3:34 
GeneralRe: Yes, YES Pin
Roger Allen4-Feb-03 4:01
Roger Allen4-Feb-03 4:01 
GeneralRe: Yes, YES Pin
HENDRIK R4-Feb-03 4:19
HENDRIK R4-Feb-03 4:19 
GeneralRe: Sending customized messages to parent window Pin
Abbas_Riazi4-Feb-03 3:48
professionalAbbas_Riazi4-Feb-03 3:48 
GeneralGet Text from List box Pin
Larsson4-Feb-03 3:01
Larsson4-Feb-03 3:01 
GeneralRe: Get Text from List box Pin
HENDRIK R4-Feb-03 3:10
HENDRIK R4-Feb-03 3:10 
GeneralRe: Get Text from List box Pin
Larsson4-Feb-03 3:26
Larsson4-Feb-03 3:26 
GeneralRe: Get Text from List box Pin
HENDRIK R4-Feb-03 3:35
HENDRIK R4-Feb-03 3:35 
GeneralRe: Get Text from List box Pin
Larsson4-Feb-03 3:48
Larsson4-Feb-03 3:48 
Generalimplementing new Pin
Patje4-Feb-03 2:15
Patje4-Feb-03 2:15 
GeneralRe: implementing new Pin
Joaquín M López Muñoz4-Feb-03 2:23
Joaquín M López Muñoz4-Feb-03 2:23 
GeneralRe: implementing new Pin
Patje4-Feb-03 2:56
Patje4-Feb-03 2:56 
GeneralRe: implementing new Pin
Joaquín M López Muñoz4-Feb-03 4:33
Joaquín M López Muñoz4-Feb-03 4:33 
GeneralRe: implementing new Pin
Alvaro Mendez4-Feb-03 6:04
Alvaro Mendez4-Feb-03 6:04 
GeneralRe: implementing new Pin
Joaquín M López Muñoz4-Feb-03 6:25
Joaquín M López Muñoz4-Feb-03 6:25 
GeneralRe: implementing new Pin
Alvaro Mendez4-Feb-03 6:54
Alvaro Mendez4-Feb-03 6:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.