?
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
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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 200 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 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