Click here to Skip to main content
16,005,734 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CPropertyPagae [modified] Pin
bob1697228-May-06 19:35
bob1697228-May-06 19:35 
GeneralRe: CPropertyPagae [modified] Pin
ftsOne29-May-06 5:51
ftsOne29-May-06 5:51 
GeneralRe: CPropertyPagae [modified] Pin
bob1697229-May-06 10:13
bob1697229-May-06 10:13 
GeneralRe: CPropertyPagae [modified] Pin
ftsOne29-May-06 10:43
ftsOne29-May-06 10:43 
Questioncontrol Dlg classes in 1 application Pin
Immunity1828-May-06 8:00
Immunity1828-May-06 8:00 
AnswerRe: control Dlg classes in 1 application Pin
bob1697228-May-06 8:50
bob1697228-May-06 8:50 
GeneralRe: control Dlg classes in 1 application Pin
Immunity1828-May-06 8:54
Immunity1828-May-06 8:54 
GeneralRe: control Dlg classes in 1 application Pin
bob1697228-May-06 9:36
bob1697228-May-06 9:36 
That would require modeless dialog boxes which are usually instanciated on the heap and using them easily becomes confusing, time-consuming and error prone since the dialog usually is responsible for deleting itself but all the while someone else has a pointer to it so SendMessage becomes a necessity to communicate what is happening to the main window.

void CYourView::OnShow()
{
// TODO: Add your control notification handler code here

if (m_pDlg) // Window already exists so go to it
m_pDlg->SetFocus();
else {
m_pDlg=new CYourModelessDlg();
m_pDlg->Create(IDD_MODELESS);
m_pDlg->ShowWindow(SW_SHOW);
}
}

void CyourModelessDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class

CDialog::PostNcDestroy();

delete this;
}

void CYourModelessDlg::OnCancel()
{
// TODO: Add extra cleanup here
DestroyWindow();

// CDialog::OnCancel();
}

Obviously, there are quite a few "gotchas" here that I won't even bother to get into as well as the extra work required to communicate between the dialog and the main window. This is where I'll suggest you consider using property sheets/pages or at least try to combine the functionality into a single stack based modal dialog. This way, everything fits well into a single function since the DoModal command blocks and there is no concern for resource cleanup since the dialog instance is usually local. There's no need to communicate when, where, and how the dialog was dismissed as your return variable has all that and getting your data is a breeze since the dialog does not go out of scope until the function ends. Need I mention that there is no dangling pointer as you probably noticed the modeless dialog leaves this particular dangerous situation for you to sort out on your own.

For what it's worth...
QuestionXML/Soap/HTTP Questions (help your n00b) Pin
chasetoys28-May-06 7:19
chasetoys28-May-06 7:19 
QuestionCreateProcessWithLogonW limitations? Pin
fourierman28-May-06 6:24
fourierman28-May-06 6:24 
AnswerRe: CreateProcessWithLogonW limitations? Pin
fourierman28-May-06 10:08
fourierman28-May-06 10:08 
AnswerRe: CreateProcessWithLogonW limitations? Pin
bob1697228-May-06 11:20
bob1697228-May-06 11:20 
GeneralRe: CreateProcessWithLogonW limitations? Pin
fourierman28-May-06 11:49
fourierman28-May-06 11:49 
QuestionHow i write text in a file Pin
Immunity1828-May-06 5:59
Immunity1828-May-06 5:59 
AnswerRe: How i write text in a file [modified] Pin
bob1697228-May-06 6:30
bob1697228-May-06 6:30 
GeneralRe: How i write text in a file [modified] Pin
Immunity1828-May-06 6:49
Immunity1828-May-06 6:49 
GeneralRe: How i write text in a file [modified] Pin
bob1697228-May-06 7:07
bob1697228-May-06 7:07 
GeneralRe: How i write text in a file [modified] Pin
bob1697228-May-06 7:16
bob1697228-May-06 7:16 
GeneralRe: How i write text in a file [modified] Pin
Immunity1828-May-06 7:18
Immunity1828-May-06 7:18 
QuestionSpeed up listview when adding thousands of items Pin
Master Gollom28-May-06 5:56
Master Gollom28-May-06 5:56 
AnswerRe: Speed up listview when adding thousands of items Pin
bob1697228-May-06 6:36
bob1697228-May-06 6:36 
GeneralRe: Speed up listview when adding thousands of items Pin
Master Gollom28-May-06 6:41
Master Gollom28-May-06 6:41 
GeneralRe: Speed up listview when adding thousands of items Pin
Immunity1828-May-06 9:32
Immunity1828-May-06 9:32 
AnswerRe: Speed up listview when adding thousands of items [modified] Pin
anwer_skk28-May-06 16:45
anwer_skk28-May-06 16:45 
GeneralRe: Speed up listview when adding thousands of items [modified] Pin
Master Gollom28-May-06 22:32
Master Gollom28-May-06 22:32 

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.