Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing a pageframe based on tab orientation

Status
Not open for further replies.

awaresoft

Programmer
Feb 16, 2002
373
DE
I would like to offer my users the ability to change the orientation of their pageframe tabs between horizontal and vertical settings.

When tab orientation changes, it appears to me that I need to BOTH resize my pageframe AND adjust its vertical position so that the pageframe appears to stay in the same position on the form.

This looks like a pretty complicated effort. Is there a simple way to do this?

In sketching out a plan, it appears that I need to be able to figure out the height of the page frame tabs in order to accomplish my goal.

Feeback appreciated,
Malcolm
 
Malcolm,

I'm assuming that you mean that the user can have the tabs either on the top edge or the left edge of the frame?

I just did an experiment where I had a pageframe and a line which I aligned with the top of the pageframe.

I then had a command group which changed the TabOrientation property of the pageframe and the frame stayed in exactly the same place while the tabs moved around the 4 edges.

What effects are you experiencing?


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Malcom,

Presumably you want to move the top of the pageframe upward to compensate for the lack of tabs along the top edge. So, you need to decrease the Top property by x pixels, where x is the height of the tabs.

I can't see any generic way of determining x. I wonder if it's resolution-independent, or if it depends on the font size specified on the Appearance page in Screen Properties in Control Panel. Maybe you could experiment with different settings to see if you can determine that figure.

Sorry, this is not much help. Let us know if you come up with an answer.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
One approach that I have used to achieve something like this is somewhat simplistic, but it worked.

I designed the Form with 2 separate Pageframes on it.
One Pageframe over-laid the other.

I then had to put the desired associated objects into each tab on both of the Pageframes (a tedious effort).

Then I had the Form Enable and make Visible the desired Pageframe and its associated Tab "pages" based on whatever criteria I needed to use (user settings, input criteria, etc.).

In that way, the orientation, size, position, etc. of each Pageframe does not need to be dynamic. Instead each was set before-hand and merely made available to the user when desired.

Good Luck,
JRB-Bldr
 
Wow - thanks for everyone's feedback!

StewartUK: I'm curious how you have configured your pageframe to not visually shift around when changing page orientation. I think everyone else on this thread is seeing this behavior except you. Or perhaps my description of the problem is lacking. I'll work on a better writeup and repost shortly

MikeLewis: Your general approach (shifting up and resizing) is the approach I want to take. Right now I'm trying to reverse engineer VFP's behavior to figure out how I can calculate the visual changes a pageframe undergoes when tab orientatation changes. Most of my forms are resizable so I will need an accurate formula for calculating the visual appearance of pageframes.

Jrbbldr: Clever idea using two pageframes! I'm going to try to avoid this solution as my pageframes are rather complex and because I want my pageframes to resize in response to changes in the size of its parent form.

Any other suggestions, formulas, or magic constants that I should be using in my calculations?

Thanks,
Malcolm
 
Malcolm;

You never said what version of FoxPro you are using.
Starting with VFP 8 there is a pageframe property called TabOrientation. I believe that is the version that StewartUK is using. I also created a test form and the page frame stays put.

Code:
*!* VFP 8 code

DEFINE CLASS form1 AS form


	Top = 9
	Left = 13
	Height = 388
	Width = 585
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT pageframe1 AS pageframe WITH ;
		ErasePage = .T., ;
		PageCount = 3, ;
		Top = 96, ;
		Left = 94, ;
		Width = 396, ;
		Height = 169, ;
		Name = "Pageframe1", ;
		Page1.Caption = "Page1", ;
		Page1.Name = "Page1", ;
		Page2.Caption = "Page2", ;
		Page2.Name = "Page2", ;
		Page3.Caption = "Page3", ;
		Page3.Name = "Page3"


	ADD OBJECT commandgroup1 AS commandgroup WITH ;
		ButtonCount = 4, ;
		Value = 1, ;
		Height = 37, ;
		Left = 109, ;
		Top = 288, ;
		Width = 367, ;
		Name = "Commandgroup1", ;
		Command1.Top = 5, ;
		Command1.Left = 5, ;
		Command1.Height = 27, ;
		Command1.Width = 84, ;
		Command1.Caption = "Top", ;
		Command1.Name = "Command1", ;
		Command2.Top = 5, ;
		Command2.Left = 96, ;
		Command2.Height = 27, ;
		Command2.Width = 84, ;
		Command2.Caption = "Bottom", ;
		Command2.Name = "Command2", ;
		Command3.Top = 5, ;
		Command3.Left = 187, ;
		Command3.Height = 27, ;
		Command3.Width = 84, ;
		Command3.Caption = "Left", ;
		Command3.Name = "Command3", ;
		Command4.Top = 5, ;
		Command4.Left = 278, ;
		Command4.Height = 27, ;
		Command4.Width = 84, ;
		Command4.Caption = "Right", ;
		Command4.Name = "Command4"


	PROCEDURE commandgroup1.Command1.Click
		THISFORM.pageframe1.TABORIENTATION = 0
	ENDPROC


	PROCEDURE commandgroup1.Command2.Click
		THISFORM.pageframe1.TABORIENTATION = 1
	ENDPROC


	PROCEDURE commandgroup1.Command3.Click
		THISFORM.pageframe1.TABORIENTATION = 2
	ENDPROC


	PROCEDURE commandgroup1.Command4.Click
		THISFORM.pageframe1.TABORIENTATION = 3
	ENDPROC


