Click here to Skip to main content
13,254,187 members (64,343 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 16 Jun 2002

An alternative to the often asked view-in-dialog problem using a dialog bar

, 2 Jul 2002
Rate this:
Please Sign up or sign in to vote.
In this article I show an alternative to the tricky (and thus often unstable) attempts to create a view on a dialog.


I tried to create a View on a Dialog, and thus looked up all the articles on the web. There are several attempts to do this, but more or less all of them produce errors and aren't too useful in  my opinion. So I decided to go a different way. I created a new Window type (called CDialogWindow in my demo project) by deriving the class from CFrameWnd. In this CDialogWindow I created a View using Jorge Vigils code from (I modified it of course, but am nonetheless grateful to Jorge). This View was a CScrollView which was my main intention, and perhaps this is also yours. Just imagine a task like displaying a bitmap on a dialog in full-size, which doesn't fit in the Dialog form. My own task was to display a video image generated by an ActiveX-Control. Instead of really displaying this image in a dialog, I created the just mentioned view in the CDialogWindow and added a CDialogBar to this window. The result looks nearly like a dialog containing a view.

But unfortunately I have to deal with an unexpected disadvantage using this simple technique. As the CDialogBar isn't connected with an own class but with the CDialogWindow Class, it is not possible to connect variables with the controls. This means of course, that all the advanced controls like spin buttons, scroll bars etc. which need to be represented by a variable of "Control" type, cannot be used. The functionality of the Window is reduced to input and output in text fields using the methods GetDlgItemInt(), GetDlgItemText(), SetDlgItemInt(), SetDlgItemText(). Perhaps someone can improve my project and tell me how to use all sort of controls in such a window.


As you can see in the demo project, I have added my CDialogWindow to an MDI project, not using any of the classes created by the application wizard. So if you take my project as a start point, you still have all the functionality of an MDI-app. Mainly I haven't used the generated view class but a class which I imported from another project, because this class was good for my purpose. Just to show you how the window works, I have replaced my video image by a simple text. What does this mean for you, if you want to copy some of my code:

  • Copy the CDialogWindow class to your project and create an object with the DoModeless() method as you can see it in the project.
  • If you also want to display anything but not a document, also copy the CExtraView class and modify the OnDraw() method in order to make it display your stuff.
  • If you want to create a view of a document or create a view from your own view class, just replace the class name in the RUNTIME_CLASS Macro in CDialogWindow::OnCreateClient() and don't forget to declare CVideoWindow friend of your own view class. Of course you will have to do some other little modifications like including the header files and so on.


Pleas write me an <A>email if you could improve my classes, especially, if you achieve to use all sort of controls in the dialog bar. I'm sorry, but I generated the demo project using the German version of the SDK. Thus the auto-generated comments are in German. This should not prevent you from understanding the code, as all pieces of my own code are commented in English.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Germany Germany
Thomas Schuster, studying Physics in Ulm / Germany and therefore programming Visual C++.

You may also be interested in...


Comments and Discussions

Answerthanks .you help me a lot Pin
zxl2004068-Sep-11 21:43
memberzxl2004068-Sep-11 21:43 
GeneralThanks,your code has a great help to me. Pin
82745426-Aug-08 23:04
member82745426-Aug-08 23:04 
QuestionWhat you present isn't really a dialog Pin
AweAwe28-May-04 10:22
memberAweAwe28-May-04 10:22 
Generaldocking CdialogBar like toolbal Pin
yaser7-Sep-02 11:03
memberyaser7-Sep-02 11:03 
QuestionFor me illogical conclusion? Pin
Jörgen Sigvardsson18-Jun-02 5:22
memberJörgen Sigvardsson18-Jun-02 5:22 
AnswerRe: For me illogical conclusion? Pin
Daniel Turini3-Jul-02 12:50
memberDaniel Turini3-Jul-02 12:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 3 Jul 2002
Article Copyright 2002 by thom_as
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid