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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Odd behaviour forms Moved method

Status
Not open for further replies.

JackTheC

Programmer
Feb 25, 2002
324
NL
I noticed some odd behaviour with the forms moved method that I can't explain.

When I minimize a form with the MinButton I want VFP to go to the taskbar, not above the taskbar, with the instruction
_screen.windowstate=thisform.windowstate in the Resize method. That works fine.

But when I put a command, any command, in the forms Moved method and I click on the taskbar to go back to Normal windowstate the objects (labels, textboxes etc.) on the form are invisible. The form is blank. A Refresh method repaints only some objects but not the labels.

When I comment out the Moved method or the _screen.windowstate command in the Resize method the objects stay visible. So for some reason the combination of the _screen.windowstate and the Moved method is causing this problem. Why?

Example form for testing:

Code:
PUBLIC oform1

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

	**************************************************
*-- Form:         form1 
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   02/26/21 01:26:05 PM
*
DEFINE CLASS form1 AS form
	Height = 214
	Width = 426
	Desktop = .T.
	DoCreate = .T.
	Caption = "Form1"
	WindowType = 1
	Name = "Form1"

	ADD OBJECT label1 AS label WITH ;
		Caption = "Label1", ;
		Height = 25, ;
		Left = 24, ;
		Top = 24, ;
		Width = 97, ;
		Name = "Label1"

	ADD OBJECT label2 AS label WITH ;
		Caption = "Label2", ;
		Height = 25, ;
		Left = 24, ;
		Top = 48, ;
		Width = 97, ;
		Name = "Label2"

	ADD OBJECT text1 AS textbox WITH ;
		Height = 25, ;
		Left = 156, ;
		Top = 24, ;
		Width = 85, ;
		Name = "Text1"

	ADD OBJECT text2 AS textbox WITH ;
		Height = 25, ;
		Left = 156, ;
		Top = 48, ;
		Width = 85, ;
		Name = "Text2"

	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 96, ;
		Left = 156, ;
		Height = 37, ;
		Width = 85, ;
		Caption = "OK", ;
		Name = "Command2"

	PROCEDURE Moved
		a=1  && just some code
	ENDPROC

	PROCEDURE Resize
		_screen.windowstate=thisform.windowstate

		* thisform.refresh  repaints only the textboxes not the labels.
	ENDPROC

	PROCEDURE Unload
		_screen.visible=.t.
	ENDPROC

	PROCEDURE Load
		_screen.visible=.f.
	ENDPROC

ENDDEFINE
*
*-- EndDefine: form1
 
Comment out a=1 in the move method, It seems to be the issue.



If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I knew that. But why? A=1 is just a simple example. Any command, any line of code in the Moved method causes this issue.
 
Could if be a recursive thing, the move calls move, calls move, calls move, until there is no stack left?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Let me get this right. You say you want to fix it so that, when you minimise the form using its Minimize button, you want the whole of the VFP main window to be minimised. I've never seen a form behave that way before. But I accept you have a good reason for wanting to do it.

Have you considered simply making this a top-level form - by setting its ShowWindow to 2? I've just tried doing that, and it seems to work much better. I also set the WindowType to 0, to make the form modeless.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
@Griff, that was my first thought too. So I logged to a txt file each time the Move and Resize methods were called.
Result: Move and Resize both one time when minimized and both one time when maximized again. So no recursive calls.

By the way: The command button is also invisible and it becomes visible when you hover the mouse over the location you guess it must be.

@Mike: No I solved it in the real app by not using the Moved method but another method. I was just wondering about this strange behaviour. And it's not simply ShowWindow=2 for me, other strange things happen then and I couldn't resolve those yet. I nearly always work with modal forms.
Did you mean you never saw "_screen.windowstate=thisform.windowstate" before? I've been using this since VFP3 in 1997 to minimize to the taskbar instead of the default location just above the taskbar and never had problems with that. Probably didn't use the Moved method before...



 
FWIW, I've never seen anyone use _screen.windowstate=thisform.windowstate before. I'd be pretty surprised in any application that minimizing one form minimizes the whole application. The only case I can imagine wanting that is when the form I'm minimizing is a top-level window.

Tamar
 
Jack, like Tamar, I have never seen "_screen.windowstate=thisform.windowstate" before. But what I actually meant was that I had never seen a situation where minimising one form caused the whole outer window to become minimised. I don't really understand what effect you are trying to achieve here. That was why I was wondering if what you really need is a top-level form (but that wouldn't work if the form was modal).

When I was experimenting with your code, I found that the best result happened after I removed the .Desktop setting and after I made the form modeless.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The thing where the command button doesn't "exist" until you hover the mouse above it, sounds like the old programs converted from FPW where you don't use _SCREEN.Themes=.F.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top