Modalless Dialog

How can I have a dialog based program start up as Modaless?
bradsobleskyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
DeckmeisterConnect With a Mentor Commented:
Hi,

You have to use the function
ShowWindow(SW_SHOW)
and NOT Show.
0
 
DeckmeisterCommented:
Hi,

To create a modal dialog box, you have
to use the CDialog constructor and
then DoModal()

If you want a modaless dialog box, you
have to call the constructor and then
Create() (and NOT DoModal()).

If you have generated your application
with AppWizard, you simply have to
find DoModal()
-> in C...App::InitInstance
and call Create instead of DoModal()
0
 
MrFlibble052199Commented:
Don't forget you have to show it as well,


CMyDialog dlg;

dlg.Create(IDD_MYDIALOG);
dlg.Show(SW_SHOW);
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
bradsobleskyAuthor Commented:
I get a runtime error that brings me here:


HWND CDialog::PreModal()
{
      // cannot call DoModal on a dialog already constructed as modeless
      ASSERT(m_hWnd == NULL);

      // allow OLE servers to disable themselves
      CWinApp* pApp = AfxGetApp();
      if (pApp != NULL)
            pApp->EnableModeless(FALSE);
0
 
bradsobleskyAuthor Commented:
I think i fixed that now i get:

SecurityDlg.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CSecurityDlg::DoModal(void)" (?DoModal@CSecurityDlg@@UAEHXZ)
Debug/Security.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

0
 
bradsobleskyAuthor Commented:
not working
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

I could not understand Ur requirement properly. Why U want the dilaogbased apps main dialog to be modeless?. It makes no difference as such if it is modaled one.

But if U want to create the modeless dialog box, here r the steps.
1. using resource editor, create a dialog with id IDD_MYDIALOG.
2. Add the class to it, say CMyDlg.
3. Then say u want to pop it up in x.cpp, then go to x.h and add the follwing include header to it
#include "MyDlg.h"
Then declare a variable as public as
CMyDlg *m_dlg;

4. Then in the constructor of the x.cpp do
    m_dlg = NULL;
5. Then U want to pop up do
    m_dlg = new CMyDlg;
    m_dlg->Create(IDD_MYDIALOG, this);
    m_dlg->ShowWindow(SW_SHOW);

Thats it.
VinExpert
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

There is one way. U can have the dummy SDi app, There pop up Ur main dialog as modeless as I mentioned. Then hide the main window of SDI.

Try it out.
VinExpert
0
 
abancroftCommented:
A modeless application (dialog based or otherwise) doesn't make sense.

Do you want your app to float over all other applications? Then use SetWindowPos(wndTopMost, ...) or apply the WS_EX_TOPMOST style.
0
All Courses

From novice to tech pro — start learning today.