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
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
// ... somewhere ...
// ... and no problem to show again
NOTE: You can test m_hWnd against NULL instead of calling ::IsWindow, as well.
In you use this code
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:
static CMy * Dlg =NULL;
Dlg= new CMy();
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?
Working on a wizard type dilaog application and taken the idea of creating wizard from the below link
Here having one problem:
what I am doing is that Suppose right now on property page number 3 and performing some operaion, after finishing operation want to jump on the next page (number 4) automatically, without clicking on the Next Button.
For this using SetActivePage(int i) function. but this function throws exception.
One more thing that when I jump from Page 3 to Page 2 it jumps successfully, problem is with the pages ahead.
So Please tell me that how to jump over the next page in the wizard automatically
You get exception because dialog for the 'next' page has not been created yet.
I usually send a 'faked' next button press to the parent of wizard pages and it 'thinks' the user has pressed next button. That seems to always work out well.
I've seen better runs in my shorts! - Patches O'Houlihan
Hi,I have taken FormView,in which i have created ListControl,The client area, "rect" of the FormView is taken is taken as i/p for ListControl Creation.I have handled WM_CONTEXTMENU in the formview,in the ContextMenu,there are two items one is "Print" another is "PntView"..ON_COMMAND of both ID_PRINT and ID_PRIVIEW i have handled in formview.in the respective functions i have called CFormView::OnFilePrint,CFormView::OnFilePrintPriview,i have overriden "Onprepareprinting" and "OnPrint".When i click print in the context menu , it is printing,when i click priview in the context preview is coming,but in the preview when i print button,it is not printing , what could be the reason...