Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Resizing Docked Form's Height Programmatically
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01017705
Message ID:
01018145
Views:
307
Craig!

WOW! You've got my attention now! Now that's what I call cool! :)

I made some small tweaks to your code: positioned the toolbar, added a container to the toolbar, updated your exit button code to reflect containership, etc.

My constants are based on 1024x768 display. Here's the code I'm using to describe my experience with your post.
PUBLIC goToolbar
goToolbar = CREATEOBJECT("BorderlessToolbar")
goToolbar.Show()

DEFINE CLASS BorderlessToolbar as Toolbar

	Top  = -24  && hide top margin
	Left = -10  && hide left and right margin

	* my init
	PROCEDURE Init()
		* add main container which we use to control size and visual presentation (borders, picture, etc)
		this.AddObject( "cntMain", "Container" )
		with This.cntMain
			.Height = 30

			* force main container to stretch width of display
			.Width = 1026 && screenwidth + 2

			* ugly color scheme so container stands out
			.BorderColor = 255
			.Backcolor = rgb( 224, 255, 255 ) 
		
			* add exit button
			.AddObject("btnExit", "Exitbutton")
			.btnExit.Move( 3, 4, 80, 22 )
			.btnExit.Visible = .T.
			
			.Visible = .T.
		endwith
		
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		IF DODEFAULT(nStyle)
			this.Resize()
		ENDIF
	ENDPROC

	PROCEDURE Resize
		this.SetDisplayRegion(3, SYSMETRIC(9) - 5, this.Width + 3, this.Height + SYSMETRIC(9) - 4)
	ENDPROC

	PROCEDURE AfterDock
		LPARAMETERS nLocation, oForm
		this.SetDisplayRegion(0, 0, this.Width, this.Height)
	ENDPROC

	PROCEDURE Undock
		LOCAL lnDockPosition
		lnDockPosition = this.DockPosition
		IF INLIST(lnDockPosition, 0, 3)
			this.SetDisplayRegion(3, SYSMETRIC(9) - 5, this.Width - 5, this.Height+ SYSMETRIC(9) - 5)
		ELSE
			this.SetDisplayRegion(3, SYSMETRIC(9), this.Width + 1, this.Height + SYSMETRIC(9) - 13)
		ENDIF
	ENDPROC

	PROCEDURE SetDisplayRegion(tnX1, tnY1, tnX2, tnY2)
		DECLARE INTEGER DeleteObject IN gdi32 INTEGER hObject
		DECLARE INTEGER CreateRectRgn IN gdi32;
			INTEGER X1, INTEGER Y1, INTEGER X2, INTEGER Y2
		DECLARE INTEGER SetWindowRgn IN user32 ;
			INTEGER HWND, INTEGER hRgn , INTEGER bRedraw
		RegiondeLinea = CreateRectRgn(tnX1, tnY1, tnX2, tnY2)
		SetWindowRgn(This.Hwnd, RegiondeLinea, 1)
		DeleteObject(RegiondeLinea)
	ENDPROC

ENDDEFINE

DEFINE CLASS ExitButton as CommandButton
	Caption = "Exit Toolbar"
	
	FontSize = 8
	
	* updated to reflect parent container
	PROCEDURE Click
		this.Parent.Parent.Release()
	ENDPROC
ENDDEFINE
The only thing I can't figure out how to do is get rid of the toolbar's margins. In the example above, I cheated by hiding the top, left and right margins outside the visible area of the display. But I still have that damn bottom margin. I tried fiddling with your SetDisplayRegion code, but failed to have any luck.

IMO, its critical to eliminate the toolbar margins (the area between the toolbar border and its child controls) to prevent users from repositioning toolbars and for esthetic reasons so that a developer has full control over the presentation appearance of your toolbar containers.

I ran a bunch of ad-hoc tests with resizing _Screen and your toolbar control responded as expected, including moving up and down as the _Screen width became narrow enough to cause the menu bar to wrap to additional lines. I haven't tried your code in a TopLevel form yet.

Some observations:

1. One needs to take into consideration the real size of toolbar (with titlebar, borders, and margins) when positioning a toolbar. Its easy to forget that the physical dimensions of the toolbar haven't changed - just the visual dimensions. Did some head stratching on that one :)

2. There appears to be a single white line that gets placed between your toolbar and docked toolbars or the menubar (if no other toolbars are present). I assume that VFP inserts this type of border to differentiate between a docked and undocked toolbar. Any ideas on how we might eliminate this effect?

Craig, I am really excited by your posting. I believe a naked toolbar container could be the missing link in building the ultimate in modern user interfaces using just plain ol' VFP. With this type of widget as the foundation, I believe it possible to duplicate the look of Office 2003 toolbars (just set your container's picture property to a gradient image ... SWEET!!!, huh?) AND Office 2003 menus (based on a toolbar container of "menubar" controls?); Office 2003 taskpanes, and Explorer/Outlookbar type navigation widgets that benefit from the toolbar foundation's ability to preserve a current control's focus; ... with a naked toolbar container, the sky's the limit!

Thank you for your help and for your contributions to the VFP community!

Malcolm

PS: If you can come up with a solution to the toolbar margins, you will have to change your company name from Sweet Potato to HOT Potato! :)
Malcolm Greene
Brooks-Durham
mgreene@bdurham.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform