Modalless Dialog

How can I have a dialog based program start up as Modaless?
bradsobleskyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
DeckmeisterCommented:
Hi,

You have to use the function
ShowWindow(SW_SHOW)
and NOT Show.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.