Function Reference

_GUICtrlButton_GetIdealSize

ボタンのテキストと、画像リストが存在する場合はその画像に最適のボタンのサイズを取得します。

#Include <GuiButton.au3>
_GUICtrlButton_GetIdealSize($hWnd)

 

パラメータ

$hWnd コントロールのハンドル

 

返し値

次の配列を返します:
        [0] - 理想の幅
        [1] - 理想の高さ

 

注意

必須OS: Windows XP以降

 

関連

_GUICtrlButton_SetSize

 

こちらも参照

MSDNライブラリでBCM_GETIDEALSIZEを検索して下さい。

 


#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>

Opt("MustDeclareVars", 1)

Global $iMemo

_Main()

Func _Main()
    Local $hImage, $btn, $aIdealSize

    GUICreate("Buttons", 400, 400)
    $iMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")

    $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImage, "shell32.dll", $x, True)
    Next

    $btn = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetImageList($btn, $hImage)

    GUISetState()

    $aIdealSize = _GUICtrlButton_GetIdealSize($btn)
    MemoWrite("Button1 Ideal width: " & $aIdealSize[0] & " height: " & $aIdealSize[1])
   
    Sleep(3000)
   
    MemoWrite(StringFormat("Set Size: %s", _GUICtrlButton_SetSize($btn, $aIdealSize[0], $aIdealSize[1])))
   
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>_Main

; メモコントロールに1行書き込み
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite