hi all [modified]
-
plz tell me dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); when i rty this to create modeless dialog box after one try it will create error as assertion failureplz Ashish Dogra MCA Noida -- modified at 1:33 Thursday 29th June, 2006
yes because you create your dialog and you dont need to create again_**
**_
whitesky
-
yes because you create your dialog and you dont need to create again_**
**_
whitesky
sir i will try to create it again after cancelling it but sir as with domaodal() we can try again after cancelling it it will not give any error Ashish Dogra MCA Noida
-
plz tell me dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); when i rty this to create modeless dialog box after one try it will create error as assertion failureplz Ashish Dogra MCA Noida -- modified at 1:33 Thursday 29th June, 2006
For a modeless dailog, you should define your own constructore, never let the default constructor to call the base class with template ID. Here is an article from MSDN[^] SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar." My Blog | Understanding State Pattern in C++ -
For a modeless dailog, you should define your own constructore, never let the default constructor to call the base class with template ID. Here is an article from MSDN[^] SaRath.
"It is your attitude, not your aptitude, that determines your altitude - Zig Ziglar." My Blog | Understanding State Pattern in C++even i use this i will still not solve the problem CMy dlg; dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); please tell me some example Ashish Dogra MCA Noida
-
even i use this i will still not solve the problem CMy dlg; dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); please tell me some example Ashish Dogra MCA Noida
ashish dogra wrote:
CMy dlg; dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1);
Whats problem with this code_**
**_
whitesky
-
plz tell me dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); when i rty this to create modeless dialog box after one try it will create error as assertion failureplz Ashish Dogra MCA Noida -- modified at 1:33 Thursday 29th June, 2006
After exiting DoModal, the attached window of CDialog object is destroyed and detached, so there is no problem to call DoModal again. For a modeless dialog (made with CDialog::Create), unless the CDialog object goes out-of scope or DestroyWindow was called, the window is not destroyed, not even the user pushes OK/Cancel/close button. So you have to test if the dialog was created before call CDialog::Create. If yes, then simply show it:
void CFoo::ShowModelessDialog(CDialog& dlg, UINT nResID) { if(!::IsWindow(dlg.m_hWnd)) // thest attached window handle { // create only if not yet created dlg.Create(nResID, this); } dlg.ShowWindow(SW_SHOW); } // ... // ... somewhere ... ShowDialog(m_dlg, IDD_DIALOG1); // ... and no problem to show again ShowDialog(m_dlg, IDD_DIALOG1);
NOTE: You can test m_hWnd against NULL instead of calling ::IsWindow, as well. Ovidiu Cucu Microsoft MVP - Visual C++
-
ashish dogra wrote:
CMy dlg; dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1);
Whats problem with this code_**
**_
whitesky
sir the problem is that when i run application the modeless dialog box open a screen after clicking on ok button of fiest dialog box but when i cancel the modeless dialog and again click on ok button of first dialog box then it will give an assertion error and does not create modeless dialog box again plz sovle this one Ashish Dogra MCA Noida
-
sir the problem is that when i run application the modeless dialog box open a screen after clicking on ok button of fiest dialog box but when i cancel the modeless dialog and again click on ok button of first dialog box then it will give an assertion error and does not create modeless dialog box again plz sovle this one Ashish Dogra MCA Noida
Can you show how to use and you show your code that has error_**
**_
whitesky
-
After exiting DoModal, the attached window of CDialog object is destroyed and detached, so there is no problem to call DoModal again. For a modeless dialog (made with CDialog::Create), unless the CDialog object goes out-of scope or DestroyWindow was called, the window is not destroyed, not even the user pushes OK/Cancel/close button. So you have to test if the dialog was created before call CDialog::Create. If yes, then simply show it:
void CFoo::ShowModelessDialog(CDialog& dlg, UINT nResID) { if(!::IsWindow(dlg.m_hWnd)) // thest attached window handle { // create only if not yet created dlg.Create(nResID, this); } dlg.ShowWindow(SW_SHOW); } // ... // ... somewhere ... ShowDialog(m_dlg, IDD_DIALOG1); // ... and no problem to show again ShowDialog(m_dlg, IDD_DIALOG1);
NOTE: You can test m_hWnd against NULL instead of calling ::IsWindow, as well. Ovidiu Cucu Microsoft MVP - Visual C++
In you use this code void OnSomeFunction() { CMy dlg; dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); } this is not safe, because the dlg object is created in Stack and it will get destroyed as soon as the function is out of scope. Create ModeLess Dialogs in Heap or Make Sure that the Object is not out of scope by making is static or Global/Top Clsss Variale Like. One Way of Doing It is: void OnSomeFunction() { static CMy * Dlg =NULL; if (!m_Dlg) { Dlg= new CMy(); Dlg->Create(IDD_DIALOG1); } dlg.ShowWindow(1); }
-
Can you show how to use and you show your code that has error_**
**_
whitesky
void CGd1Dlg::OnOK() { CMy dlg; dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); } Ashish Dogra MCA Noida
-
void CGd1Dlg::OnOK() { CMy dlg; dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); } Ashish Dogra MCA Noida
can you show in
CMy::CtetDlg(CWnd* pParent /*=NULL*/) : CDialog(CtetDlg::IDD, pParent)
and one suggestion use this function instead your functions and answer to me it work or doesnt workCMy::CtetDlg(CWnd* pParent /*=NULL*/) : CDialog(CtetDlg::IDD, pParent) BOOL o= Create(IDD,pParent);
-----------void CGd1Dlg::OnOK() { CMy *dlg; dlg=new CMy(this); /*use from breakpoint and debug for see error if you get a error*/ dlg->ShowWindow(1); }
_**
**_
whitesky
-
can you show in
CMy::CtetDlg(CWnd* pParent /*=NULL*/) : CDialog(CtetDlg::IDD, pParent)
and one suggestion use this function instead your functions and answer to me it work or doesnt workCMy::CtetDlg(CWnd* pParent /*=NULL*/) : CDialog(CtetDlg::IDD, pParent) BOOL o= Create(IDD,pParent);
-----------void CGd1Dlg::OnOK() { CMy *dlg; dlg=new CMy(this); /*use from breakpoint and debug for see error if you get a error*/ dlg->ShowWindow(1); }
_**
**_
whitesky
thanks sir it works thanks a lot ......................HAVE A NICE DAY Ashish Dogra MCA Noida
-
In you use this code void OnSomeFunction() { CMy dlg; dlg.Create(IDD_DIALOG1); dlg.ShowWindow(1); } this is not safe, because the dlg object is created in Stack and it will get destroyed as soon as the function is out of scope. Create ModeLess Dialogs in Heap or Make Sure that the Object is not out of scope by making is static or Global/Top Clsss Variale Like. One Way of Doing It is: void OnSomeFunction() { static CMy * Dlg =NULL; if (!m_Dlg) { Dlg= new CMy(); Dlg->Create(IDD_DIALOG1); } dlg.ShowWindow(1); }
Hey, hey, dear Indian Idol! To be clear. I didn't suggest to declare a CDialog object locally in a function. Did you see that in may example? If you pay a little bit more attention, can observe that I prefixed with m_ which suggest that m_dlg is a member of class CFoo. And your static CMy *Dlg locally declared in OnSomeFunction() smells a C. And by the way... where you think it's possible to delete *Dlg in order to get rid of memory leaks? Ovidiu Cucu Microsoft MVP - Visual C++