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
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.