' Filename: SKINTEST.IBA ' Description: Demonstrates how to create irregular shaped windows and skinning with IBasic ' Date: 9-22-2002 ' Author: Tony Jones - tuesdaysgoneagain@yahoo.com ' Notes: Translated directly from C code in the article ' Win32 Window Skinning by Vander Nunes as listed at ' http://www.flipcode.com/articles/article_win32skins.shtml ' All the credit goes to the original author, all I did was convert it from C to IBasic. :-) ' To build the EXE, make sure you do the following: ' Add a resource of the type Bitmap with an ID of 100 and a Filename of skinit.bmp ' Add a resource of the type Custom with an ID of 101, a Custom Type of 256 and the ' Filename pointing to the skinit.rgn file that was included in this Zip. ' Technical Notes: ' The skinit.rgn file was created from the bitmap using the Region Creator utility ' which is also included in this package. ' To exit the program, just press ALT-F4. ' API Declarations DECLARE "user32",SetWindowRgn(hWnd:WINDOW, hRgn:INT, bRedraw:INT),INT DECLARE "gdi32",ExtCreateRegion(pXform:INT, nCount:INT, lpRgnData:MEMORY),INT DECLARE "user32",InvalidateRect(hwnd:WINDOW, lpRect:INT, bErase:INT),INT ' Constants SETID "TRUE",1 SETID "FALSE",0 SETID "IDSKIN",100 SETID "IDSKINREGION",101 SETID "WM_NCLBUTTONDOWN",&HA1 SETID "HTCAPTION",2 ' The width and height of the image we are using ' These can and should be changed to match the dimensions ' of the image you want to use. SETID "SKIN_WIDTH",283 SETID "SKIN_HEIGHT",301 ' Globals DEF Run:INT DEF Skin:INT DEF RegionWin:WINDOW DEF lpRgnData:MEMORY DEF RegionHandle:INT ' Create the main window WINDOW RegionWin,0,0,@SKIN_WIDTH,@SKIN_HEIGHT,@NOCAPTION|@NOAUTODRAW,0,"",RegionWinProc ' Center the window CENTERWINDOW RegionWin ' Load the skin image which is stored as a resource Skin = LOADIMAGE(@IDSKIN,@IMGBITMAP) ' Now load the skin region which is stored as a resource Temp = LOADRESOURCE(@IDSKINREGION,256,lpRgnData) ' Make sure the resource loaded IF Temp = 0 MESSAGEBOX RegionWin,"Load Resource Error!","Error" ENDIF ' Create the region using the region info we just loaded RegionHandle = ExtCreateRegion(0, LEN(lpRgnData), lpRgnData) ' Free up the memory we used FREEMEM lpRgnData ' Region the window RegionMe ' Run the program until we're told otherwise Run = @TRUE WAITUNTIL Run = @FALSE ' Free up the memory we used DELETEIMAGE Skin,@IMGBITMAP CLOSEWINDOW RegionWin END ' Message handler for the window SUB RegionWinProc SELECT @CLASS CASE @IDCLOSEWINDOW Run = @FALSE CASE @IDPAINT SkinMe CASE @IDLBUTTONDN ' --------------------------------------------------------- ' this is a common trick for easy dragging of the window. ' this message fools windows telling that the user is ' actually dragging the application caption bar. ' --------------------------------------------------------- SENDMESSAGE RegionWin, @WM_NCLBUTTONDOWN,@HTCAPTION,0) ENDSELECT RETURN ' Creates the regioned window SUB RegionMe ' -------------------------------------------------- ' assign the region to the window ' -------------------------------------------------- SetWindowRgn(RegionWin, RegionHandle, @TRUE) ' -------------------------------------------------- ' force a window repainting ' -------------------------------------------------- InvalidateRect(RegionWin, 0, @TRUE) RETURN ' Skins the window with the bitmap SUB SkinMe ' Show the image SHOWIMAGE RegionWin,Skin,@IMGBITMAP,0,0,@SKIN_WIDTH,@SKIN_HEIGHT RETURN