Jump to content

2 GUI Issues I can't seem to iron out!


 Share

Recommended Posts

Hey Guys, this is somewhat related to another post in here but my specific question was "answered" and so I thought I would make a new post that is referencing the same code, with slightly different issues. 

Problem 1

Setup: I am using a label docked to the main GUI to set the size of a child GUI. 

Issue: When I slowly drag the borders, I can see my green label kind of peeking out from behind the GUI, not a huge problem I guess. If I drag the border very quicky I can get the offset to be really big (200-300 pixels)

** Edit - I just realized that the child of the child GUI actually does not display this same "lag" or difference in sizing. hmmmm

Problem 2

*discaimer! - Melba if you see this, I know you have Aero disabled so I understand if you don't want anything to do with this one! haha

Setup: Using windows message WM_WINDOWPOSCHANGING. This should give me a message "While" the window is changing. There is a WM_WINDOWPOSCHANGED, which should fire after the change happens. 

Issue: Upon a normal maximize/restore methods (double clicking title bar, or using the buttons) the window behaves. Upon an Aero Snap maximize/restore the update only happens AFTER I let go of my left click. So while dragging the window down from its maximized state the child GUI's remain maximized until I let go of the left click  mouse button and it resizes. I really want this to resize the second it unsnaps from the maximized state. 

**Edit - This is due to the way I am handling the flags parameter of the WINDOWPOS Struct. I'm masking only using 1 of the members and it only sees that once the LMB is released. So I am basically misusing the message because im not very familiar with it :( I have experimented with bitOR(member1, member2, member3) because im thinking SWP_FRAMECHANGED is not the only member I should be masking against "flags" (although it works somewhat)

Here is my code. 

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

$iGuiWidth = 660
$iGUIHeight = 320
$DividerOffset = 244

Global $aGUIPos[6]
Global $hgui, $hgui1, $hguiInner1, $cLabel_1, $cLabel_2, $cLabel_3, $iOFfset_X1, $iOFfset_Y1
Global $bSysMsg = False

GUI()
GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
GUIRegisterMsg($WM_WINDOWPOSCHANGING, "_WM_WINDOWPOSCHANGING")


Func GUI()
    $hgui = GUICreate("test", $iGuiWidth, $iGUIHeight, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_POPUP))
    GUISetBkColor(0x666666)

    $cLabel_1 = GUICtrlCreateLabel("I am the label", 4, 65, $iGuiWidth - 7, 250)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKRIGHT))
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState()

    $hgui1 = GUICreate("", $iGuiWidth - 7, $iGUIHeight - 70, -1, 60, $WS_POPUP, $WS_EX_MDICHILD, $hgui)
    GUISetBkColor(0x888888)
    GUISetState()

    $Divider = GUICtrlCreateLabel('', $DividerOffset, 0, 5, 250)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetResizing(-1, BitOR($GUI_DOCKWIDTH, $GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM))
    GUICtrlSetCursor(-1, 13)
    GUISetState()

    $cLabel_2 = GUICtrlCreateLabel("I am the label", 249, 25, 403, 225)
    GUICtrlSetBkColor(-1, 0x0000FF)
    GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH, $GUI_DOCKRIGHT))
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState()

    $hGuiInner1 = GUICreate("",  403, 225, 252,28, $WS_POPUP, $WS_EX_MDICHILD, $hgui1)
    GUISetBkColor(0x555555)
    GUISetState()

    _GetGuiPos($hgui,0,1)
    _GetGuiPos($hgui1,2,3)
;~  _GetGuiPos(hgui2,3,4)

For $i = 0 to 5
    ConsoleWrite("$aguipos[" & $i & "]:=" & $aguipos[$i] &  @LF)
Next


EndFunc   ;==>GUI

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Quit()
    EndSwitch

    If $bSysMsg Then
        $bSysMsg = False
        _Resize_GUIs()
    EndIf

WEnd

Func Quit()
    Exit
EndFunc   ;==>Quit

Func _Resize_GUIs()
    ;GUI1
    $aWin1 = WinGetPos($hgui)
    $aRet1 = ControlGetPos($hgui, "", $cLabel_1)
    WinMove($hgui1, "", $aWin1[0] + $aGUIPos[0] + $aRet1[0], $aWin1[1] + $aGUIPos[1] + $aRet1[1], $aRet1[2], $aRet1[3])
    $aWin2 = WinGetPos($hgui1)
    $aRet2 = ControlGetPos($hgui1, "", $cLabel_2)
    WinMove($hguiInner1, "", $aWin2[0] + $aGUIPos[2] + $aRet2[0], $aWin2[1] + $aGUIPos[3] + $aRet2[1], $aRet2[2], $aRet2[3])
;~  $aWin3 = WinGetPos($hgui)
;~     $aRet3 = ControlGetPos($hgui, "", $cLabel_3)
;~     WinMove($hgui1, "", $aWin3[0] + $aGUIPos[4] + $aRet3[0], $aWin3[1] + $aGUIPos[5] + $aRet3[1], $aRet3[2], $aRet3[3])

EndFunc   ;==>_Resize_GUIs

func _WM_WINDOWPOSCHANGING($hWnd, $msg, $wParam, $lParam)
   Local $winpos_Struct = DllStructCreate("hwnd hwnd;hwnd hwndInsertAfter;int x;int y;int cx;int cy;uint flags", $lParam)
   $MaximizeOrRestore = bitand(DllStructGetData($winpos_Struct, "flags"), $SWP_FRAMECHANGED)
   if $MaximizeOrRestore > 0 then
      $bSysMsg = True
   endif
EndFunc

Func _WM_SIZE($hWnd, $msg, $wParam, $lParam)
    _Resize_GUIs()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_SIZE

Func _Exit($s_Msg)
    MsgBox(0, "Error", $s_Msg)
    Exit
EndFunc

Func _GetGuiPos($hTargGUI,$iArrayEle1,$iArrayEle2)
    $aWin = WinGetPos($hTargGUI)
    Local $tPoint = DllStructCreate("int X;int Y")
    DllStructSetData($tPoint, "X", 0)
    DllStructSetData($tPoint, "Y", 0)
    _WinAPI_ClientToScreen($hTargGUI, $tPoint)
    $aGUIPos[$iArrayEle1] = DllStructGetData($tPoint, "X") -  $aWin[0]
    $aGUIPos[$iArrayEle2] = DllStructGetData($tPoint, "Y") -  $aWin[1]
EndFunc
Edited by JakeKenmode
Link to comment
Share on other sites

Ok Problem 1 Solved: 

It seems messy to me, but this worked by some stroke of luck in my experimenting.

WM_WINDOWPOSCHANGING fires when anything happens. So altering my mask I was able to catch resizes as well as maximizes and minimizes. 

WM_SIZE handles the "live" sizing while you are dragging, but then at the end if there was any mismatch I am using WM_WINDOWPOSCHANGING to give it one last update at the end that perfectly sizes my child GUI to the green label under it. 

Why WM_SIZE on its own could be tricked? I don't know, but changing WM_WINDOWPOSCHANGING's  the mask to: 

bitand(DllStructGetData($winpos_Struct, "flags"), bitor($SWP_FRAMECHANGED,$SWP_NOMOVE,$SWP_NOZORDER))

allowed me to catch window resizes once I let go of the LMB at the end of a resize. 

Like I said - messy. Also - This message "should" be firing events AS the window is moving as the description on MSDN suggests. This leads me to believe I am still using it wrong because the events are firing after all the moves and I let go of LMB on a drag. 

So I'm closer - Issue 2 still exists 

Edited by JakeKenmode
Link to comment
Share on other sites

  • Moderators

JakeKenmode,

Fine, I will limit my comments to problem 1 only! :D

Just make the label transparent (look in the Help file to see how) as this has no effect on the label resizing but means it does not show when the resizing is taking place. ;)

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

 

Link to comment
Share on other sites

In the main app - it will be transparent, I'm just using the test code up there to simplify and show me the labels, so I can see that it is performing correctly. 

Here is an image showing the result of quickly dragging the right edge of the form very fast. 

post-87120-0-00465800-1424285378_thumb.j

I referenced your resize script with the 3 list views and only edited the background colors and on a really fast drag of the window you can achieve the same effects where the labels size / position goes out of whack

post-87120-0-77161500-1424285942_thumb.j

 

Edited by JakeKenmode
Link to comment
Share on other sites

  • Moderators

JakeKenmode,

AutoIt is an interpreted language - you will never get the speed of response that you get with fully compiled languages. We are already using a trick to get the non-AutoIt generated controls resized so it seems a little ungracious to complain that AutoIt lags a little when asked to cope. ;)

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

 

Link to comment
Share on other sites

I have OCD! haha it must be perfect! Ok ok not perfect, but I would expect it to behave "like" a proper windows form would. 

Digging around in the forums I have unearthed a post! all credit here goes to user "binhnx"

My test script works perfectly - on resizes, maximizes and restores. It also handles the Windows 7 Aero interface snaps :)

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

GUIRegisterMsg($WM_SIZE, "WM_SIZE")

$hgui = GUICreate("test", 300, 300, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_POPUP))
GUISetState()
$hgui1 = GUICreate("", 280, 280, 5, 5, $WS_POPUP, $WS_EX_MDICHILD, $hgui)
GUISetBkColor(0x444444)
GUISetState()
$hgui2 = GUICreate("", 265, 265, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $hgui1)
GUISetBkColor(0x666666)
GUISetState()
$hgui3 = GUICreate("", 250, 250, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $hgui2)
GUISetBkColor(0x888888)
GUISetState()
$hgui4 = GUICreate("", 235, 235, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $hgui3)
GUISetBkColor(0xaaaaaa)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            exit
    EndSwitch
WEnd

Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam)
    ;hardcoded my offsets for simiplicty of the example
    _WinAPI_SetWindowPos($hgui1, 0, 0, 0, _WinAPI_LoWord($lParam)-20, _WinAPI_HiWord($lParam)-20,BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    _WinAPI_SetWindowPos($hgui2, 0, 0, 0, _WinAPI_LoWord($lParam)-35, _WinAPI_HiWord($lParam)-35,BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    _WinAPI_SetWindowPos($hgui3, 0, 0, 0, _WinAPI_LoWord($lParam)-50, _WinAPI_HiWord($lParam)-50,BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    _WinAPI_SetWindowPos($hgui4, 0, 0, 0, _WinAPI_LoWord($lParam)-65, _WinAPI_HiWord($lParam)-65,BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    Return 1
EndFunc
Edited by JakeKenmode
Link to comment
Share on other sites

  • Moderators

JakeKenmode,

Bravo!! :thumbsup:

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

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...