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
179 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
Independent Software Vendors: 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 83
Replacement selected text 2 66
conditional code and condition difference 9 84
ffmpeg - "rtsp://...... Operation not permitted" 4 89
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 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