【已解决】无边框,自己添加最大最小化按钮
本帖最后由 影子 于 2012-4-18 22:51 编辑如题,请问大侠怎么弄,新手!举个例子最好,谢谢! 放两按钮.
事件为相应代码
哦,初级自学,可以举例吗,谢谢
回复 2# 星雨朝霞 本帖最后由 wua0550 于 2012-4-18 17:00 编辑下面是例子
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$hForm = GUICreate("无边筐", 404, 149, -1, -1, $WS_SYSMENU, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST))
$Button1 = GUICtrlCreateButton("最大化", 311, 11, 75, 23)
$Button2 = GUICtrlCreateButton("最小化", 200, 11, 75, 23)
GUISetState()
While 1
Switch GUIGetMsg()
Case $Button1
WinSetState($hForm, "", @SW_MAXIMIZE)
Case $Button2
WinSetState($hForm, "", @SW_MINIMIZE)
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars", 1)
#Region ### START Koda GUI section ### Form=
Global $Form = GUICreate("Form1", 363, 92, 538, 188)
Global $Button1 = GUICtrlCreateButton("最小化", 80, 24, 75, 25)
Global $Button2 = GUICtrlCreateButton("最大化", 224, 24, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
Sleep(100)
WEnd
Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
Local Const $SC_MOVE = 0xF010
Local Const $SC_SIZE = 0xF000
Local Const $SC_CLOSE = 0xF060
If $hWnd = $Form Then
Switch BitAND($wParam, 0xFFF0)
Case $SC_CLOSE
Exit
EndSwitch
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SYSCOMMAND
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0x0000FFFF)
Local $hCtrl = $lParam
Switch $hCtrl
Case GUICtrlGetHandle($Button1)
If $nNotifyCode = $BN_CLICKED Then
GUISetState(@SW_MINIMIZE,$Form)
EndIf
Case GUICtrlGetHandle($Button2)
If $nNotifyCode = $BN_CLICKED Then
GUISetState(@SW_MAXIMIZE,$Form)
EndIf
EndSwitch
EndFunc ;==>WM_COMMAND 本帖最后由 xiehuahere 于 2012-4-18 17:24 编辑
传送门:http://www.autoitx.com/forum.php?mod=viewthread&tid=29256&extra=&page=1
方法类似。 #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Local $Form1 = GUICreate("Form1", 623, 442, 192, 150,BitOR($WS_POPUP,$WS_CLIPSIBLINGS,$WS_SYSMENU))
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
Local $Button1 = GUICtrlCreateButton('最小化', 623-75*3, 0, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
Local $Button2 = GUICtrlCreateButton('最大化', 623-75*2, 0, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
Local $Button3 = GUICtrlCreateButton('关闭', 623-75, 0, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func Button1Click()
Switch @GUI_CtrlId
Case $Button1
WinSetState($Form1,'',@SW_MINIMIZE)
Case $Button2
$State=WinGetState($Form1)
If $State=15 Then
WinSetState($Form1,'',@SW_MAXIMIZE)
Else
WinSetState($Form1,'',@SW_RESTORE)
EndIf
Case $Button3
Exit
EndSwitch
EndFunc
Func Form1Close()
Exit
EndFunc ls各位已经给出例子了,简单的思路,创建3个按钮,分别设置 最小化、最大化、关闭 动作。
页:
[1]