Обычным способом иконка в кнопку устанавливается в центре
А можно ли иконку в кнопке установить с краю кнопки скажем перед названием
Извиняюсь этот пример был в теме "Как раздвинуть окно"
этот пример был в теме "Как раздвинуть окно" »
Если в этой теме нет решения, то кому она будет полезна, да ещё и с пометкой [решено]?
Вот решение:
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIButton.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIImageList.au3>
Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $hImageList = _GUIImageList_Create (http://dundats.mvps.org/help/html/libfunctions/_guiimagelist_create.htm)(16, 16, 5, 1)
$hGUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)("_GUICtrlButton_SetImageEx Example", 350, 200)
$nButton = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("Ok", 20, 170, 80, 22, $BS_ICON)
_GUICtrlButton_SetImageEx($hImageList, $nButton, @SystemDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@systemdir) & "\rasdlg.dll", 1)
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)()
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$Msg = GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)()
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $Msg
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
_GUIImageList_Destroy (http://dundats.mvps.org/help/html/libfunctions/_guiimagelist_destroy.htm)($hImageList)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $nButton
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) GUICtrlRead (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlRead.htm)($nButton) = "Ok" Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($nButton, "Cancel")
_GUICtrlButton_SetImageEx($hImageList, $nButton, @SystemDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@systemdir) & "\rasdlg.dll", 0)
Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($nButton, "Ok")
_GUICtrlButton_SetImageEx($hImageList, $nButton, @SystemDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@systemdir) & "\rasdlg.dll", 1)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
_WinAPI_RedrawWindow (http://dundats.mvps.org/help/html/libfunctions/_winapi_redrawwindow.htm)($hGUI)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _GUICtrlButton_SetImageEx($hImageList, $nCtrl, $sIconFile, $nIconID=0, $nAlign=-1)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) _GUIImageList_GetImageCount (http://dundats.mvps.org/help/html/libfunctions/_guiimagelist_getimagecount.htm)($hImageList) > 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$tIcon = DllStructCreate (http://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm)("int Icon")
_WinAPI_ExtractIconEx (http://dundats.mvps.org/help/html/libfunctions/_winapi_extracticonex.htm)($sIconFile, $nIconID, 0, DllStructGetPtr (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetPtr.htm)($tIcon), 1)
$hIcon = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tIcon, "Icon")
_GUIImageList_ReplaceIcon (http://dundats.mvps.org/help/html/libfunctions/_guiimagelist_replaceicon.htm)($hImageList, 0, $hIcon)
_WinAPI_DestroyIcon (http://dundats.mvps.org/help/html/libfunctions/_winapi_destroyicon.htm)($hIcon)
Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
_GUIImageList_AddIcon (http://dundats.mvps.org/help/html/libfunctions/_guiimagelist_addicon.htm)($hImageList, $sIconFile, $nIconID)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) _GUICtrlButton_SetImageList (http://dundats.mvps.org/help/html/libfunctions/_guictrlbutton_setimagelist.htm)($nCtrl, $hImageList, $nAlign)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.