![]() |
3 | Code Libraries |   |
  |
Setting a UserControl's BorderStyle |
|
Provide unique border style options by modifying the WindowStyle directly with this drop-in code |
Download the BorderStyle control code (5kb)
VB creates a border on a UserControl through an extended Window Style provided in Win32,
WS_EX_CLIENTEDGE. You can see this by using the SPY++ program provided with various Microsoft
Development products (on the VB Enterprise CD it can be found in the Tools directory). Start
SPY++ and use the Window Finder tool to point at a VB User Control with BorderStyle set
to 1. You will see WS_EX_CLIENTEDGE in the list of WindowStyles for that window.
When this style is set, Windows automatically draws a border around the window and
resets the client region of the window to leave out the border.
You can set other styles for a controls border by using the API SetWindowLong
function. The extended style WS_EX_STATICEDGE provides a thin, sunken border whilst
the extended style WS_EX_WINDOWEDGE in combination with the standard styles
WS_BORDER and WS_THICKFRAME provides a raised edge.
The code in the control in the download provides you all you need to add these styles to
your own user control. It's easy! And you don't have to change any of your resizing code
or drawing code to add it, because VB's ScaleWidth and ScaleHeight properties
use the underlying GetClientRect API and hence take account of the differing border
styles.
Back to top
Back to Source Code Overview
![]() |
|
About Contribute Send Feedback Privacy
|