DropShad.exe Draws Custom Border Around Control Window
ID: Q66992
|
The information in this article applies to:
-
Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1
SUMMARY
DropShad.exe demonstrates how to create an edit control with a "drop
shadow." The parent window of the edit control draws the drop shadow on the
control's behalf.
Microsoft Windows is not designed to allow a control to draw its own custom
border. If an application subclasses the control and draws a border during
the processing of the WM_PAINT message, the control will not be clipped
properly because the control does not determine the clipping when it draws
outside its client area.
The proper approach is to have the parent of the control draw the border
during the processing of a WM_PAINT message. In this case, Windows will
perform the appropriate clipping automatically.
MORE INFORMATION
The following files are available for download from the Microsoft
Download Center. Click the file names below to download the files:
DropShad.exe
For more information about how to download files from the Microsoft
Download Center, please visit the Download Center at the following Web
address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.
The following three steps draw the drop shadow:
- During the processing of the parent window's WM_CREATE message, the
parent creates the edit control and sets a static variable to the
edit control's HWND (which will be needed to draw the shadow).
- The parent windows draws the drop shadow during the processing of a
WM_PAINT message. The parent window uses GetWindowRect() to
determine the rectangle of the edit control in screen coordinates.
The ScreenToClient() function converts this data to local
coordinates, then OffsetRect() offsets the rectangle to determine
the bounds of the shadow. (The code for this step would go very
nicely into a DrawShadow() procedure if the application had more
than one edit control to shadow.)
- The parent window calls Rectangle() to draw the two rectangles that
create the drop shadow.
The width of the drop shadow, how far the drop shadow is offset from the
corners of the edit control, and the color of the brush used to paint the
drop shadow can be varied to achieve a particular control appearance.
Additional query words:
Keywords : kbfile kbsample kb16bitonly kbCtrl kbGrpUser kbWinOS310 kbWndw kbWinOS300
Version : WINDOWS:3.0,3.1
Platform : WINDOWS
Issue type :