Code: |
nomainwin open "WMLiberty" for dll as #wmlib loadbmp "skin", "bmp\skin.bmp" WindowWidth = 520 WindowHeight = 400 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) open "Skinned Window" for window_nf as #skin #skin "trapclose [QUIT]" callback lpfn, OnPaint ( ulong, ulong, ulong, ulong ), long hwndSkin = hwnd(#skin) calldll #wmlib, "SetWMHandler", _ hwndSkin as ulong, _ _WM_PAINT as ulong, _ lpfn as ulong, _ 0 as long, _ ret as long #skin "hide" #skin "show" [LOOP] scan calldll #kernel32, "Sleep", _ 'Minimize CPU usage 50 as long, _ ret as void goto [LOOP] [QUIT] close #skin close #wmlib end function OnPaint(hwnd, uMsg, wParam, lParam) hdc = GetDC(hwnd) dcSkin = CreateCompatibleDC(hdc) r = SelectObject(dcSkin, hbmp("skin")) r = BitBlt(hdc, 0,0,520,400, dcSkin, 0, 0, _SRCCOPY) r = DeleteDC(dcSkin) r = ReleaseDC(hwnd, hdc) r = DeleteObject(hbmp("skin")) end function function GetDC(h) calldll #user32, "GetDC",_ h as ulong,_ 'graphicbox handle GetDC as ulong 'returns handle to device context end function function ReleaseDC(h, hdc) calldll #user32, "ReleaseDC",_ h as ulong,_ 'window handle hdc as ulong,_ 'device context ReleaseDC as long end function function DeleteDC(hDCM) calldll #gdi32, "DeleteDC", _ hDCM as ulong, _ DeleteDC as long end function function CreateCompatibleDC(hDC) calldll #gdi32, "CreateCompatibleDC", _ hDC as ulong, _ 'current screen CreateCompatibleDC as ulong 'handle of memory DC end function function SelectObject(hDC,hImage) calldll #gdi32, "SelectObject", _ hDC as ulong, _ hImage as ulong, _ SelectObject as ulong end function function DeleteObject(memBmp) calldll #gdi32, "DeleteObject", _ memBmp as ulong, _ DeleteObject as long end function function BitBlt(hDCdest, xDest, yDest, xWidth, yHeight, hDCsource, xSrc, ySrc, ROP) CallDll #gdi32, "BitBlt", _ hDCdest as ulong,_ 'The destination DC xDest as long,_ 'x location on destination yDest as long,_ 'y location on destination xWidth as long,_ 'width to transfer yHeight as long,_ 'height to transfer hDCsource as ulong,_ 'The source DC xSrc as long,_ 'x location in source ySrc as long,_ 'y location in source ROP as ulong,_ 'The operation to be performed BitBlt as long 'nonzero if successful end function |
Here is a link to download the image: skin.bmp