Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

Creating a Dialog box as a New Window

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
fates_warning
Asked:
fates_warning
  • 3
  • 3
1 Solution
 
fates_warningAuthor Commented:
Yeah, i found the answer myself, just pass the window an instance of itself and it works, dah!
0
 
fl0ydCommented:
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
 
fates_warningAuthor Commented:
Yeah, i found the answer myself, just pass the window an instance of itself and it works, dah!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
fl0ydCommented:
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
 
fates_warningAuthor Commented:
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
 
fl0ydCommented:
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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now