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

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?

dreadedjewAsked:
Who is Participating?
 
VrizConnect With a Mentor Commented:
Hi,

You can build your application by using the Single Document Application.  You can then use a CFormView in this case. Create a dialog as usual but go to its properties to change it to style to child and border to none. Then go to classview and create a class for it. For example, CNewFormView and select its base class as CFormView.

If your application/file name is test, go to test.cpp and add

#include "NewFormView.h"

then change the code from


      CSingleDocTemplate* pDocTemplate;
      pDocTemplate = new CSingleDocTemplate(
            IDR_MAINFRAME,
            RUNTIME_CLASS(CTestDoc),
            RUNTIME_CLASS(CMainFrame),       // main SDI frame window
            RUNTIME_CLASS(CTestView));
      AddDocTemplate(pDocTemplate);


to



      CSingleDocTemplate* pDocTemplate;
      pDocTemplate = new CSingleDocTemplate(
            IDR_MAINFRAME,
            RUNTIME_CLASS(CTestDoc),
            RUNTIME_CLASS(CMainFrame),       // main SDI frame window
            RUNTIME_CLASS(CNewFormView));
      AddDocTemplate(pDocTemplate);

0
 
GlennDeanCommented:
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
0
 
dreadedjewAuthor Commented:
This "hack" does work but is there a way to avoid the hack and embed that dialog into the original CMainFrame Window?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
SamHobbsCommented:
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.

0
 
WynCommented:
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...
0
 
Vinayak KumbarSr Program ManagerCommented:
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
0
 
SamHobbsCommented:
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.
0
 
AndrianCommented:
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?
0
 
dreadedjewAuthor 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
0
 
SamHobbsCommented:
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.

0
 
dreadedjewAuthor Commented:
Hey that is MUCH easier!!!
0
 
SamHobbsCommented:
Excellent, dreadedjew, and your confirmation that it works is all I need.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.