Applies to  VB4/32   VB5+ 

Adding a Client Edge to a Form

Code

A window with the "client edge" style has an inside border with a sunken edge:

Screenshot of a form with the client edge style

One way to add a client edge to a form is to draw a picture box that fills the entire form. Another way is to add the WS_EX_CLIENTEDGE window style to the form and let Windows draw the border for you. Add these two statements to the Form_Load event:

To preserve existing styles, the first statement retrieves them with GetWindowLong before adding WS_EX_CLIENTEDGE. The second statement repaints the form by calling the RedrawWindow procedure (available in General.bas):

These are the required API declarations (available in Win32.tlb):

Comments

Without the call to RedrawWindow, the client edge wouldn't appear until the form was resized.

In the call to SetWindowPos, the SWP_FRAMECHANGED constant causes Windows to redraw the frame of the window. The other constants indicate that the window isn't being moved, sized, repositioned, or activated.

The WS_EX_CLIENTEDGE style is especially useful for MDI child forms. If instead you use a picture box to provide the sunken border, a "double edge" appears when the user maximizes the form. Windows automatically takes care of this problem when you use the WS_EX_CLIENTEDGE style.

1