enaiman Posted September 29, 2010 Share Posted September 29, 2010 (edited) I've just noticed this behaviour - what can I do to keep the icons there? Sample script: #include <GuiConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Global $hGUI, $hStatus Global $aParts[4] = [75, 150, 300, 400] $hGUI = GUICreate("", 400, 300, 193, 124, $WS_SIZEBOX) $hStatus = _GUICtrlStatusBar_Create ($hGUI) GUISetState(@SW_SHOW) ; Set parts _GUICtrlStatusBar_SetParts ($hStatus, $aParts) _GUICtrlStatusBar_SetText ($hStatus, "Part 1") _GUICtrlStatusBar_SetText ($hStatus, "Part 2", 1) ; Set icons _GUICtrlStatusBar_SetIcon ($hStatus, 0, 23, "shell32.dll") _GUICtrlStatusBar_SetIcon ($hStatus, 1, 40, "shell32.dll") ; Loop until user exits GUIRegisterMsg($WM_SIZE, "WM_SIZE") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) _GUICtrlStatusBar_Resize ($hStatus) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Thanks, Edited October 3, 2010 by enaiman SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
enaiman Posted October 3, 2010 Author Share Posted October 3, 2010 Wow - I got so many answers I had a hard time figuring the best one Just kidding It looks like this part of the forum is different than the General Help and it is not watched so closely. Well, I have found a solution; if I am not wrong, martin had this idea and it is working. I am posting the updated script; maybe somebody else will benefit out of this. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <Constants.au3> Global $hGUI, $hStatus Global $aParts[4] = [75, 150, 300, 400] $hGUI = GUICreate("", 400, 300, 193, 124, $WS_SIZEBOX) $hStatus = _GUICtrlStatusBar_Create ($hGUI) GUISetState(@SW_SHOW) ; Set parts _GUICtrlStatusBar_SetParts ($hStatus, $aParts) _GUICtrlStatusBar_SetText ($hStatus, "Part 1") _GUICtrlStatusBar_SetText ($hStatus, "Part 2", 1) ; Set icons _GUICtrlStatusBar_SetIcon ($hStatus, 0, 23, "shell32.dll") _GUICtrlStatusBar_SetIcon ($hStatus, 1, 40, "shell32.dll") ; Loop until user exits $wProcNew = DllCallbackRegister("_StatusBarWindowProc", "int", "hwnd;uint;wparam;lparam") $wProcOld = _WinAPI_SetWindowLong($hStatus, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew)) GUIRegisterMsg($WM_SIZE, "WM_SIZE") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) _GUICtrlStatusBar_Resize ($hStatus) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func _StatusBarWindowProc($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) Switch $Msg Case $WM_NCPAINT _RefreshIcons() EndSwitch Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam) EndFunc ;==>_NewWindowProc Func _RefreshIcons() _GUICtrlStatusBar_SetIcon ($hStatus, 0, 23, "shell32.dll") _GUICtrlStatusBar_SetIcon ($hStatus, 1, 40, "shell32.dll") EndFunc For others jumping with better solutions: ... ... too late. All good. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
ProgAndy Posted October 4, 2010 Share Posted October 4, 2010 The problem is the function _GUICtrlStatusBar_SetIcon. It loads the ucon from the dll, and sets it to the status bar. But then the icon is released, so the bar can't repaint it lateron. Using a custom func for extracting solves the problem: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <Constants.au3> Global $hGUI, $hStatus Global $aParts[4] = [75, 150, 300, 400] $hGUI = GUICreate("", 400, 300, 193, 124, $WS_SIZEBOX) $hStatus = _GUICtrlStatusBar_Create ($hGUI) GUISetState(@SW_SHOW) ; Set parts _GUICtrlStatusBar_SetParts ($hStatus, $aParts) _GUICtrlStatusBar_SetText ($hStatus, "Part 1") _GUICtrlStatusBar_SetText ($hStatus, "Part 2", 1) ; Load Icons Global $hFirstIcon = _ExtractIcon("shell32.dll", 23) Global $hSecondIcon = _ExtractIcon("shell32.dll", 40) OnAutoItExitRegister("_FreeIcons") ; Set icons _GUICtrlStatusBar_SetIcon ($hStatus, 0, $hFirstIcon) _GUICtrlStatusBar_SetIcon ($hStatus, 1, $hSecondIcon) GUIRegisterMsg($WM_SIZE, "WM_SIZE") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) _GUICtrlStatusBar_Resize ($hStatus) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func _ExtractIcon($sFile, $iIndex) Local $tIcon = DllStructCreate("ptr") If Not _WinAPI_ExtractIconEx($sFile, $iIndex, 0, DllStructGetPtr($tIcon), 1) Then Return SetError(1,0,0) Return DllStructGetData($tIcon,1) EndFunc Func _FreeIcons() _WinAPI_DestroyIcon($hFirstIcon) _WinAPI_DestroyIcon($hSecondIcon) 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...
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