Click here to Skip to main content
15,671,758 members
Articles / Desktop Programming / MFC
Posted 28 Dec 1999


40 bookmarked

Standard file open dialog with preview

Rate me:
Please Sign up or sign in to vote.
4.24/5 (11 votes)
28 Dec 1999
This article describes a completely object oriented standard file open dialog with preview.


There is no custom hook function, just common MFC message maps. The dialog has a CDibStatic member, which displays the preview image when available. The CDibStatic class encapsulates a static control that displays images and is described in an article in the static controls section.

This is how the dialog looks like:

Image 1

The template for the dialog is a normal developer studio dialog template. Note however, the use of the stc32 static control. As it hasn't any text in it, it is invisible unless you select it. This static control will serve as a place holder for the standard file dialog controls, thus establishing the position of the newly added controls in respect to the standards. If there is no stc32 control specified in the template, all the new controls will be placed below the standard controls. Otherwise, the common file dialog will look at the size of the stc32 control to attempt to fit all the standard controls in it. If it is not big enough, it is resized to make room for the standard controls, and then the new controls are repositioned with respect to the resized stc32 control.

Palette support is included within the dialog class. It is implemented using handlers for the WM_QUERYNEWPALETTE and WM_PALETTECHANGED Windows messages, so you have to ensure in your program that the dialog receives these messages. If the palette never changes, the image is painted with the right palette selected the first time. Since the standard dialogs are modal, the palette changes can be due only to other applications (unless you change it in another thread), thus realizing palette when gaining focus should always maintain the right colors. You can realize the palette at any time you wish by sending a WM_QUERYNEWPALETTE message to the CDibStatic control, for instance.

This class has been used (among other things) to implement a completely object oriented DIBLOOK.


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.

Written By
Cuba Cuba
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

GeneralNeed help on setting this Dialog Pin
jocblack19-Oct-06 10:15
jocblack19-Oct-06 10:15 
Generaluse dll in c# Pin
giugio26-Apr-03 2:29
giugio26-Apr-03 2:29 
GeneralGood One...But no preview for first time!!! Pin
paytapatya25-Jul-02 1:22
paytapatya25-Jul-02 1:22 
GeneralDoubts on VC++ DhtmlEdit Controll for IE5[Table insert,Paste html...] Pin
Ranjith.e.Nair15-Jul-02 23:09
Ranjith.e.Nair15-Jul-02 23:09 
GeneralDoubts on VC++ DhtmlEdit Controll for IE5[Table insert,Paste html...] Pin
Ranjith.e.Nair15-Jul-02 23:08
Ranjith.e.Nair15-Jul-02 23:08 
Doubts on VC++ DhtmlEdit Controll for IE5[Table insert,Paste html...]

I am trying to develop a html editor using vc++6.

Now I am facing four major problems

1 How add Toolbar in a Dialog Based Application using vc+6 ? ,Is it possible in Dialog Based Application ?.

2 How insert a Table in a html page using vc+6's DHTML EDIT Control for IE5 ?.

3 How implement PasteHtml using vc+6's DHTML EDIT Control for IE5 ?.

4 How insert an adjecent Html?

5 How devolop a file opening dialog with html preview ?

The following shows my code for each problem ...

** Problem 2: VB code OK:-

Dim s As New DHTMLEDLibCtl.DEInsertTableParam
s.Caption = "test"
s.NumCols = "2"
s.NumRows = "2"
s.TableAttrs = "border=20"
s.CellAttrs = "bgcolor=black"
** How it solve in VC++6 ?
** Problem 3: VB code OK:-

Private Sub btnInsertNewTag_Click()
'insert new tag at cursor position
Dim tr As Object
Set tr = DHTMLEdit1.DOM.selection.createRange
tr.pasteHTML "
End Sub
** How it solve in VC++6 ?

** Problem 4: VB6 code Error:-

DHTMLEdit1.DOM.body.insertAdjacentHTML "body", "hr"

** Problem 4: VC++6 code Error:-

// It is not proper working.
LPCTSTR lpStrWhere= "body";
LPCTSTR lpStrHtml= "hr";

If you know any methods to solve any of these problem ,you please send the source code or web site address.

Anticipating your early reply



Doubts on VC++ DhtmlEdit Controll for IE5[Table insert,Paste html...]
QuestionHow can i use it in a extension dll ? Pin
10-Jan-02 19:48
suss10-Jan-02 19:48 
Questionhow to use palette Pin
2-Jan-02 23:05
suss2-Jan-02 23:05 
AnswerRe: how to use palette Pin
mvsk417-Jun-12 23:53
mvsk417-Jun-12 23:53 
GeneralElegant Pin
Member 450117-Jun-00 21:28
Member 450117-Jun-00 21:28 

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.