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

How to detect resize event of screen ?

Status
Not open for further replies.

viettla

Programmer
Joined
Jul 19, 2002
Messages
34
Location
VN
Hi,
I want to resize child form when screen is rezized. How can do this ?
thank's

Viet
 
If I understand your question correctly, wcgs has posted an example of this in thread184-687849.

Brian
 
Viet,

In addition to Wcgs' method, if you have VFP 8.0, you can use the new BindEvent() function to tie the screen's resize to the form's resize. For more details, see Bindevent() in the Help.

Mike


Mike Lewis
Edinburgh, Scotland
 
Thank to Brian, Mike
I found best answer from Wcgs's example.
Viet

Viet
 
viettla

If you are looking to resize a child form when _SCREEN is resized, and you don't have VFP 8,0, you need to add a resize method to _SCREEN.

Perhaps you could confirm which of the options offered so far suits?

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Mike

In the root of main.prg put

DO ScreenResizeClass

Then create a procedure :-

* *********************************
* Procedure: ScreenResizeClass
* Syntax: DO ScreenResizeClass
* *********************************
PROC ScreenResizeClass

DEFINE CLASS Resizer AS Custom
oScreen = _SCREEN

PROCEDURE oScreen.Resize
WITH _SCREEN
.LockScreen = .T.
&& Code
.LockScreen = .F.
ENDW

IF VARTYPE(oMain) = [O]
WITH oMain
.LockScreen = .T.
&& Code
.LockScreen = .F.
ENDW
ENDI

IF VARTYPE(oStatusBar) = [O]
WITH oMain
.LockScreen = .T.
&& Code
.LockScreen = .F.
ENDW
ENDI
ENDPROC
ENDDEFINE

In the .Load() event of your main form put :-

WITH _SCREEN
.AddObject([oResizer],[Resizer])
&& .AddObject([oScreenMoved],[ScreenMoved])
ENDW

As you can see, you can also add a .Moved() method which enables you to write the coordinates of _SCREEN to a table so that the app always starts in the last position.

In the .SCREEN.Resize() method, you can also write the coordinates of the child forms to a table for the same reason.

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Chris,

Thanks for that code. I should have guessed that's what you had in mind. I thought you meant that he should somehow write code directly into the _SCREEN event handler.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top