Jump to content

Recommended Posts

Posted (edited)

I've been struggling with this weird and utterly unwanted behavior in an application I'm developing. When I simply move the GUI window using the title bar, it magically shrinks in height by a large amount. At no point do I call any move or resize functions when this happens. It seems that the OS is shrinking the window by itself.  The width of the window remains unchanged; only the height shrinks, by roughly 2 inches with every move.

I've registered a Move handler and a Sizing handler, but the sizing handler is never invoked when this happens.  Here's the Move handler:

;
;   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
;
;   The following function owes a great debt to the excelent example code by AutoIt poster Bilgus
;
Func _MyDualMovingHandler( $arg_hWnd, $arg_MsgID, $arg_wParam, $arg_lParam )
    #forceref $arg_hWnd, $arg_MsgID, $arg_wParam, $arg_lParam

    If ($arg_hWnd <> $G_DualImageGUI) And ($arg_hWnd <> $G_DualSlotsGUI) Then
        Return $GUI_RUNDEFMSG                               ; This message wasn't meant for us, let it pass through to the Windows system
    EndIf
;
    Local $Lf_TargGUI, $Lf_MonIndex, $Lf_Width, $Lf_Height, $Lf_GUIWasLimited

    _MyUpdStatusMsg("_MyDualMovingHandler Invoked with one of the Dual GUIs")
;
    $Lf_GUIWasLimited = False
;
    If $arg_hWnd = $G_DualImageGUI Then                 ; If the request came from the Image GUI...
        $Lf_TargGUI = $G_DualImageGUI
        $Lf_MonIndex = $G_DualImageMonTblIdx
    Else
        $Lf_TargGUI = $G_DualSlotsGUI
        $Lf_MonIndex = $G_DualSlotsMonTblIdx
    EndIf
;
;       Current rect is passed in lParam
;
    Local $Lf_Rect = DllStructCreate($tagRect, $arg_lParam) ; (IS NOT X, Y, W, H) => (IS X, Y, X+W, Y+H)
    Local $Lf_Left = DllStructGetData($Lf_Rect, 1)
    Local $Lf_Top = DllStructGetData($Lf_Rect, 2)
    Local $Lf_Right = DllStructGetData($Lf_Rect, 3)
    Local $Lf_Bottom = DllStructGetData($Lf_Rect, 4)

_MyUpdStatusMsg("_MyDualMovingHandler - Left, Top, Right, Bottom = " & $Lf_Left & ", " & $Lf_Top & ", " & $Lf_Right & ", " & $Lf_Bottom)

;       Check left and right of window against imposed limits
;
    If $Lf_Left < $G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblLeftIx] Then
        $Lf_Width = $Lf_Right - $Lf_Left ;Calculate Original Width
        $Lf_Left = $G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblLeftIx]
        $Lf_Right = $Lf_Left + $Lf_Width ;Have to keep our same Width
        $Lf_GUIWasLimited = True
    EndIf

    If $Lf_Right > $G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblRightIx] Then
        $Lf_Width = $Lf_Right - $Lf_Left ;Calculate Original Width
        $Lf_Right = $G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblRightIx]
        $Lf_Left = $Lf_Right - $Lf_Width ;Have to keep our same Width
        $Lf_GUIWasLimited = True
    EndIf
;
;       Check top and bottom of window against imposed limits
;
    If $Lf_Top < $G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblTopIx] Then
        $Lf_Height = $Lf_Bottom - $Lf_Top ;Calculate Original Height
        $Lf_Top = $G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblTopIx]
        $Lf_Bottom = $Lf_Top + $Lf_Height ;Have to keep our same Height
        $Lf_GUIWasLimited = True
    EndIf

    If $Lf_Bottom > $G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblBottomIx] Then
        $Lf_Height = $Lf_Bottom - $Lf_Top ;Calculate Original Height
        $Lf_Bottom = $G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblBottomIx]
        $Lf_Top = $Lf_Bottom - $Lf_Height ;Have to keep our same Height
        $Lf_GUIWasLimited = True
    EndIf

