다른 명령
새 문서: <source lang=autoit> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> ; GUI 생성 (창 크기 조절 가능하도록 스타일 설정) Local $hGUI = GUICreate("Resizable GUI Example", 600, 400, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION)) ; Edit 컨트롤 생성 (창의 대부분을 차지하도록 설정) Local $hEdit = GUICtrlCreateEdit("", 10, 10, 580, 320, $ES_MULTILINE + $WS_VSCROLL) GUICtrlSetFont($hEdit, 10, 400, 0, "Con... |
편집 요약 없음 |
||
| (같은 사용자의 중간 판 하나는 보이지 않습니다) | |||
| 1번째 줄: | 1번째 줄: | ||
== 방법1 == | |||
<source lang=autoit> | |||
#include <GUIConstantsEx.au3> | |||
#include <WindowsConstants.au3> | |||
; Create the main GUI with resizable properties | |||
Local $hGUI = GUICreate("Resizable GUI Example", 600, 400, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION)) | |||
; Create an Edit control and Button control | |||
Local $hEdit = GUICtrlCreateEdit("", 10, 10, 580, 300, $ES_MULTILINE + $WS_VSCROLL) | |||
Local $hButton = GUICtrlCreateButton("Submit", 250, 330, 100, 30) | |||
; Show the GUI | |||
GUISetState(@SW_SHOW) | |||
; Get initial GUI dimensions for reference | |||
Local $iGUIWidth = 600 | |||
Local $iGUIHeight = 400 | |||
; Main loop to handle GUI events | |||
While True | |||
Switch GUIGetMsg() | |||
Case $GUI_EVENT_CLOSE | |||
ExitLoop | |||
Case $GUI_EVENT_RESIZED | |||
; Get the new size of the GUI | |||
Local $iNewWidth = WinGetPos($hGUI)[2] | |||
Local $iNewHeight = WinGetPos($hGUI)[3] | |||
; Resize the Edit control to maintain margin | |||
GUICtrlSetPos($hEdit, 10, 10, $iNewWidth - 20, $iNewHeight - 90) | |||
; Adjust the Button position based on new GUI height | |||
GUICtrlSetPos($hButton, ($iNewWidth - 100) / 2, $iNewHeight - 60, 100, 30) | |||
EndSwitch | |||
WEnd | |||
GUIDelete($hGUI) | |||
Exit | |||
</source> | |||
== 방법2 == | |||
<source lang=autoit> | <source lang=autoit> | ||
#include <GUIConstantsEx.au3> | #include <GUIConstantsEx.au3> | ||
| 50번째 줄: | 93번째 줄: | ||
EndFunc | EndFunc | ||
</source> | </source> | ||
[[category:autoit]] | |||
2025년 5월 20일 (화) 06:22 기준 최신판
방법1
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; Create the main GUI with resizable properties
Local $hGUI = GUICreate("Resizable GUI Example", 600, 400, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION))
; Create an Edit control and Button control
Local $hEdit = GUICtrlCreateEdit("", 10, 10, 580, 300, $ES_MULTILINE + $WS_VSCROLL)
Local $hButton = GUICtrlCreateButton("Submit", 250, 330, 100, 30)
; Show the GUI
GUISetState(@SW_SHOW)
; Get initial GUI dimensions for reference
Local $iGUIWidth = 600
Local $iGUIHeight = 400
; Main loop to handle GUI events
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $GUI_EVENT_RESIZED
; Get the new size of the GUI
Local $iNewWidth = WinGetPos($hGUI)[2]
Local $iNewHeight = WinGetPos($hGUI)[3]
; Resize the Edit control to maintain margin
GUICtrlSetPos($hEdit, 10, 10, $iNewWidth - 20, $iNewHeight - 90)
; Adjust the Button position based on new GUI height
GUICtrlSetPos($hButton, ($iNewWidth - 100) / 2, $iNewHeight - 60, 100, 30)
EndSwitch
WEnd
GUIDelete($hGUI)
Exit
방법2
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
; GUI 생성 (창 크기 조절 가능하도록 스타일 설정)
Local $hGUI = GUICreate("Resizable GUI Example", 600, 400, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION))
; Edit 컨트롤 생성 (창의 대부분을 차지하도록 설정)
Local $hEdit = GUICtrlCreateEdit("", 10, 10, 580, 320, $ES_MULTILINE + $WS_VSCROLL)
GUICtrlSetFont($hEdit, 10, 400, 0, "Consolas")
; 버튼 생성
Local $hButton = GUICtrlCreateButton("Click Me", 250, 340, 100, 30)
; GUI 표시
GUISetState(@SW_SHOW, $hGUI)
; WM_SIZE 메시지를 처리하기 위해 메시지 등록
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
; 메시지 루프
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
GUIDelete($hGUI)
Exit
; WM_SIZE 메시지 처리 함수
Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
; 새로운 창 크기 가져오기
Local $iWidth = BitAND($lParam, 0xFFFF) ; LOWORD
Local $iHeight = BitShift($lParam, -16) ; HIWORD
; Edit 컨트롤 크기 조정
ControlMove($hGUI, "", $hEdit, 10, 10, $iWidth - 20, $iHeight - 80)
; 버튼 위치 조정 (가운데 정렬)
Local $iButtonWidth = 100
Local $iButtonHeight = 30
Local $iButtonX = ($iWidth - $iButtonWidth) / 2
Local $iButtonY = $iHeight - 40
ControlMove($hGUI, "", $hButton, $iButtonX, $iButtonY, $iButtonWidth, $iButtonHeight)
Return $GUI_RUNDEFMSG
EndFunc