?
Solved

Creating a Dialog box as a New Window

Posted on 2003-03-27
6
Medium Priority
?
159 Views
Last Modified: 2013-11-20
I'm still partially new with MFC, and I'm running into a problem with creating an "independent" dialog box.  I'm curious if it's possible to create a dialog box as a new window that can rest on the task bar.

Let's say I have a simple app, that has a single CMainFrame with no views or documents. If, in the constructor of the main frame, I create a new dialog box, the dialog box opens as it's own window, completely separate of the frame. This is what I’m looking for, however, I'm curious if there is a way do this once the frame has been created.

I realize that I can create another frame, or wnd for that matter, but since I already have quite a bit of code written as a dialog box, this would save me time.

Also, I’ve tried calling the CWnd::Create method in the constructor of the derived CDialog box I’m creating, and keep getting error messages saying that there is no method that takes 6 parameters (but it shows up in Visual as one of the overloaded methods). Not sure if I can even do this with inheritance.

Thanks.
0
Comment
Question by:fates_warning
[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
  • 3
  • 3
6 Comments
 

Author Comment

by:fates_warning
ID: 8222994
Yeah, i found the answer myself, just pass the window an instance of itself and it works, dah!
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 8227873
This will get you into trouble, since dialog messages are handled slightly differently from child windows, in particular the navigation with [Tab] and the cursor keys is in the dialog code. You will not be able to handle those key presses yourself. There are other differences, but they won't make your life easier. You have two options, either create a childwindow of type CFormView and place the controls in there or restart your project all over.

.f
0
 

Author Comment

by:fates_warning
ID: 8228889
Yeah, i found the answer myself, just pass the window an instance of itself and it works, dah!
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 8

Accepted Solution

by:
fl0yd earned 60 total points
ID: 8229988
Like I stated previously, it is _NOT_ a solution to your problem. It may appear to work but it doesn't do so properly. If you don't believe me, you will have to learn it the hard way then.

.f
0
 

Author Comment

by:fates_warning
ID: 8237058
Thanks for the warning, although the tone of it is quite negative.

This dialog box will be used for very limited purposes, and it will eventually be upgraded to a frame, so it's not a big deal. Thanks.

0
 
LVL 8

Expert Comment

by:fl0yd
ID: 8237139
The tone is quite negative as the errors that will come up are rather hard to find. It is a word of warning to someone who lacks understanding of the underlying win32 API and is trying to tackle a very complex library, namely MFC. Contrary to what you read in many books, MFC isn't there to make programming accessible to beginners but to make it safer and more productive to experienced users of plain win32 API developers.

A good test for you to decide whether you are ready for MFC or not is this:
a) are you able to write the same application without use of MFC? If no, don't use MFC yet
b) can you set up an MFC project without using the application wizard? If no, you're not ready for it either.

The wording of my previous post is there to stress the fact that you definately haven't found a solution, but rather a hackish workaround to achieve something that _appears_ to accomplish what you need. And it does, albeit it is buggy.

What may have come across as rude or arrogant is merely to point out that the problems that will arise are subtle, almost un-noticable. Just meant to wake you from your sweet dreams about having found a solution, when you just haven't.

.f
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

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