Creating Odd Shaped Forms
Public Declare Function _ OffsetRgn _ Lib "gdi32" _ (ByVal hRgn As Long, _ ByVal x As Long, _ ByVal y As Long) As Long
This function allows you to shift the specified region by x, y pixels.
It can return the following constants:
Public Declare Function _ CombineRgn Lib "gdi32" _ (ByVal hDestRgn As Long, _ ByVal hSrcRgn1 As Long, _ ByVal hSrcRgn2 As Long, _ ByVal nCombineMode As Long)_ As Long
This API provides the ability to join two regions using a variety of different methods. The source regions are specified in hSrcRgn1 and hSrcRgn2, and the combined region will be specified in hDestRgn. Note that the destination region must already be created as a region before this API is called. To get round this, create a rectangle, left, top, width and height dimensions of 0, then call the CombineRgn API with this region handle. The nCombineMode can be one of the following:
Initializing the Window
Public Declare Function SetWindowRgn _ Lib "user32" _ (ByVal hWnd As Long, ByVal hRgn _ As Long, ByVal bRedraw As Boolean) _ As Long
Use this function to make the window into your custom shape. The hWnd is the window
handle of the window on which to set the region. This can be anything that provides a
hWnd, including Forms, Command Buttons, Picture Boxes, etc. Set bRedraw to True to
automatically redraw the window when the new region has been applied.
This will return 0 on failure.
Public Declare Function DeleteObject _ Lib "gdi32" _ (ByVal hObject As Long)_ As Long
As with most GDI functions, the region handles must be "tidied up". This is done using the DeleteObject API. Once you have set the window's region, you can delete all the regions, except for the one that you used in SetWindowRgn. You should return the form to its original shape by passing hRgn=0 to the SetWindowRgn function, then deleting the region handle.
Page 3 of 4