Click here to Skip to main content
15,915,160 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTest a DIB for percentage of black pixels Pin
davidhart15-Feb-06 3:48
davidhart15-Feb-06 3:48 
AnswerRe: Test a DIB for percentage of black pixels Pin
basementman15-Feb-06 4:29
basementman15-Feb-06 4:29 
GeneralRe: Test a DIB for percentage of black pixels Pin
normanS15-Feb-06 18:39
normanS15-Feb-06 18:39 
QuestionChange Application Icon Pin
sunit515-Feb-06 3:30
sunit515-Feb-06 3:30 
AnswerRe: Change Application Icon Pin
toxcct15-Feb-06 3:32
toxcct15-Feb-06 3:32 
GeneralRe: Change Application Icon Pin
sunit515-Feb-06 3:39
sunit515-Feb-06 3:39 
AnswerRe: Change Application Icon Pin
Wim Engberts15-Feb-06 4:12
Wim Engberts15-Feb-06 4:12 
GeneralRe: Change Application Icon Pin
ThatsAlok16-Feb-06 2:44
ThatsAlok16-Feb-06 2:44 
GeneralRe: Change Application Icon Pin
Wim Engberts16-Feb-06 5:21
Wim Engberts16-Feb-06 5:21 
GeneralRe: Change Application Icon Pin
ThatsAlok16-Feb-06 17:18
ThatsAlok16-Feb-06 17:18 
QuestionSir,I want 2 know that weather we can call SAME function in Multiple Threads? Pin
CodeVarma15-Feb-06 3:18
CodeVarma15-Feb-06 3:18 
AnswerRe: Sir,I want 2 know that weather we can call SAME function in Multiple Threads? Pin
Tim Smith15-Feb-06 3:35
Tim Smith15-Feb-06 3:35 
GeneralRe: Sir,I want 2 know that weather we can call SAME function in Multiple Threads? Pin
ThatsAlok16-Feb-06 2:43
ThatsAlok16-Feb-06 2:43 
GeneralRe: Sir,I want 2 know that weather we can call SAME function in Multiple Threads? Pin
Tim Smith16-Feb-06 3:40
Tim Smith16-Feb-06 3:40 
GeneralRe: Sir,I want 2 know that weather we can call SAME function in Multiple Threads? Pin
ThatsAlok16-Feb-06 17:24
ThatsAlok16-Feb-06 17:24 
AnswerRe: Sir,I want 2 know that weather we can call SAME function in Multiple Threads? Pin
BadKarma15-Feb-06 3:54
BadKarma15-Feb-06 3:54 
AnswerRe: Sir,I want 2 know that weather we can call SAME function in Multiple Threads? Pin
Stephen Hewitt15-Feb-06 16:59
Stephen Hewitt15-Feb-06 16:59 
AnswerRe: Sir,I want 2 know that weather we can call SAME function in Multiple Threads? Pin
ThatsAlok16-Feb-06 2:41
ThatsAlok16-Feb-06 2:41 
Questionmodeless dialog WM_CLOSE - opinion Pin
23_44415-Feb-06 3:14
23_44415-Feb-06 3:14 
Need your thoughts and/or opinion. Question at the bottom.

When user closes the modeless dialog box you can trap the WM_CLOSE message to insure proper cleanup.

According to Help
CWnd::OnClose
The framework calls this member function as a signal that the CWnd or an application is to terminate. The default implementation calls DestroyWindow.

I found two ways to approach the user who closes the modeless dialog box by clicking the x on the upper right hand corner of the window

Looking at the first example below.
I found out that if you don't call DestroyWindow() from your OnClose() and you don't want multiple instances of your modeless opened you will need to set the pointer to NULL here (otherwise your pointer value can't be used as a flag to prohibit other instances of your modeless dialog from being opened). PostNcDestroy apparently isn't run until the parent is destroyed. Once the parent/owner is closed then a PostNcDestroy is run for each modeless that opened - one right after another.

void CDialogDerived::OnClose()
{
CDialog::OnClose();
m_pParent->m_pModelessDialog = NULL;
}

void CDialogDerived::PostNcDestroy()
{
CDialog::PostNcDestroy();
m_pParent->m_pModelessDialog = NULL; //in case destroy window is called from your code and OnClose is never run
delete this;
}


Example 2. This seems like a cleaner approach as the Dialog is destroyed immediately and thus your pointer is set to
NULL immediately
void CDialogDerived::OnClose()
{
CDialog::OnClose();
DestroyWindow();
}

void CDialogDerived::PostNcDestroy()
{
CDialog::PostNcDestroy();
m_pParent->m_pModelessDialog = NULL;
delete this;
}

Any thoughts pro and con to either of these approaches? I'm curious why the PostNcDestroy is not run promptly
with the OnClose call on the first example.

Thanks!
AnswerRe: modeless dialog WM_CLOSE - opinion Pin
Shog915-Feb-06 3:46
sitebuilderShog915-Feb-06 3:46 
AnswerRe: modeless dialog WM_CLOSE - opinion Pin
Rage15-Feb-06 3:59
professionalRage15-Feb-06 3:59 
GeneralRe: modeless dialog WM_CLOSE - opinion Pin
23_44415-Feb-06 4:43
23_44415-Feb-06 4:43 
GeneralRe: modeless dialog WM_CLOSE - opinion Pin
23_44415-Feb-06 4:58
23_44415-Feb-06 4:58 
GeneralRe: modeless dialog WM_CLOSE - opinion Pin
Shog915-Feb-06 7:53
sitebuilderShog915-Feb-06 7:53 
GeneralRe: modeless dialog WM_CLOSE - opinion Pin
23_44415-Feb-06 8:00
23_44415-Feb-06 8:00 

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.