Click here to Skip to main content
Click here to Skip to main content

MFC Transparent CDialog Demo

, 3 Dec 2002 CPOL
Rate this:
Please Sign up or sign in to vote.
A transparent dialog
<!-- Download Links --> <!-- Article image -->

Sample Image - transparentdialog.gif

Introduction

This dialog is derived from CDialog. A bitmap is loaded from a file and a region created based on a transparent colour. The bitmap is then used to paint the dialog. This demo also demonstrates dragging the dialog by clicking anywhere on a visible portion of the dialog, timer events and a button on the transparent dialog.

It is perfect to be used as a splash screen or similar application or as a skeleton application for non rectangular windows that are shaped by a supplied bitmap.

The code

You should be able to use this demo as a skeleton application for your own project.

A standard CDialog MFC EXE application was created with the wizard and apart from the standard supplied code, the following functions were overridden.

void OnClose() Used to clean up some resources on exit.
void OnPaint() Used to paint the bimap into the region.
void OnSize(UINT nType, int cx, int cy) Used to create the region and position and resize the dialog.
void OnLButtonDown(UINT nFlags, CPoint point) To allow the dialog to be dragged by clicking anywhere.

A button was created to allow the user to close the dialog. A timer was created to demonstrate auto closing after a period of time.

The image is a normal bmp file that is loaded by the app and used to paint the dialog. TRANSPARENTCOLOR is defined in the dialog class header as bright purple (RGB(255, 0, 255), but this could be changed to any colour you like.

The dialog window is auto sized to the size of the loaded bitmap then a region created based on the transparent colour. The dialog is then positioned in the centre of the current screen. This was done as an example for those who want to use this application as a splash windows.

An example of using this class is as follows:

CTransparentDialogDlg dlg;
int nResponse = dlg.DoModal();

The button serves no real purpose and was made a close button simply to demonstrate using a button.

History

V1.0 initial release 27th November 2002

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nic Wilson
Web Developer
Australia Australia
No Biography provided

Comments and Discussions

 
GeneralGetting an Error Pinmembersimhadri13-Mar-06 23:29 
GeneralRe: Getting an Error PinmemberCode Incomplete...11-Apr-06 18:41 
Questionhi,greate, but can it is used with ws_child window? Pinmemberwwx13-Sep-05 18:03 
Generalcapture hiden window Pinmemberjags_vc16-Feb-05 20:36 

 

 
I have a problem like this.i have hooked
WM_CREATE message and whenewer application window is created
i just takes it HWND and passes user Defined message to another application that application handles userdefined message(This application is also my application).In that message handlers i have kept delay of 100 ms and capture the image and then hide it.
That is work but when i hide window in WM_CREATE hook procedure then pass Userdefined message to my application then it can`t be captured insted it capures only active window`s GUI of Size of my hiden application window.
 

I think that to capture any window it is requred to be visible.
but is it possible that by copying memory content of Windows Gui we can also capture the image of window ?
 
Confused | :confused:
Generalproblem with the position of the window PinsussMarco Randazzo14-Sep-04 4:31 
GeneralTry this... Pinmemberel_rata15-Jan-04 9:57 
GeneralWonderful ! PinmemberLeeZi1-Sep-03 15:35 
QuestionGreat!! But is it possible?? PinmemberAWebDude12-Mar-03 15:24 
GeneralImage.bmp is not provided with the zip PinmemberShanhaz12-Mar-03 0:51 
GeneralRe: Image.bmp is not provided with the zip PinmemberNic Wilson12-Mar-03 12:18 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 4 Dec 2002
Article Copyright 2002 by Nic Wilson
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid