02-Nov-09
Deprecated.
The library contains three basic functions. I always use these functions and decided to share them with the community. I hope that to some of you they will be useful. To understand why this is done, please look at my examples.
![]()
History
Spoiler
1.8
1.7
1.6
1.5
1.8
- Updated the reducing flicker algorithm - _Icons_Control_Update(), now the upper windows will be redrawn.
- Improved performance for all main functions.
- Added one new example to benchmark the reducing flicker algorithm.
- Fixed few minor bugs.
1.7
- Completely rewritten the internal code of the library.
- ]$fErase parameter replaced to $hOverlap that makes the opposite effect. (See description)
- All the internal functions have been renamed.
- Added some internal functions. (See expamples 5 and 6)
- Function _Icons_Icon_Merge() (formerly _Icons_CombineIcon()) now works with icon handles.
- Improved performance for the _SetCombineBkIcon() function.
- Added two new examples.
1.6
- Added compatibility with the MrCreatoR's GUICtrlSetOnHover UDF Library. (See GUICtrlSetOnHover & Icons UDFs Demonstration below)
- Added mode to reduce flickering when changing images in the controls.
- Added parameter $fErase for all functions. Because the reduce flickering mode is enabled by default, but in some cases it must be disabled. (See example 4)
- Fixed bug consists in the wrong determinates the size of controls after cleaning their by using _SetImage($hWnd, "") or _SetHImage($hWnd, 0) functions.
- Fixed bug consists in the wrong determinates the background color of the icons in _SetCombineBkIcon() function if the window is invisible.
- Internal _Icons_SetImage() function is completely rewritten and improved.
- Slightly improved performance.
1.5
- Added resizing image, depending on the size of control. (Thanks wraithdu, Post #19)
- Added some new opportunities for _SetCombineBkIcon() function. See description inside the library.
- Now you can use the one handle for the few controls. _SetHIcon() and _SetHImage() function makes a copy of HIcon and HBitmap handles.
- Added the ability to automatically determine the background color of the window for the _SetCombineBkIcon() function.
- Fixed bug consists in the wrong value of the $SS_BITMAP constant. (Thanks wraithdu, Post #17)
- Fixed bug consists in memory leaks when using _SetImage() and _SetHImage() functions. (Thanks wraithdu, Post #28)
- Fixed bug consists in unnecessary to convert the values for the style.
- The code was completely rewritten and improved.
- Added four new examples.
Icons UDF Library v1.8
(Previous downloads: 1268)
Icons.au3 42K
3215 downloadsExample
Spoiler
AutoIt
#Include <GUIConstantsEx.au3> #Include <Icons.au3> Global Const $sPng = RegRead('HKLMSOFTWAREAutoIt v3AutoIt', 'InstallDir') & 'ExamplesGUIAdvancedImagesTorus.png' Global Const $sJpg = @TempDir & '~wallpaper.jpg' Global Const $sGreen = @TempDir & '~green.png' Global Const $sRed = @TempDir & '~red.png' Global Const $sLogo = @TempDir & '~logo.png' Example1() Example2() Example3() Example4() Example5() Example6() Example7() Func Example1() GUICreate('Example1', 204, 108) $Icon1 = GUICtrlCreateIcon('', 0, 30, 38, 32, 32) $Icon2 = GUICtrlCreateIcon('', 0, 88, 38, 32, 32) $Icon3 = GUICtrlCreateIcon('', 0, 146, 38, 32, 32) GUISetState() _SetCombineBkIcon($Icon1, -1, @SystemDir & 'shell32.dll', 70, 32, 32, @SystemDir & 'shell32.dll', 22, 24, 24, 0, 8) _SetCombineBkIcon($Icon2, -1, @SystemDir & 'shell32.dll', 3, 32, 32, @SystemDir & 'shell32.dll', 28, 32, 32) _SetCombineBkIcon($Icon3, -1, @SystemDir & 'shell32.dll', 220, 32, 32, @SystemDir & 'shell32.dll', 29, 32, 32) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example1 Func Example2() GUICreate('Example2', 216, 128) $Icon = GUICtrlCreateIcon('', 0, 40, 40, 48, 48) GUICtrlCreateIcon(@WindowsDir & 'explorer.exe', 0, 128, 40, 48, 48) GUISetState() _SetIcon($Icon, @WindowsDir & 'explorer.exe', 0, 48, 48) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example2 Func Example3() GUICreate('Example3', 715, 388) $Pic1 = GUICtrlCreatePic('', 10, 10, 386, 368) $Pic2 = GUICtrlCreatePic('', 406, 10, 193, 184) $Pic3 = GUICtrlCreatePic('', 609, 10, 96, 92) GUISetState() _SetImage($Pic1, $sPng) _SetImage($Pic2, $sPng) _SetImage($Pic3, $sPng) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example3 Func Example4() GUICreate('Example4', 253, 244) $Pic1 = GUICtrlCreatePic('', 10, 10, 193, 184) $Pic2 = GUICtrlCreatePic('', 60, 60, 193, 184) GUISetState() _SetImage($Pic2, $sPng) _SetImage($Pic1, $sPng) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example4 Func Example5() Local $aIndex[10] = [4, 13, 23, 31, 86, 104, 130, 150, 168, 170] GUICreate('Example5', 600, 400) $Pic = GUICtrlCreatePic('', 0, 0, 600, 400) For $i = 1 To UBound($aIndex) GUICtrlCreatePic('', Random(0, 600 - 48, 1), Random(0, 400 - 48, 1), 48, 48) $hIcon = _Icons_Icon_Extract(@SystemDir & 'shell32.dll', $aIndex[$i - 1], 48, 48) $hBitmap = _Icons_Bitmap_CreateFromIcon($hIcon) _SetHImage($Pic + $i, $hBitmap) _WinAPI_DeleteObject($hBitmap) _WinAPI_DestroyIcon($hIcon) Next GUISetState() InetGet('http://dota.ru/3d/big/p324_42.jpg', $sJpg) $hBitmap = _Icons_Bitmap_Load($sJpg) $hArea = _Icons_Bitmap_Crop($hBitmap, 420, 320, 600, 400) _SetHImage($Pic, $hArea) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hArea) FileDelete($sJpg) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example5 Func Example6() GUICreate('Example6', 800, 500) $Background = GUICtrlCreatePic('', 0, 0, 800, 500) GUICtrlSetState(-1, $GUI_DISABLE) $Button = GUICtrlCreateButton('Test', 355, 460, 90, 23) $Pic1 = GUICtrlCreatePic('', 102, 122, 256, 256) $Pic2 = GUICtrlCreatePic('', 442, 122, 256, 256) GUISetState() InetGet('http://autoit.rv.ua/files/Pictures/icons_ex_back.jpg', $sJpg) InetGet('http://autoit.rv.ua/files/Pictures/icons_ex_green.png', $sGreen) InetGet('http://autoit.rv.ua/files/Pictures/icons_ex_red.png', $sRed) _SetImage($Background, $sJpg) $hGreen = _Icons_Bitmap_Load($sGreen) $hRed = _Icons_Bitmap_Load($sRed) _SetHImage($Pic1, $hRed) _SetHImage($Pic2, $hRed) FileDelete($sJpg) FileDelete($sGreen) FileDelete($sRed) $pCtrlID = 0 While 1 $Cursor = GUIGetCursorInfo() If @error Then ContinueLoop EndIf $nCtrlID = $Cursor[4] If $nCtrlID <> $pCtrlID Then Switch $pCtrlID Case $Pic1 _SetHImage($Pic1, $hRed) Case $Pic2 _SetHImage($Pic2, $hRed, -1) EndSwitch Switch $nCtrlID Case $Pic1 _SetHImage($Pic1, $hGreen) Case $Pic2 _SetHImage($Pic2, $hGreen, -1) EndSwitch $pCtrlID = $nCtrlID EndIf $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Button GUICtrlSetState($Button, $GUI_DISABLE) For $i = 1 To 50 GUIGetMsg() _SetHImage($Pic1, $hGreen) _SetHImage($Pic2, $hGreen, -1) Sleep(50) _SetHImage($Pic1, $hRed) _SetHImage($Pic2, $hRed, -1) Sleep(50) Next GUICtrlSetState($Button, $GUI_ENABLE) EndSwitch WEnd GUIDelete() EndFunc ;==>Example6 Func Example7() GUICreate('Example7', 400, 93) $Pic = GUICtrlCreatePic('', 0, 0, 400, 93) $hIcon = _Icons_Icon_Extract(@SystemDir & 'shell32.dll', 86, 24, 24) $hBitmap = _Icons_Bitmap_CreateFromIcon($hIcon) For $i = 1 To 5 GUICtrlCreatePic('', 258 + ($i - 1) * 28, 12, 24, 24) _SetHImage($Pic + $i, $hBitmap) Next _WinAPI_DeleteObject($hBitmap) _WinAPI_DestroyIcon($hIcon) GUISetState() InetGet('http://www.autoitscript.com/forum/public/style_images/autoit/logo.png', $sLogo) $hBitmap = _Icons_Bitmap_Load($sLogo) $hArea = _Icons_Bitmap_Crop($hBitmap, 0, 7, 400, 93) _SetHImage($Pic, $hArea) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hArea) FileDelete($sLogo) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example7
GUICtrlSetOnHover & Icons UDFs Demonstration
Icons_Hover.zip
Edited by Yashied, 20 March 2012 - 11:41 PM.








