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!

Form resize 1

Status
Not open for further replies.

Stretchwickster

Programmer
Apr 30, 2001
1,746
GB
Hi people,

I'm trying to catch the end of a form resize operation so that I can repaint a canvas after the user releases the mouse (i.e. finished the resize). Using the OnResize event of the form, I can detect when the user starts to resize but not when they finish. So it tries to redraw whilst the user is still dragging out the form. Anyone got any ideas?

Your help would be much appreciated!

Clive [infinity]
 
why not set a flag in the onresize event and use this flag in the onmouseup event?

cheers

--------------------------------------
What You See Is What You Get
 
Nice idea, but I tried it and when you resize the form - the mouse events are not triggered! Any other ideas? Do I need to catch some windows messages?

Clive [infinity]
 
Clive,

played some and this is what I found :
Code:
type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
   procedure ResizeMoveDetect(var Msg: Tmessage); message WM_EXITSIZEMOVE;
  end;


procedure TForm1.ResizeMoveDetect(var Msg: Tmessage);
begin
 showmessage('this works!!!');
end;

this code will detect end of resizes/moves of your form. I want only resize events, you can set a flag in hte Onresize event and test/clear this flag in the ResizeMoveDetect procedure...

Happy programming :)


--------------------------------------
What You See Is What You Get
 
whosrdaddy,

You are a genius! Thank you - that windows message was exactly what I was looking for. Incidentally, how did you find the WM_EXITSIZEMOVE message. I spent a good hour hunting for a more apt windows message than WM_RESIZE!!

Once again, thank you - you thoroughly deserve a star!

Enjoy!

Clive [infinity]
 
The resize now works beautifully. I also realised that I needed to handle the maximise and restore possibilities. So I added the following:
For maximise
Code:
procedure TForm1.MaximiseDetect(var Msg: TWMSize);
begin
  inherited;
  if Msg.SizeType = SIZE_MAXIMIZED then
  begin
    // redraw
  end;
end;

For restore
Code:
procedure TForm1.ApplicationEvents1Restore(Sender: TObject);
begin
  // redraw
end;

However, there's one last situation I need to account for. When a form is maximised it can then be "restored down" - how do I catch this event? I couldn't seem to see it on MSDN.

Your help would be much appreciated!

Clive [infinity]
 
Clive,

you can look for the WM_SIZE message, here's a copy/paste from win32 SDK, this way you'll capture all events in one procedure :

Code:
he WM_SIZE message is sent to a window after its size has changed. 

WM_SIZE  
fwSizeType = wParam;      // resizing flag 
nWidth = LOWORD(lParam);  // width of client area 
nHeight = HIWORD(lParam); // height of client area 
 

Parameters

fwSizeType

Value of wParam. Specifies the type of resizing requested. This parameter can be one of the following values: 

Value	Meaning
SIZE_MAXHIDE	Message is sent to all pop-up windows when some other window is maximized.
SIZE_MAXIMIZED	Window has been maximized.
SIZE_MAXSHOW	Message is sent to all pop-up windows when some other window has been restored to its former size.
SIZE_MINIMIZED	Window has been minimized.
SIZE_RESTORED	Window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies.
 

nWidth

Value of the low-order word of lParam. Specifies the new width of the client area. 

nHeight

Value of the high-order word of lParam. Specifies the new height of the client area. 

 

Return Values

If an application processes this message, it should return zero.

hope this helps...

--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top