Skitty Posted June 18, 2012 Posted June 18, 2012 (edited) I have a condition where I must resize various controls manually and on the fly, the problem I am encountering is that you cannot resize the native autoit controls from the scope of the WM_SIZE registered function and seems to only be possible when registering it to execute after the function has exited. How can I resize a control without having to use the adlibregister function? I have noticed that this is not a very good method when another function is already running because the adlib registed function will wait to execute after everything else has compleated. expandcollapse popup#include <WinAPI.au3> #include<WindowsConstants.au3> Global $UseAdlib = 0 Opt("GUIOnEventMode", 1) Global $ui= GUICreate("",200,200,-1,-1,0x00070000) GUISetOnEvent(-3, "_Exit") GUICtrlCreateButton("SwitchMode",66,99,65,33) GUICtrlSetOnEvent(-1,"SwitchMode") GUIRegisterMsg($WM_SIZE, "WM_SIZE") Global $hbar= GUICtrlCreateInput("",4, 33,12,20) GUISetState() Sleep(1000000) Func _Exit() Exit EndFunc Func SwitchMode() $UseAdlib = Not($UseAdlib) Switch $UseAdlib Case True WinSetTitle($ui,"","Using AdlibRegister to resize input!") Case False WinSetTitle($ui,"","Attempting to resize input from inside WM_SIZE function!") EndSwitch EndFunc Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hwnd, $iMsg, $iwParam, $ilParam Switch $UseAdlib Case True AdlibRegister("_size",1) Case False _size() EndSwitch Return 'GUI_RUNDEFMSG' EndFunc ;==>WM_SIZE Func _size() Local $Size = WinGetClientSize($ui) ControlMove($ui, "",$hBar, 4, 33 , $Size[0] -8, 21) AdlibUnRegister("_size") EndFunc Here is one more thing I took notice to, it will work if I do this... #include <WinAPI.au3> #include<WindowsConstants.au3> Global $UseAdlib = 0 Opt("GUIOnEventMode", 1) Global $ui= GUICreate("",200,200,-1,-1,0x00070000) GUISetOnEvent(-3, "_Exit") GUIRegisterMsg($WM_SIZE, "WM_SIZE") Global $hbar= GUICtrlCreateInput("",4, 33,12,20) GUISetState() Sleep(1000000) Func _Exit() Exit EndFunc Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hwnd, $iMsg, $iwParam, $ilParam Return 'GUI_RUNDEFMSG'&_size() EndFunc ;==>WM_SIZE Func _size() Local $Size = WinGetClientSize($ui) ControlMove($ui, "",$hBar, 4, 33 , $Size[0] -8, 21) EndFunc So I come to the conclusion that I need to figure out a way to send the 'GUI_RUNDEFMSG' string some other way and then proceed to do the adjustments to some controls manually from withing the function, how can I do this? Is there a way to send the 'GUI_RUNDEFMSG' message manually without having to return from the function? Edited June 18, 2012 by ApudAngelorum
AZJIO Posted June 18, 2012 Posted June 18, 2012 (edited) Opt("GUIResizeMode", 802)GUICtrlSetResizingFunc WM_SIZE($hWnd, $msg, $wParam, $lParam) #forceref $Msg, $wParam Local $w, $h If $hWnd = $Gui Then $w = BitAND($lParam, 0xFFFF) ; _WinAPI_LoWord $h = BitShift($lParam, 16) ; _WinAPI_HiWord _SetSizePos($w, $h) EndIf Return $GUI_RUNDEFMSG EndFunc Func _SetSizePos($w, $h) $w = $w - 200 $h = ($h - 130) / 2 GUICtrlSetPos($Pattern, 10, 104, $w, $h) GUICtrlSetPos($Result, 10, $h + 120, $w, $h) GUICtrlSetPos($LRes, 10, $h + 105) EndFunc Edited June 18, 2012 by AZJIO My other projects or all
Skitty Posted June 18, 2012 Author Posted June 18, 2012 Ah, I new I was doing something wrong, thanks.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now