I'm using a sub to resize a panel when it's parent form resizes, via a MyBase.Resize handler
VB Code:
Private Sub RESIZE_FORM(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
Within the sub, I'm also repositioning the panel so its centered in the form, and is always 9/10 ths the size of the form.
Within the panel is a picturebox, and that is being centered in the panel as the panel resizes to the forms new size.
Now, My next step is going to be, if the picturebox contains an image, the picturebox is going to resize as the panel resizes, and the image within the picturebox is going to resize to the size of the picturebox.
So:
Form Resizes-> Panel Resizes-> PictureBox Resizes-> Image Resizes
Now, certainly I can do all this from the MyBase.Resize event, however, I can see that resizeing the image is going to be a memory intensize operation, and the MyBase.resizing event is constantly firing as I'm using my mouse to change the forms frame size.
What I want to really do is when the frame is changing size, all the sub controls are changing size, but I want to hold off on resizing the image until the form STOPS resizing.
This would be doable without a timer, if I could detect the MouseUp event of the forms frame.
So, My Question is:
How can I get the forms frame to fire off mouse events?
Depends on how you coded each control resize. Couldn't you use loops to continue until each control completes resizing?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
I'm not exactly sure HOW to do it, but I believe you could use the WndProc method of the form and check for WM_NCMBUTTONDOWN and WM_NCMBUTTONUP messages.
Something like this maybe...
VB Code:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_NCMBUTTONDOWN Then
'User clicked the caption or one of the edges
'Block Imagesizing here
ElseIf m.Msg = WM_NCMBUTTONUP Then
'User released the caption or one of the edges
'Perform resize here if size has changed
End If
MyBase.WndProc(m)
End Sub
I hope this is of any help...
I wish I could think of something witty to put in my sig...
Didn't help much, but I tried it anyways, thinking I might intercept more. Didn't truly help, however it got me to thinking about Spy++
So, Activateing that tool up, I soon saw that mousedowning and mouseupping on the frame creates the messages:
WM_ENTERSIZEMOVE
WM_EXITSIZEMOVE
Which, after fidaddling a little, I figured out their values should be defined as:
VB Code:
Const WM_ENTERSIZEMOVE = &H231
Const WM_EXITSIZEMOVE = &H232
Before I defined those constants, I spent some time looking for them to be defined in some sort of predefined system object, whereby I could see ALL the WM's. But I couldn't.
For anyone who wants to see, attached is my code which handles
resizing a loaded image in a picturebox after a form has been resized from dragging
its frame with a mouse.
When the Form resizes, a panel resizes in relation to the form, and a picturebox resizes in relation to the panel.
If the picturebox contains an image, if the form was resized by resizing the forms outside border with the mouse, then once the mouse releases the forms border, the picture inside the picture box resizes to the bounds of the picturebox.
Originally posted by pax ...But the WM_NCMBUTTONDOWN...
OOPS!
I ended up mixing it up with WM_RBUTTONDOWN .
Ah Well. It's best that I ended up with WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE, I wouldn't want to have to code around clicking on the title bar, or caption.