ENDDEFINE

Ed

Please let me know if the suggestion(s) I provide are helpful to you.
Sometimes you're the windshield... Sometimes you're the bug.
smallbug.gif
 
Malcolm,

As you say...curious. I made another test form using the default VFP form and pageframe objects and the pageframe still stays in one place.

I should perhaps ask what version of VFP you're using?

From your description, it sounds like the effect you get is that when the tabs are moved from the top to the side, the pageframe gets shorter (the top edge moving down so that the top is level with what was the bottom edge of the tabs) and wider (with the tabs sticking out beyond where the left edge of the pageframe was). Is that correct?

Stewart
 
With many thanks to Fabio Lunardon on the UT, listed below is an example SOLUTION that illustrates how to resize and move pageframes in response to changes to a pageframe's TabOrientation property.

This solution was posted in UT thread:

Fabio's solution makes great use of the OBJTOCLIENT() function. No messy constants. Very clean. This is the first time I've used OBJTOCLIENT() and I think this function may make alot of other VFP GUI related challenges possible.

Code:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form


	Autocenter = .T.

	ADD OBJECT optiongroup1 AS optiongroup WITH ;
		AutoSize = .T., ;
		ButtonCount = 4, ;
		Value = 1, ;
		Height = 84, ;
		Left = 12, ;
		Top = 76, ;
		Width = 71,;
		Option1.Caption = "Top", ;
		Option1.Height = 17, ;
		Option1.Left = 5, ;
		Option1.Top = 5, ;
		Option1.Width = 61, ;
		Option1.Name = "Option1", ;
		Option2.Caption = "Bottom", ;
		Option2.Height = 17, ;
		Option2.Left = 5, ;
		Option2.Top = 24, ;
		Option2.Width = 61, ;
		Option2.Name = "Option2", ;
		Option3.Caption = "Left", ;
		Option3.Height = 17, ;
		Option3.Left = 5, ;
		Option3.Top = 43, ;
		Option3.Width = 61, ;
		Option3.Name = "Option3", ;
		Option4.Caption = "Right", ;
		Option4.Height = 17, ;
		Option4.Left = 5, ;
		Option4.Top = 62, ;
		Option4.Width = 61, ;
		Option4.Name = "Option4"

	ADD OBJECT check1 AS checkbox WITH ;
		Top = 4, ;
		Left = 12, ;
		AutoSize = .T., ;
		Caption = "TabStyle"

	ADD OBJECT check2 AS checkbox WITH ;
		Top = 24, ;
		Left = 12, ;
		AutoSize = .T., ;
		Caption = "TabStretch"

	ADD OBJECT check3 AS checkbox WITH ;
		Top = 44, ;
		Left = 12, ;
		AutoSize = .T., ;
		Caption = "ResizeMovePages"

	ADD OBJECT pf AS myPageFrame  WITH ;
		PageCount = 6, ;
		Top = 50, ;
		Left = 130, ;
		Height = 150,;
		Width  = 150

	PROCEDURE Init
		WITH thisform.pf.Pages[1]
			.AddObject("text1",[textbox])
			.text1.Visible = .text1.Move(51,36,80)
		ENDWITH
		this.Check1.ControlSource = "thisform.pf.TabStyle"
		this.Check2.ControlSource = "thisform.pf.TabStretch"
		this.Check3.ControlSource = "thisform.pf.ResizeMovePages"

	PROCEDURE optiongroup1.Refresh
		this.Value=thisform.pf.TabOrientation+1
	ENDPROC


	PROCEDURE optiongroup1.Valid
		thisform.pf.TabOrientation=this.Value-1
	ENDPROC


ENDDEFINE

DEFINE CLASS myPageFrame AS pageframe

	ResizeMovePages = .T.

	HIDDEN PROCEDURE TabOrientation_assign
		LPARAMETERS tabOrientation
		IF m.this.ResizeMovePages OR EMPTY(m.this.PageCount)
			THIS.TabOrientation = m.tabOrientation
		ELSE
			PRIVATE left,top
			STORE m.this.Top	+ OBJTOCLIENT(this.Pages[1],1) TO top
			STORE m.this.Left	+ OBJTOCLIENT(this.Pages[1],2) TO left
			THIS.TabOrientation = m.tabOrientation
			this.Move(	m.Left	-OBJTOCLIENT(this.Pages[1],2);
				,		m.Top	-OBJTOCLIENT(this.Pages[1],1))
		ENDIF
	ENDPROC


	HIDDEN PROCEDURE TabStretch_Assign
		LPARAMETERS tabStretch
		IF m.this.ResizeMovePages OR EMPTY(m.this.PageCount)
			THIS.TabStretch = m.tabStretch
		ELSE
			PRIVATE left,top
			STORE m.this.Top	+ OBJTOCLIENT(this.Pages[1],1) TO top
			STORE m.this.Left	+ OBJTOCLIENT(this.Pages[1],2) TO left
			THIS.TabStretch = m.tabStretch
			this.Move(	m.Left	-OBJTOCLIENT(this.Pages[1],2);
				,		m.Top	-OBJTOCLIENT(this.Pages[1],1))
		ENDIF
	ENDPROC