;
;   Adjust GUI to leave 2 pixels extra space on each dimension
;
    If $Lf_Left < ($G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblLeftIx] +2) Then
        $Lf_Left += 2
        $Lf_GUIWasLimited = True
    EndIf

    If $Lf_Top < ($G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblTopIx] +2) Then
        $Lf_Top += 2
        $Lf_GUIWasLimited = True
    EndIf

    If $Lf_Right < ($G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblRightIx] -2) Then
        $Lf_Right -= 2
        $Lf_GUIWasLimited = True
    EndIf

    If $Lf_Bottom < ($G_MonitorTbl[$Lf_MonIndex][$Gc_MonTblBottomIx] -8) Then
        $Lf_Bottom -= 8
        $Lf_GUIWasLimited = True
    EndIf

    If $Lf_TargGUI = $G_DualImageGUI Then
        $G_DualImageGUIAbsLeft  = $Lf_Left
        $G_DualImageGUIAbsTop   = $Lf_Top
        $G_DualImageGUIWidth    = $Lf_Width
        $G_DualImageGUIHeight   = $Lf_Height
    ElseIf $Lf_TargGUI = $G_DualSlotsGUI Then
        $G_DualSlotsGUIAbsLeft      = $Lf_Left
        $G_DualSlotsGUIAbsTop       = $Lf_Top
        $G_DualSlotsGUIAbsHeight    = $Lf_Height
        If $Lf_Right <> $Lf_Left + $G_FixedDualSlotsGUIWidth Then
            $Lf_Right = $Lf_Left + $G_FixedDualSlotsGUIWidth
        EndIf
        $G_DualSlotsGUIAbsRight = $Lf_Right
        $G_DualSlotsGUIAbsBottom    = $Lf_Bottom
        $Lf_GUIWasLimited = True
    EndIf


    If $Lf_GUIWasLimited Then

        DllStructSetData($Lf_Rect, 1, $Lf_Left)
        DllStructSetData($Lf_Rect, 2, $Lf_Top)
        DllStructSetData($Lf_Rect, 3, $Lf_Right)
        DllStructSetData($Lf_Rect, 4, $Lf_Bottom)

        DllStructSetData($G_ImageAreaRECTtag, "Left", $Lf_Left)
        DllStructSetData($G_ImageAreaRECTtag, "Top", $Lf_Top)
        DllStructSetData($G_ImageAreaRECTtag, "Right", $Lf_Right)
        DllStructSetData($G_ImageAreaRECTtag, "Bottom", $Lf_Bottom)

;~      _WinAPI_DefWindowProc($arg_hWnd, $arg_MsgID, $arg_wParam, $arg_lParam)  ; Rect on to default window procedure ?
        Return 1 ; True

    EndIf

;~  _WinAPI_DefWindowProc($arg_hWnd, $arg_MsgID, $arg_wParam, $arg_lParam)
    Return 0 ; Default Handler? Or stop here (Return 0)????

EndFunc ;==>_MyDualMovingHandler
;

Any ideas as to why this is happening?  Regarding the end of the function, I get the same results if I include or comment out the call to _WinAPI_DefWindowProc().

Thank You for your time.

Edited by Mbee
Posted
2 minutes ago, Mbee said:

Any ideas as to why this is happening?

We're going to need more than just one function to try and figure this out. Post something we can run that demonstrates the problem.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

Oh, well. I can't possibly isolate the necessary parts of 11,300 lines of code so that it actually is runnable.  Forget I asked for help.

Posted (edited)

For the record, the bug was indeed in exactly what I posted.  No posting of other code was the least bit necessary or useful. This recurring demand that I post large amounts of working proprietary code is unfair and unnecessary.

The bug occurs under the heading comment "Adjust GUI to leave 2 pixels extra space on each dimension", where I subtract 8 pixels at the bottom of the window. When I coded this, I was expecting the WM_MOVE handler would be invoked only once, whereas it turns out that it is invoked many times, potentially hundred of times. That explains the shrinking window.

 

Edited by Mbee
  • Moderators
Posted

Mbee,

As I have explained previously, no-one is asking you to post 11,000+ lines of code - in fact if you did, I doubt anyone would even bother to read it. What we do ask though is that you post a runnable script which demonstrates the problem you are having. If, as you have indicated on several occasions now, you consider that too difficult to manage, then please refrain from asking for help on this monster script because you are very unlikely to get any sensible suggestions when all you do is post a few snippets.

I have now merged the 2 threads on this matter - which explains the 2 posts above.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...