Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form - resize rubber band
Message
From
21/09/2004 23:09:26
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00944495
Message ID:
00944843
Views:
28
This message has been marked as a message which has helped to the initial question of the thread.
>Herman,
>
>>How about drawing a rectangle (Rectangle() API) on MouseDown, continue drawing
>>it on MouseMove. Then do the actual resize on MouseUp. I think it looks good enough
>
>Yes, that's what I think needs to be done. That's why I posted it here under "API".
>
>Uppon Startup I would need to draw the dotted line around and on top of the current form. keeping the mouse-Offset, I will than have to extend this with the mousemove and when having the mouseUp getting the new coordinates, resize my form and do the removing and cleanup of the rubber.
>
>Unfortunately I havn't done too much window-drawing-stuff with the API, and thought someone could give me a hand on that ;-)


Sorry Frank, my bad :-(
Here is the example to draw the rectangle on the border:
#Define BOOL       long
#Define HANDLE     long
#Define PSTR       String @
#Define PRECT      String @

#Define R2_NOTXORPEN   10
#Define HWND_DESKTOP    0
#Define NULL_BRUSH      5

Declare BOOL Rectangle in GDI32 ;
	HANDLE hDC, Integer nLeftRect, Integer nTopRect, ;
	Integer nRightRect,  Integer nBottomRect  

Declare BOOL GetWindowRect in User32 HANDLE nhWnd, PRECT lpRect
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
Declare BOOL ClientToScreen in User32 HANDLE nhWnd, PSTR cPoint
Declare Integer SetROP2 in GDI32 HANDLE hDC, Integer fnDrawMode
Declare HANDLE GetStockObject in GDI32 Integer fnObject

Local lh_DC, lh_OldBrush, lh_OldPen
Local lc_Rect, ln_Left, ln_Top, ln_Right, ln_Bottom

lc_Rect = space( 16 )
GetWindowRect( ThisForm.hWnd, @lc_Rect )

** 1st coordinate
lc_Point = left( lc_Rect, 8 )
ClientToScreen( HWND_DESKTOP, @lc_Point )
ln_Left = Buff2Num( lc_Point, (4*0)+1, .F. )
ln_Top = Buff2Num( lc_Point, (4*1)+1, .F. )

** 2nd coordinate
lc_Point = right( lc_Rect, 8 )
ClientToScreen( HWND_DESKTOP, @lc_Point )
ln_Right = Buff2Num( lc_Point, (4*0)+1, .F. ) - 1
ln_Bottom = Buff2Num( lc_Point, (4*1)+1, .F. ) - 1

** Draw to the DC
lh_DC = GetDC( HWND_DESKTOP )
lh_OldBrush = SelectObject( lh_DC, GetStockObject(NULL_BRUSH) )
SetROP2( lh_DC, R2_NOTXORPEN )
Rectangle( lh_DC, ln_Left, ln_Top, ln_Right, ln_Bottom )
SelectObject( lh_DC, lh_OldBrush )
ReleaseDC( HWND_DESKTOP, lh_DC )
Regards
Herman
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform