Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Resizable Container Control
Message
De
30/07/1997 22:06:35
Renato De Giovanni
Via Fractal Information Systems
São Paulo, Brésil
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00041015
Message ID:
00042539
Vues:
32
>Renato, hi, could you share how you did that? I've been following this thread for a while and found it to be very interesting; the applications for such an effect can be many and very helpful!.
>
>Thanks.

Here it is...

Part of this code was based on Gérald Santerre's ideas (thanks, Gérald!) and it will work in almost all situations.
If you also want to resize the controls inside the container you must put extra code into the resize and the init events (the resizing classes available in the files section don't work for this situation and also aren't provided with free source code...)

So, Create a Container Class with these properties:
zrl_from_top, zrl_from_left, zrn_maxHeight, zrn_minHeight, zrn_maxWidth, zrn_minWidth

And paste this code (I've deleted the comments in portuguese :) , but I believe the code is understandable)
**************** MouseMove Event
LOCAL ln_delta, ln_left, ln_top, ll_vertical_change, ;
ll_horizontal_change, ll_vertical_expansion, ;
ll_horizontal_expansion

ln_delta = 0
ln_left = THIS.Left
ln_top = THIS.Top
ll_vertical_change = .F.
ll_horizontal_change = .F.
ll_vertical_expansion = .F.
ll_horizontal_expansion = .F.

DO CASE

CASE nButton = 0

DO CASE

CASE nYCoord = ln_top AND nXCoord = ln_left

THIS.MousePointer = 8
THIS.zrl_from_top = .T.
THIS.zrl_from_left = .T.

CASE nYCoord = ln_top AND nXCoord = ln_left + THIS.Width -1

THIS.MousePointer = 6
THIS.zrl_from_top = .T.
THIS.zrl_from_left = .F.

CASE nYCoord = ln_top + THIS.Height -1 AND nXCoord = ln_left

THIS.MousePointer = 6
THIS.zrl_from_top = .F.
THIS.zrl_from_left = .T.

CASE nYCoord = ln_top + THIS.Height -1 AND ;
nXCoord = ln_left + THIS.Width -1

THIS.MousePointer = 8
THIS.zrl_from_top = .F.
THIS.zrl_from_left = .F.

CASE nXCoord = ln_left

THIS.MousePointer = 9
THIS.zrl_from_left = .T.

CASE nXCoord = ln_left + THIS.Width -1

THIS.MousePointer = 9
THIS.zrl_from_left = .F.

CASE nYCoord = ln_top

THIS.MousePointer = 7
THIS.zrl_from_top = .T.

CASE nYCoord = ln_top + THIS.Height -1

THIS.MousePointer = 7
THIS.zrl_from_top = .F.

OTHERWISE

THIS.MousePointer = 0
ENDCASE

CASE nButton = 1

DO CASE

CASE THIS.MousePointer = 9

IF (nXCoord <> ln_left) AND ;
(nXCoord <> ln_left + THIS.Width)

ll_horizontal_change = .T.

IF (nXCoord < ln_left) OR ;
(nXCoord > ln_left + THIS.Width)

ll_horizontal_expansion = .T.
ENDIF
ENDIF

CASE THIS.MousePointer = 7

IF (nYCoord <> ln_top) AND ;
(nYCoord <> ln_top + THIS.Height)

ll_vertical_change = .T.

IF (nYCoord < ln_top) OR ;
(nYCoord > ln_top + THIS.Height)

ll_vertical_expansion = .T.
ENDIF
ENDIF

CASE THIS.MousePointer = 6 OR THIS.MousePointer = 8

IF (nXCoord <> ln_left) AND ;
(nXCoord <> ln_left + THIS.Width)

ll_horizontal_change = .T.

IF (nXCoord < ln_left) OR ;
(nXCoord > ln_left + THIS.Width)

ll_horizontal_expansion = .T.
ENDIF
ENDIF

IF (nYCoord <> ln_top) AND ;
(nYCoord <> ln_top + THIS.Height)

ll_vertical_change = .T.

IF (nYCoord < ln_top) OR ;
(nYCoord > ln_top + THIS.Height)

ll_vertical_expansion = .T.
ENDIF
ENDIF
ENDCASE

IF ll_horizontal_change

IF THIS.zrl_from_left

IF ll_horizontal_expansion

ln_delta = ln_left - nXCoord

IF THIS.Width < THIS.zrn_maxWidth

THIS.Left = nXCoord - THIS.Parent.Left
ELSE

THIS.MousePointer = 12
ENDIF

THIS.Width = THIS.Width + ln_delta
ELSE

ln_delta = nXCoord - ln_left

IF THIS.Width > THIS.zrn_minWidth

THIS.Left = nXCoord -THIS.Parent.Left
ELSE

THIS.MousePointer = 12
ENDIF

THIS.Width = THIS.Width - ln_delta
ENDIF
ELSE

IF ll_horizontal_expansion

ln_delta = nXCoord -(ln_left + THIS.Width)

THIS.Width = THIS.Width + ln_delta

IF THIS.Width = THIS.zrn_maxWidth

THIS.MousePointer = 12
ENDIF

ELSE

THIS.Width = nXCoord - ln_left

IF THIS.Width = THIS.zrn_minWidth

THIS.MousePointer = 12
ENDIF
ENDIF
ENDIF
ENDIF

IF ll_vertical_change

IF THIS.zrl_from_top

IF ll_vertical_expansion

ln_delta = ln_top - nYCoord

IF THIS.Height < THIS.zrn_maxHeight

THIS.Top = nYCoord - THIS.Parent.Left
ELSE

THIS.MousePointer = 12
ENDIF

THIS.Height = THIS.Height + ln_delta
ELSE

ln_delta = nYCoord - ln_top

IF THIS.Height > THIS.zrn_minHeight

THIS.Top = nYCoord -THIS.Parent.Left
ELSE

THIS.MousePointer = 12
ENDIF

THIS.Height = THIS.Height - ln_delta
ENDIF
ELSE

IF ll_vertical_expansion

ln_delta = nYCoord -(ln_top + THIS.Height)

THIS.Height = THIS.Height + ln_delta

IF THIS.Height = THIS.zrn_maxHeight

THIS.MousePointer = 12
ENDIF
ELSE

THIS.Height = nYCoord - ln_top

IF THIS.Height = THIS.zrn_minHeight

THIS.MousePointer = 12
ENDIF
ENDIF
ENDIF
ENDIF
ENDCASE
******************* Resize Event
IF THIS.Height > THIS.zrn_maxHeight

THIS.Height = THIS.zrn_maxHeight
ENDIF

IF THIS.Height < THIS.zrn_minHeight

THIS.Height = THIS.zrn_minHeight
ENDIF

IF THIS.Width > THIS.zrn_maxWidth

THIS.Width = THIS.zrn_maxWidth
ENDIF

IF THIS.Width < THIS.zrn_minWidth

THIS.Width = THIS.zrn_minWidth
ENDIF
*******************
Add the Container to any Form and you'll have a resizable container...

Regards,

Renato
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform