Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Toolbar - howto get rid of the anchor on the left or rig
Message
From
30/04/2004 04:18:49
Dorin Vasilescu
ALL Trans Romania
Arad, Romania
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00899615
Message ID:
00899630
Views:
22
Yes
Dock the toolbar on any side to see
The ClearToolbarMover function is called in Paint event

>Could you send me an example how to do that?
PUBLIC oToolbar
oToolbar = CREATEOBJECT('mytoolbar')
oToolbar.show


DEFINE CLASS mytoolbar AS toolbar


	Caption = "Test toolbar"
	Height = 28
	Left = 0
	Top = 0
	Width = 99
	Name = "mytoolbar"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 3, ;
		Left = 5, ;
		Height = 22, ;
		Width = 23, ;
		Caption = "", ;
		Name = "Command1"


	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 3, ;
		Left = 27, ;
		Height = 22, ;
		Width = 23, ;
		Caption = "", ;
		Name = "Command2"


	ADD OBJECT command3 AS commandbutton WITH ;
		Top = 3, ;
		Left = 49, ;
		Height = 22, ;
		Width = 23, ;
		Caption = "", ;
		Name = "Command3"


	ADD OBJECT command4 AS commandbutton WITH ;
		Top = 3, ;
		Left = 71, ;
		Height = 22, ;
		Width = 23, ;
		Caption = "", ;
		Name = "Command4"


	PROCEDURE Paint
		cleartoolbarmover(this, _vfp.hWnd)
	ENDPROC


ENDDEFINE



procedure ClearToolbarMover
LPARAMETERS toToolbarRef, tnParenthWnd
*toToolbarRef		toolbar reference
*tnParentWHnd		_VFP or top level form whnd property
IF toToolbarRef.DockPosition = -1		
	RETURN
ENDIF
LOCAL i,j
DeclareAPI()
lnToolbarHwnd = GetToolbarHwnd(toToolbarRef, tnParenthWnd)	&&get toolbar hWnd
thDC = GetWindowDC(lnToolbarHwnd)							&&get toolbar DC
DO case
CASE INLIST(toToolbarRef.DockPosition,0,3)
	FOR i=2 TO 6
		FOR j=2 TO toToolbarRef.height - 4
			setpixel(thDC,i,j,toToolbarRef.backcolor)
		NEXT
	NEXT
CASE INLIST(toToolbarRef.DockPosition,1,2)
	FOR i=2 TO toToolbarRef.width - 4
		FOR j=2 TO 6
			setpixel(thDC,i,j,toToolbarRef.backcolor)
		NEXT
	NEXT
ENDCASE
ReleaseDC(thDC,lnToolbarHwnd)
CLEAR DLLS "GetWindow","GetWindowText","GetWindowDC","SetPixel","ReleaseDC"
RETURN


PROCEDURE GetToolbarHwnd
PARAMETERS toToolbarRef, tnParenthWnd
lcToolbarCaption = toToolbarRef.Caption
IF VARTYPE(tnParenthWnd) = 'L'
	lnVFPHnd = _VFP.hWnd 
ELSE
	lnVFPHnd = tnParenthWnd 
ENDIF
lnToolbarWhnd = 0
GetWindows(lnVFPHnd, 0,0)
RETURN lnToolbarWhnd


PROCEDURE GetWindows
LPARAMETERS lnHandle,lnParent,lnLevel
#DEFINE GW_HWNDNEXT   2 
#DEFINE GW_CHILD      5 
LOCAL WinCaption, hWindow, hParent, lvl
LOCAL hChild, oChild, hNext, oNext 
WinCaption = ''
hWindow = 0
hParent = 0
lvl = 0
IF lnHandle = 0 
	RETURN .F. 
ENDIF 
lvl = lnLevel 
hWindow = lnHandle 
hParent = lnParent 
WinCaption = GetWinText(lnHandle)
IF TRIM(WinCaption) = TRIM(lcToolbarCaption)
   	lnToolbarWhnd = hWindow
endif
hChild = GetWindow(hWindow, GW_CHILD) 
oChild = GetWindows( hChild, hWindow, lvl+1)
IF lnParent <> 0 
    hNext = GetWindow(hWindow, GW_HWNDNEXT) 
    oNext = GetWindows(hNext, hParent, lvl) 
ENDIF 


FUNCTION  GetWinText(hWindow) 
    LOCAL lcBuffer, lnResult 
    lcBuffer = Space(250) 
    lnResult = GetWindowText(hWindow, @lcBuffer, Len(lcBuffer)) 
RETURN Left(lcBuffer, lnResult) 



FUNCTION DeclareAPI
DECLARE INTEGER GetWindow IN user32 INTEGER hwnd, INTEGER wFlag 
DECLARE INTEGER GetWindowText IN user32; 
	INTEGER hwnd, STRING @lpString, INTEGER cch 
DECLARE INTEGER SetPixel IN gdi32 integer hDc, INTEGER x, INTEGER y, INTEGER nColor
DECLARE INTEGER GetWindowDC IN user32 INTEGER hwnd 
DECLARE INTEGER ReleaseDC IN user32 INTEGER hwnd, INTEGER hdc 
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform