Weird behavior when launching guisize with gosub. Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
colt
Posts: 75
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Weird behavior when launching guisize with gosub.

20 Nov 2018, 21:50

I am trying to change my gui layout by changing modes with a dropdown list. It works great until I try launching the guisize glabel with gosub. When guisize is launched all the controls disappear. To make them visible again I have to manually resize the gui. Is it possible to refresh the whole gui? Here is a script that shows the problem and a few attempts at a workaround.

Code: Select all

#singleInstance Force
setbatchlines -1
Gui, New, hwndhwndGUI Resize 
Gui, Add, Edit,vtextE ,TEST
gui, add, dropdownlist,vdropDownDD altSubmit gdropDown,Setting 1||Setting 2
gui show, w500 h500,Video Manager
return

GuiSize:
	;tooltip % A_GUI ", " A_GUIEvent
	gui Submit, Nohide	
	if(dropDownDD == 1)
	{
		editH := A_guiHeight - 100
	}
	else
	{
		editH := A_guiHeight - 300	
	}
	guicontrol ,moveDraw,textE, % "w" . A_guiWidth -20 . " h" .  editH . " y10"	
	guicontrol ,moveDraw,dropDownDD, % "w" . A_guiWidth -20 . " y" . editH + 15
return

dropDown:
	gui Submit, Nohide	
	gosub,GuiSize
return

f6::
	gui Submit, Nohide	
	tooltip trying send message
	SendMessage, 0x05,,,, ahk_id %hwndGUI%
return
	
f7::
	gui Submit, Nohide	
	tooltip trying gosub
	gosub,GuiSize
return

f8::
	tooltip resize 1 pixel
	;doesnt work when maximized
	gui Submit, Nohide		
	WinGetPos , X, Y, Width, Height, A
	newWidth := Width + 1	
	WinMove, ahk_id %hwndGUI%,,,, %newWidth%
	WinMove, ahk_id %hwndGUI%,,,, %Width%	
return

f9::
	tooltip try redraw
	winset, redraw,,ahk_id %hwndGUI%
return

f10::
	tooltip try winhide winshow
	winhide,ahk_id %hwndGUI%
	winshow,ahk_id %hwndGUI%
return
colt
Posts: 75
Joined: 04 Aug 2014, 23:12
Location: Portland Oregon

Re: Weird behavior when launching guisize with gosub.  Topic is solved

20 Nov 2018, 22:08

Turns out that if guisize is not triggered by an actual drag A_guiWidth and A_guiHeight are not accurate and are reset to 0. In case anyone else runs into this here is the new gui size function.

Code: Select all

GuiSize:
	;tooltip % A_GUI ", " A_GUIEvent
	gui Submit, Nohide	
	tooltip %A_guiHeight%`n%A_guiWidth%`n%ErrorLevel%
	if(ErrorLevel==0)
	{
		lastHeight := A_guiHeight
		lastWidth := A_guiWidth
	}
	if(dropDownDD == 1)
	{
		editH := lastHeight - 100
	}
	else
	{
		editH := lastHeight - 300	
	}
	guicontrol ,moveDraw,textE, % "w" . lastWidth -20 . " h" .  editH . " y10"	
	guicontrol ,moveDraw,dropDownDD, % "w" . lastWidth -20 . " y" . editH + 15	
return

Return to “Ask For Help”

Who is online

Users browsing this forum: A_Perry_1984, colt, ineuw, MannyKSoSo, OmegaMachine, Regath and 39 guests