JackDinn Posted April 19, 2009 Share Posted April 19, 2009 (edited) ahhh, i need to change a pic control but when the window is resized by user the GUICtrlSetImage command sets the new image size back to the initial size of the control??? its like its not getting refreshed or something as if i slightly resize the window it jumps to the size that it should be. hav read 1 other person with same problem but his was with icons and his solution was to through a GUICtrlSetState($HP_CC_pic, $GUI_SHOW) after the setImage but iv tryied all of the CtrlSetState modes and none will do it. im pretty sure i could do a scripted slight resize in and out of the window to "refresh it" but there must be a trick to this that im missing. anyhow done a demo script to show what i mean , if you resize the window and then hit the button the pic should not go back to its first size. GUICreate("My GUI picture", 350, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MAXIMIZEBOX); will create a dialog box that when displayed is centered GUISetBkColor(0xE0FFFF) $n = GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 50, 50, 200, 50) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) $Hbut = GUICtrlCreateButton("test", 2, 2) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Hbut GUICtrlSetImage($n, @SystemDir & "\oobe\images\mslogo.jpg") EndSwitch WEnd Thx all Edited April 21, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted April 21, 2009 Author Share Posted April 21, 2009 ahh common someone pleeese. iv kind given up and im using :- $x = WinGetPos($HGUI_CCeditbox) WinMove($HGUI_CCeditbox, -1, $x[0], $x[1], $x[2], $x[3] + 1) WinMove($HGUI_CCeditbox, -1, $x[0], $x[1], $x[2], $x[3] - 1) which just slightly resizes the window out and then back again which does work for some unknown reason, but now iv found that its not guna work when this window is maximized (of cause, should have realized that ages ago) !! so im back to the same question again how do i "refresh" the pic ctrl after changing the picture??? Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
ProgAndy Posted April 21, 2009 Share Posted April 21, 2009 You should save the control-position before you update the image and reset it afterwards: Func _GUICtrlSetImage($ControlID,$FileName,$IconName=-1, $IconType=1) ; Prog@ndy Local $hCtrl = GUICtrlGetHandle($ControlID) If $hCtrl==0 Then Return SetError(1,0,0) Local $hGUI = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hCtrl) If @error Then Return SetError(2,0,0) Local $pos = ControlGetPos($hGUI[0],"",$n) Local $result = GUICtrlSetImage($ControlID, $FileName, $IconName, $IconType) GUICtrlSetPos($ControlID,$pos[0],$pos[1],$pos[2],$pos[3]) Return $result EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
JackDinn Posted April 21, 2009 Author Share Posted April 21, 2009 aye , i was working on doing that as a kinda fudge , dident know if it would work but i was just looking for how to get the pos & size of a ctrl. it all seems a bit of a work around though thx for your response though , appreciated . Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
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