ENDDEFINE
 
Stuart and Ed,

Very strange - just re-dropped a default pageframe on a blank form and now I'm seeing the same thing you guys are. Now I'm really confused!

I'm going to drink another pot of coffee and see if that helps :)

Malcolm
 
Stuart and Ed,

BTW: I'm using VFP 8, SP 1 on XP with Themes enabled. 1024x768, 16M color resolution, small font mode. Standard taskbar setup, etc. Pretty generic setup.

Malcolm
 
Malcolm;

Coffee wont help. Take a look at the clock, I'll bet it's "Beer-Thirty". [smile]


Ed

Please let me know if the suggestion(s) I provide are helpful to you.
Sometimes you're the windshield... Sometimes you're the bug.
smallbug.gif
 
Ed,

LOL! Its been beer-thirty since I woke up this morning. Just one of those days ... (per your signature - I'm the bug today)

Thanks for the laugh,

Malcolm

 
Malcom,

... with Themes enabled

I wonder what difference it would make if you disabled Themes. I've sometimes found that solves all kinds of UI problems.

Re OBJTOCLIENT(). Thanks (and to Fabio) for reminding me about this function, which I can find lots of uses for. However, it doesn't tell you anything you couldn't find -- with a little effort -- by other means. Essentially, you could drill up through the containership hierarchy to get the same values.

One other thought. How about doing away with the tabs completely. Instead, provide some other control to switch from one page to another. Maybe a set of buttons or even labels. With care, you could simulate two sets of tabs -- one horizontal and one vertical -- and place them at the appropriate edge of the frame. That way, when the user decides to switch orientation, the actual pageframe stays in the same place.

Just a thought.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi Mike,

> How about doing away with the tabs completely

Funny you should mention that. In an ideal world, what I would like to build is a set of tab control classes that mimic the look and feel of MS's OneNote product, ie. colorful, gradient based "real notebook" looking tabs that one can insert, delete, drag&drop reposition, scroll when there are too many, and custom color with on-the-fly gradients based on a starting color point. Oh yeah, and supporting all 4 tab orientations plus the ability for vertical tabs to have horizontal labels and for all tabs to have optional icons in their captions.

Have you heard of anyone implementing anything similar in the VFP world? I'm sure that this type of control could be built in VFP 9 with the new support for GDI+ and rotated captions for vertical tabs. This would be a fun project to work on!

Surprisingly I only found only one 3rd party ActiveX control that implements the MS OneNote look and feel ( and while the images on the web page look great, the product in reality is poorly implemented and contains only a small subset of the functionality I described above. And it does not work with VFP at all.

Malcolm
 
I just tested (in VFP 9) and the pageframe doesn't move. The page size and shape changes, but you can manage that with the PageHeight and PageWidth properties.

Tamar
 
Hi Tamar,

It appears that several of us - on TekTips, UT, and Profox had mysteriously morphying Pageframes which now - even more mysteriously - I can not duplicate.

A valuable outcome of this post was learning how the OBJTOCLIENT() function can be used.

Any comments on building OneNote type tabs in VFP? Have you seen or heard of anytyhing like this in VFP over the course of your travels?

Malcolm
 
Malcom,

I'm not familiar with OneNote, but you might want to peruse the DBI site ( They make some interesting ActiveX controls which provide various tabs, toolbars and button bars.

But, to get back to your current situation ... I would have thought it would be fairly easy to create a VFP class that would mimic horizontal and vertical tabs to control your pageframe. You can always add the gradients and similar stuff later.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Hi Mike,

I already own several DBI products and have had good success using these components with VFP. Unfortunately, most of my current customers mandate solutions that can be installed on locked down workstations without admin/poweruser rights. This means most of my current my applications can not use ActiveX/COM components.

I agree that VFP has the tools to build whatever type of tab control I can imagine - especially with VFP 9's vertical labels and GDI+ support.

If you have a chance, Microsoft's OneNote product is worth taking a look at (if only via their website promotional materials) because of its friendly user interface and cool looking tab controls. While the product itself has gotten luke warm reviews, there's a lot of cool user interface ideas introduced in this product that may have applicability for other projects.

Malcolm
 
I've seen a demo of OneNote, but it was a long time ago and I don't remember the particulars. Sorry.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top