Here is how to use, to manipulate the shape of the form. Normally shape of a form is square, but by using function of WinAPI then the shape can be changed. If you want to try , follow the illustration ( Add syntax In INIT Form and change the number that is red to change the form ) :
ROUND SHAPE
Declare Long CreateEllipticRgn IN WIN32API Long X1, Long Y1, ;
Long X2, Long Y2
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, ;
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, ;
String bRedraw
SetWindowRgn(thisform.hwnd, ;
SetWindowRgn(thisform.hwnd, ;
CreateEllipticRgn(1,1,100,100), "True")
SQUARE SHAPE
Declare Long CreateRectRgn IN WIN32API Long X1, Long Y1, ;
Long X2, Long Y2
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, ;
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, ;
String bRedraw
SetWindowRgn(thisform.hwnd, ;
SetWindowRgn(thisform.hwnd, ;
CreateRectRgn(1,1,100,100), "True")
SQUARE SHAPE WITH CURVED END
Declare Long CreateRoundRectRgn IN WIN32API Long X1, Long Y1, ;
Long X2, Long Y2, Long X3, Long Y3
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, ;
Declare Long SetWindowRgn IN WIN32API Long hWnd, Long hRgn, ;
String bRedraw
SetWindowRgn(thisform.hwnd, ;
SetWindowRgn(thisform.hwnd, ;
CreateRoundRectRgn(1,1,100,100,50,50), "True")
In Visual FoxPro even not only form that can be changed in shape, window editor of Visual FoxPro can be chenged too. Just follwo and run the syntax above in the Command Window and change the syntax section thisform.hwnd to _vfp.hwnd . whereas if you want to create a form with other shape ( not only round ) , can use the following scenario :
- Prepare an image with a certain shape , which will be used as shape of a form.
- Add image controls to the form , and navigate property picture to the picture.
- Change the BackColor property of the form to different color from the color images for example red (255.0.0)
- Add the syntax below in INIT form :
DECLARE INTEGER SetLayeredWindowAttributes IN WIN32API ;
INTEGER HWND, INTEGER crKey, ;
INTEGER bAlpha, INTEGER dwFlags
DECLARE INTEGER SetWindowLong IN user32.DLL INTEGER hWnd, ;
INTEGER
nIndex, INTEGER dwNewLong DECLARE INTEGER GetWindowLong IN user32.DLL
INTEGER hWnd, INTEGER nIndex lnFlags = GetWindowLong(thisform.hwnd,
-20)
lnFlags
= BITOR(lnFlags, 0x00080000) SetWindowLong(thisform.hwnd, -20,
lnFlags) SetLayeredWindowAttributes(thisform.hwnd, ;
RGB(255,0,0), 0, 1)
Make sure the numbers 255,0,0 in syntax and BackColor is the same 5 .
- Set property titlebar in the form to 0 - off , BordeyStyle property to 0 - No Border , and do not forget if you want to keep ShowWindow property value 0 / 1 then change the Desktop property becomes .T . , Or otherwise change any ShowWindow property to 2 .
0 Response to "Creating Custom Shapes Form Using WINAPI"
Post a Comment