>PROCEDURE DrawPatternedRubber >*-- This will draw a patterned rubber around a given area in >*-- order to mimic Window's resizing - optic > >#Define BOOL long >#Define HANDLE long >#Define PSTR String @ >#Define PRECT String @ >#Define UINT Long >#Define PATINVERT 0x005A0049 > >#Define HWND_DESKTOP 0 > >lparameters tnTop, tnLeft, tnBottom, tnRight >tnTop = iif(vartype(tnTop) = "N", tnTop, this.nTop) >tnLeft = iif(vartype(tnLeft) = "N", tnLeft, this.nLeft) >tnBottom = iif(vartype(tnBottom) = "N", tnBottom, this.nBottom) >tnRight = iif(vartype(tnRight) = "N", tnRight, this.nRight) > >LOCAL lnWidth, lnHeight, rgbPatGray, hBitmap, hPatBrush > >*-- Declaration of the necessary Windows-Functions >*-- Later put aside >Declare BOOL DeleteObject in GDI32 HANDLE hDC >Declare BOOL PatBlt in GDI32 HANDLE hDC, Integer nXLeft, ; > Integer nYLeft, Integer nWidth, integer nHeight, ; > INTEGER dwRop >*-- dwRop should be a DWORD but as PATINVERT is numeric >*-- already, Integer does the trick > >Declare HANDLE CreateBitmap in GDI32 ; > Integer nWidth, Integer nHeight, ; > UINT cPlanes, UINT cBitsPerPel, PSTR lpvBits >Declare HANDLE CreatePatternBrush in GDI32 HANDLE hBitmap >Declare HANDLE GetDC in User32 HANDLE nhWnd >Declare HANDLE SelectObject in GDI32 HANDLE hDC, HANDLE hObject >Declare Integer ReleaseDC in User32 HANDLE nhWnd, HANDLE hDC > >*-- Erstellen eines Bitmap-Brush mit dem gescheckten >*-- Muster für das Zeichnen des Randes >rgbPatGray = replicate( Word(0x55) + Word(0xAA), 4 ) >hBitmap = CreateBitmap( 8, 8, 1, 1, rgbPatGray ) >hPatBrush = CreatePatternBrush( hBitmap ) > >*-- Ermitteln des Rechtecks zum Zeichnen des Rahmens >*-- Buff2Num ist eine Funktion in WordProcs.prg. Es >*-- geht aber auch meine Funktion String2Long(), dann >*-- mit einem Aufruf substr(cRect,5,4) etc. > >*-- Getting the Recangle of the form is done in a >*-- separate method now >*-- cRect = space( 16 ) >*-- GetWindowRect( ThisForm.hWnd, @cRect ) >*-- nLeft = Buff2Num( cRect, (4*0)+1, .F. ) >*-- nTop = Buff2Num( cRect, (4*1)+1, .F. ) >*-- nRight = Buff2Num( cRect, (4*2)+1, .F. ) >*-- nBottom = Buff2Num( cRect, (4*3)+1, .F. ) > >*-- calculate Width and height for better >*-- handling >lnWidth = tnRight - tnLeft >lnHeight = tnBottom - tnTop > >*-- Width and height of a sizable window-frame >lnXFrame = SysMetric(3) >lnYFrame = SysMetric(4) > >hDC = GetDC( HWND_DESKTOP ) >hOldBrush = SelectObject( hDC, hPatBrush ) > >*-- Drawing each of the four borders but without >*-- overlapping the thick lines at the edges, as this >*-- would invert them at the corners >PatBlt( hDC, tnLeft, tnTop, lnWidth, lnYFrame, PATINVERT ) && top side >PatBlt( hDC, tnLeft, tnTop+lnYFrame, lnXFrame, lnHeight-(2*lnYFrame), PATINVERT ) && left side >PatBlt( hDC, tnLeft, tnBottom-lnYFrame, lnWidth, lnYFrame, PATINVERT) && bottom side >PatBlt( hDC, tnRight-lnXFrame, tnTop+lnYFrame, lnXFrame ,lnHeight-(2*lnYFrame), PATINVERT) && right side > >*-- reset the brush >SelectObject( hDC, hOldBrush ) > >ReleaseDC( HWND_DESKTOP, hDC ) > >*-- and Delete the brush and bitmap >DeleteObject(hPatBrush) >DeleteObject(hBitmap) > >*-- Finally keep the lower right corner >*-- for later. Needed to remove the frame >this.nOldBottom = tnBottom >this.nOldRight = tnRight>
nLeft = Buff2Num( cRect, (4*0)+1, .F. )The rectangle value actually is a type of LONG . But I use WORD conversion instead, because I think windows rectangle will never reach the highest WORD value (0xFFFF). So it's up to you which one you want to use.