We help IT Professionals succeed at work.

How do I make an app (not a dialog) that is just a frame with some edit boxes, labels and a few buttons?

dreadedjew
dreadedjew asked
on
201 Views
Last Modified: 2013-11-20
Hi,

First of all let me explain why I need an actually app derived from CFrameWnd and not an dialog:

1) I need the app to stay running in the background after the user hits ok.
2) I need to call showwindow( sw_hide ) so that the window hides itself but stays active.

My question is how do I get an appwizard app to show my "dialog" resource instead of the white background thingy?

Comment
Watch Question

Suppose you have an SDI/MDI app and you want to initially show your dialog (say the dialog is called CMyDialog).  In your app's InitInstance function, at the bottom you can insert the code

m_pMainWnd->ShowWindow(SW_HIDE);
CMyDialog dlg;
dlg.DoModal();
m_pMainWnd->ShowWindow(SW_SHOW);

I just tried it - works great.
  Glenn

Author

Commented:
This "hack" does work but is there a way to avoid the hack and embed that dialog into the original CMainFrame Window?

Commented:
I think that your description of your  requirement is not as clear as it could be. You say that you want to your dialog resource to be shown. This implies you want the advantages of both, the dialog editor and non-dialog windows. This is something that I noticed years ago, before MFC existed.

Well anyway, CFormView fortunately provides the capability of both. You probably want to use CFormView for your view. That way you can design your layout using the dialog editor but still have (most of) the advantages of non-dialog windows.

Wyn

Commented:
First of all let me explain why I need an actually app derived from CFrameWnd and not an dialog:

1) I need the app to stay running in the background after the user hits ok.
2) I need to call showwindow( sw_hide ) so that the window hides itself but stays active.
-------------------------------

No,you can use Dialoge-based app.
What's problem you think you will encounter if you use a dialogue?
Plz tell us...
Vinayak KumbarSr Program Manager

Commented:
Hi,

U can use the dialog based app.
>1) I need the app to stay running in the background after the user hits ok.
Yes U can do it using dialog based app too. Just trap the OnOk() function comment out the CDialog::OnOk() call and add the code to hide the window.

Then
>2) I need to call showwindow( sw_hide ) so that the window hides itself but stays active.

Yes U can do that too as I told.
Just give a try using dialog based app. That will solve Ur prob.
VinExpert

Commented:
Something that has not been mentioned yet is making the dialog modeless, but my guess is that the CFormView solution is probably the easiest and most effective.

Commented:
When you say:"the window hides itself but stays active".Do you want to catch somes Windows events or there's others works that your app should do?
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you very much Vriz!

I understand some programmers desire to use hacks but you showed me how I can accomplish what I needed without a hack, and it was indeed as easy as anybody elses method.

Thank you all who responded,
-dj

Commented:
There is a much easier way to do it. Much easier, and I am sorry I did not mention the details, but you did not seem to want to use my suggestion.

When you generate an application using AppWizard, in the final step it lists the classes to be generated. The view class can be changed, and one of the options is CFormView. Bt selecting it, everything else that Vriz says to do is already done! Including creation of a blank dialog to be used as the form.

Author

Commented:
Hey that is MUCH easier!!!

Commented:
Excellent, dreadedjew, and your confirmation that it works is all I need.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.