Results 1 to 8 of 8

Thread: [reSolved] Click on Forms Frame

  1. #1

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397

    [reSolved] Click on Forms Frame

    Well, I'm clueless.

    I'm using a sub to resize a panel when it's parent form resizes, via a MyBase.Resize handler

    VB Code:
    1. 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?



    -Lou

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    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.

  3. #3

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Originally posted by taxes
    Hi,

    Depends on how you coded each control resize. Couldn't you use loops to continue until each control completes resizing?
    I'm not worried about the controls resizing. They resize fine when I stretch the form.

    I just want to reload a picture into the picturebox when the form STOPS resizing.

    How do I detect when the form stops resizing?

    Obviously, I know when it IS resizing, but how do I know when it has stopped?

    With a timer, I can fire off a sub if the current interval from the last resize has exceeded a certain amount, say a half a second.

    But, I'd rather know when the mousebutton has lifted off of the frame of the form.

    Any Ideas on how to detect a Mouse_Up event in referance to a forms frame?

    BTW, Clicking on a forms frame, or MouseDowning on it, does not set off the form's Mouse events.

    However, the mouses Icon changes from a pointer to a double arrow when it is over the frame.

    So, something is firing when a mouse is over the frame.

    So it would seem that the frame's events should be as detectable as any control.

    -Lou

  4. #4
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    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:
    1. Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    2.     If m.Msg = WM_NCMBUTTONDOWN Then
    3.                   'User clicked the caption or one of the edges
    4.                   'Block Imagesizing here
    5.     ElseIf m.Msg = WM_NCMBUTTONUP Then
    6.                   'User released the caption or one of the edges
    7.                   'Perform resize here if size has changed
    8.     End If
    9.  
    10.     MyBase.WndProc(m)
    11. End Sub

    I hope this is of any help...
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  5. #5

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Originally posted by pax
    Hi.
    ...I hope this is of any help...
    Hmm!
    Sweet!

    I tried your suggestion, but first I had to find the values for the constants you provided. Which led me to:

    How to disable right click in textbox

    So, trying your method, it intercepted the ButtonDown message, but NOT when I was going down on the frame, only the internal form.

    So, I looked for Messages, hoping to find some more info, and found this subclassing thread:

    Intercepting Print Screen

    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:
    1. Const WM_ENTERSIZEMOVE = &H231
    2.     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.

    Also, During this, I found that:
    VB Code:
    1. If m.Msg = WM_RBUTTONDOWN Then
    2.             MsgBox(m.ToString)
    3.         End If

    Spits this out:

    msg=0x204 (WM_RBUTTONDOWN) hwnd=0x6501a4 wparam=0x2 lparam=0x10d0196 result=0x0
    It ACTUALLY contains the Text "WM_RBUTTONDOWN"!!!!

    So, instead of checking the value of m.msg against a constant value, I could do an InStr on the message I'm checking for.

    However, It'd be slower, and I really would only want to return the Text Alias of the message only, and not all of the hWnd, wParams, lParam, ...

    But, I could not find that which returns ONLY the text alias of the message.

    Oh, Well.

    But, using the Constants WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE is just what I want.

    By this time, Knowing that the subclassing method achieved desired results, I went back and modified your code to the following:

    VB Code:
    1. Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    2.         Select Case m.Msg
    3.             Case WM_EXITSIZEMOVE
    4.                 Label1.Text = "OFF"
    5.             Case WM_ENTERSIZEMOVE
    6.                 Label1.Text = "ON"
    7.         End Select
    8.         MyBase.WndProc(m)
    9.     End Sub

    And, having commented all the subclassing stuff out of my progie, saw these few lines of code does everything that I need.

    {Well, I have to replace the label1.text setting with my image resizeing code, but you get the idea }




    -Thanks
    -lou

  6. #6

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Alrighty,

    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.




    -Lou
    Attached Files Attached Files

  7. #7
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    Glad you got it working.

    But the WM_NCMBUTTONDOWN and WM_NCMBUTTONUP constants should respond to the frame as well.

    The NC is the Non-Client area, so it should respond to all mousedown and up events in the non-client area of the window, including the caption.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  8. #8

    Thread Starter
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    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.






    -Lou

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width