Solved

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

Posted on 2000-02-21
12
175 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?

0
Comment
Question by:dreadedjew
12 Comments
 
LVL 3

Expert Comment

by:GlennDean
ID: 2544080
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
 

Author Comment

by:dreadedjew
ID: 2544663
This "hack" does work but is there a way to avoid the hack and embed that dialog into the original CMainFrame Window?
0
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2544706
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
 
LVL 5

Expert Comment

by:Wyn
ID: 2544712
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
 
LVL 8

Expert Comment

by:VinExpert
ID: 2544748
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
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2544770
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Expert Comment

by:Andrian
ID: 2545007
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
 

Accepted Solution

by:
Vriz earned 50 total points
ID: 2545298
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
 

Author Comment

by:dreadedjew
ID: 2546500
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
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2547696
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
 

Author Comment

by:dreadedjew
ID: 2555153
Hey that is MUCH easier!!!
0
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2555681
Excellent, dreadedjew, and your confirmation that it works is all I need.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now