claude21 Posted January 10, 2010 Share Posted January 10, 2010 I've a problem with icon placement changing when I send command GUICrtlSetImage to change the icon image, but only when the main window has been maximized first. here a simple example code : #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 413, 300, -1, -1, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS)) $Label1 = GUICtrlCreateLabel("icon should stay in right corner", 10, 200, 380, 17, $WS_GROUP) $Label2 = GUICtrlCreateLabel("1st maximize the window, then, click update", 10, 180, 250, 17) $Icon1 = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -14, 376, 264, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP)) $Button1 = GUICtrlCreateButton("Update icon", 32, 272, 100, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetImage($Icon1, @SystemDir & "\shell32.dll", -12) GUICtrlSetData($Label1, "Why the icon moved when Label stay in his original position ? ") EndSwitch WEnd What should I do to prevent icon changing her position when window is maximized ? I searched but found nothing so far. Link to comment Share on other sites More sharing options...
Yashied Posted January 10, 2010 Share Posted January 10, 2010 (edited) Use the GUICtrlSetResizing() function for each control.#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 413, 300, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS)) $Label1 = GUICtrlCreateLabel("icon should stay in right corner", 10, 200, 380, 17, $WS_GROUP) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Label2 = GUICtrlCreateLabel("1st maximize the window, then, click update", 10, 180, 250, 17) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Icon1 = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -14, 376, 264, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Button1 = GUICtrlCreateButton("Update icon", 32, 272, 100, 25, $WS_GROUP) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetImage($Icon1, @SystemDir & "\shell32.dll", -12) GUICtrlSetData($Label1, "Why the icon moved when Label stay in his original position ? ") EndSwitch WEnd Edited January 10, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
claude21 Posted January 10, 2010 Author Share Posted January 10, 2010 Hi GUICtrlSetResizing for each controls doesn't work either, I've just run the script and the icon doesn't stay in where it should be. Any working solution ? Use the GUICtrlSetResizing() function for each control. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 413, 300, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS)) $Label1 = GUICtrlCreateLabel("icon should stay in right corner", 10, 200, 380, 17, $WS_GROUP) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Label2 = GUICtrlCreateLabel("1st maximize the window, then, click update", 10, 180, 250, 17) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Icon1 = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -14, 376, 264, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Button1 = GUICtrlCreateButton("Update icon", 32, 272, 100, 25, $WS_GROUP) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetImage($Icon1, @SystemDir & "\shell32.dll", -12) GUICtrlSetData($Label1, "Why the icon moved when Label stay in his original position ? ") EndSwitch WEnd Link to comment Share on other sites More sharing options...
martin Posted January 10, 2010 Share Posted January 10, 2010 Hi GUICtrlSetResizing for each controls doesn't work either, I've just run the script and the icon doesn't stay in where it should be. Any working solution ? Yes, that is a problem with sending that message because the design position is used to redraw the image. The fix I use is like this #include <ButtonConstants.au3>#include <GUIConstantsEx.au3>#include <StaticConstants.au3>#include <WindowsConstants.au3>#Region ### START Koda GUI section ### Form=$Form2 = GUICreate("Form1", 413, 300, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX,$WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))$Label1 = GUICtrlCreateLabel("icon should stay in right corner", 10, 200, 380, 17, $WS_GROUP)GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE))$Label2 = GUICtrlCreateLabel("1st maximize the window, then, click update", 10, 180, 250, 17)GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE))$Icon1 = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -14, 376, 264, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP))GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE))$Button1 = GUICtrlCreateButton("Update icon", 32, 272, 100, 25, $WS_GROUP)GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE))GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Local $IconPos = ControlGetPos($Form2,"",$Icon1) GUICtrlSetImage($Icon1, @SystemDir & "\shell32.dll", -12) ControlMove($Form2,"",$Icon1,$IconPOs[0],$IconPos[1]) GUICtrlSetData($Label1, "Why the icon moved when Label stay in his original position ? ") EndSwitchWEnd Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
claude21 Posted January 10, 2010 Author Share Posted January 10, 2010 Thanks Martin for your tip, it work that way (but the move cause some flickering when many icons are present) !Strangely, if I replace the function GUICtrlCreateIcon by GUICtrlCreatePic (and use some images files instead of pointing to an icon in a dll), all is working great ! the image stay in position even when the window has been maximized. The problem is that I can't use GUICtrlCreatePic because I need icons from a dll.So, it seem's the problem is with GUICtrlCreateIcon witch doesn't get informed by the new window dimensions. Is this a bug or a feature ?here the code with GUICtrlCreatePic, replace 1.gif and 2.gif with images in your path#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 353, 345, 346, 400, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS) ) $Button1 = GUICtrlCreateButton("update image", 48, 296, 75, 25, $WS_GROUP) $Pic1 = GUICtrlCreatePic(@ScriptDir & "\1.gif", 296, 288, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetImage($Pic1, @ScriptDir & "\2.gif") EndSwitch WEnd Link to comment Share on other sites More sharing options...
martin Posted January 10, 2010 Share Posted January 10, 2010 (edited) I think the problem is probably more to do with GuiCtrlSetImage than with GuiCtrlCreateIcon. Try Yashied's icons udf, like this #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "G:\icons\icons.au3";<------------------set to correct path for you #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 413, 300, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX,$WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS)) $Label1 = GUICtrlCreateLabel("icon should stay in right corner", 10, 200, 380, 17, $WS_GROUP) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Label2 = GUICtrlCreateLabel("1st maximize the window, then, click update", 10, 180, 250, 17) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Icon1 = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -14, 376, 264, 32, 32, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) $Button1 = GUICtrlCreateButton("Update icon", 32, 272, 100, 25, $WS_GROUP) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _SetIcon($Icon1, @SystemDir & "\shell32.dll", -12);<--------------works without repositioning GUICtrlSetData($Label1, "Why the icon moved when Label stay in his original position ? ") EndSwitch WEnd Edited January 10, 2010 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
claude21 Posted January 10, 2010 Author Share Posted January 10, 2010 Perhaps your right, it's more like a problem with GuiCtrlSetImage... Hopefully, it will be fixed in the future. Still, I keep the solution you provided first, because I don't want to include about 600k of useless stuff just for 1 function, and I prefer not to use udf's when possible. Thanks anyway ! 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