Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOpen dialog? Pin
Larsson21-Oct-04 20:40
Larsson21-Oct-04 20:40 
AnswerRe: Open dialog? Pin
C_M_21-Oct-04 21:17
C_M_21-Oct-04 21:17 
GeneralRe: Open dialog? Pin
Larsson21-Oct-04 21:19
Larsson21-Oct-04 21:19 
GeneralRe: Open dialog? Pin
benjymous21-Oct-04 23:07
benjymous21-Oct-04 23:07 
GeneralRe: Open dialog? Pin
Larsson21-Oct-04 23:35
Larsson21-Oct-04 23:35 
GeneralRe: Open dialog? Pin
Larsson23-Oct-04 6:53
Larsson23-Oct-04 6:53 
GeneralRe: Open dialog? Pin
benjymous23-Oct-04 20:17
benjymous23-Oct-04 20:17 
AnswerRe: Open dialog? Pin
BlackDice22-Oct-04 3:19
BlackDice22-Oct-04 3:19 
The suggestion you got earlier about hiding the dialog is ok, but in case you do want to close it in the future so that the modeless dialog is not holding onto memory that your application doesn't need to have, this is what you should do. Make a member pointer variable of the type of your calling class in your modeless dialog's class. Alter the constructor so that it has to have a pointer of the calling class's type (make sure to use a forward declaration in your header file). Like this:

class CCallingClass;  //forward declaration

class CMyModelessDialog : public CDialog
{
  CCallingClass* m_pCaller;
};

in your constructor, set the member pointer equal to the pointer sent in. Then when you want to close the dialog, do this:

m_pCaller->SendMessage(WM_USER_CLOSE_MODELESS);


In your stdafx.h file,

#define WM_USER_CLOSE_MODELESS (WM_USER + 1001)

Add a message map entry for your #defined message like any other message, and map it to the appropriate function. In that function, do this:

m_modless.DestroyWindow();


Who are all these people and what are they doing in my house?...Me in 30 years, inside a grocery store

My articles[^]
bdiamond Sleepy | :zzz:
GeneralRe: Open dialog? Pin
Larsson23-Oct-04 6:54
Larsson23-Oct-04 6:54 
AnswerRe: Open dialog? Pin
David Crow22-Oct-04 4:40
David Crow22-Oct-04 4:40 
GeneralRe: Open dialog? Pin
Larsson23-Oct-04 6:54
Larsson23-Oct-04 6:54 
GeneralRe: Open dialog? Pin
David Crow25-Oct-04 2:50
David Crow25-Oct-04 2:50 
Questionclose dialog? Pin
Larsson21-Oct-04 20:39
Larsson21-Oct-04 20:39 
AnswerRe: close dialog? Pin
V.21-Oct-04 21:01
professionalV.21-Oct-04 21:01 
GeneralRe: close dialog? Pin
Larsson21-Oct-04 21:05
Larsson21-Oct-04 21:05 
GeneralRe: close dialog? Pin
Larsson21-Oct-04 21:07
Larsson21-Oct-04 21:07 
GeneralRe: close dialog? Pin
V.21-Oct-04 21:27
professionalV.21-Oct-04 21:27 
GeneralRe: close dialog? Pin
Larsson21-Oct-04 21:31
Larsson21-Oct-04 21:31 
GeneralC++ question. Pin
WREY21-Oct-04 20:16
WREY21-Oct-04 20:16 
GeneralRe: C++ question. Pin
Yulianto.21-Oct-04 22:04
Yulianto.21-Oct-04 22:04 
GeneralRe: C++ question. Pin
V.21-Oct-04 23:27
professionalV.21-Oct-04 23:27 
GeneralRe: C++ question. Pin
digwizfox22-Oct-04 11:05
digwizfox22-Oct-04 11:05 
GeneralRe: C++ question. Pin
WREY22-Oct-04 13:46
WREY22-Oct-04 13:46 
GeneralRe: C++ question. Pin
digwizfox25-Oct-04 6:32
digwizfox25-Oct-04 6:32 
GeneralRe: C++ question. Pin
WREY25-Oct-04 7:31
WREY25-Oct-04 7:31 

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.