AU3可以制作异形窗体吗?比如心形... 【已解决】
本帖最后由 kevinch 于 2011-6-8 13:15 编辑其他语言有制作的方法及实例,au3的还真没搜到,有高手能给个简单的例子学习下吗?{:face (396):} 使用png图片做GUI? 本帖最后由 tryhi 于 2011-6-8 12:54 编辑
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
; get height of window title and width of window frame - may be different when XP theme is ON/OFF
Global $htit = _WinAPI_GetSystemMetrics($SM_CYCAPTION)
Global $frame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)
$gui = GUICreate("Test Windows regions", 350, 210)
$btn_default = GUICtrlCreateButton("Default region", 100, 30, 150)
$btn_round = GUICtrlCreateButton("Round region", 100, 60, 150)
$btn_buble = GUICtrlCreateButton("Buble region ", 100, 90, 150)
$btn_transparent = GUICtrlCreateButton("Transparent region", 100, 120, 150)
$btn_exit = GUICtrlCreateButton("Exit", 100, 150, 150)
GUISetState(@SW_SHOW)
$pos = WinGetPos($gui) ; get whole window size (no client size defined in GUICreate)
Global $width = $pos
Global $height = $pos
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit
ExitLoop
Case $msg = $btn_default
$rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height)
_WinAPI_SetWindowRgn($gui, $rgn)
Case $msg = $btn_round
$rgn = _WinAPI_CreateRoundRectRgn(0, 0, $width, $height, $width / 3, $height / 3)
_WinAPI_SetWindowRgn($gui, $rgn)
Case $msg = $btn_buble
$rgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $width / 2, $height / 2, $width / 2, $height / 2) ; left-top
$rgn2 = _WinAPI_CreateRoundRectRgn($width / 2, 0, $width, $height / 2, $width / 2, $height / 2) ; right-top
_WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
_WinAPI_DeleteObject($rgn2)
$rgn2 = _WinAPI_CreateRoundRectRgn(0, $height / 2, $width / 2, $height, $width / 2, $height / 2) ; left-bottom
_WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
_WinAPI_DeleteObject($rgn2)
$rgn2 = _WinAPI_CreateRoundRectRgn($width / 2, $height / 2, $width, $height, $width / 2, $height / 2) ; right-bottom
_WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
_WinAPI_DeleteObject($rgn2)
$rgn2 = _WinAPI_CreateRoundRectRgn(10, 10, $width - 10, $height - 10, $width, $height) ; middle
_WinAPI_CombineRgn($rgn1, $rgn1, $rgn2, $RGN_OR)
_WinAPI_DeleteObject($rgn2)
_WinAPI_SetWindowRgn($gui, $rgn1)
Case $msg = $btn_transparent
_GuiHole($gui, 40, 40, 260, 170)
EndSelect
WEnd
; make inner transparent area but add controls
Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh)
Local $outer_rgn, $inner_rgn, $combined_rgn
$outer_rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height)
$inner_rgn = _WinAPI_CreateRectRgn($i_x, $i_y, $i_x + $i_sizew, $i_y + $i_sizeh)
$combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
_WinAPI_CombineRgn($combined_rgn, $outer_rgn, $inner_rgn, $RGN_DIFF)
_WinAPI_DeleteObject($outer_rgn)
_WinAPI_DeleteObject($inner_rgn)
_AddCtrlRegion($combined_rgn, $btn_default)
_AddCtrlRegion($combined_rgn, $btn_round)
_AddCtrlRegion($combined_rgn, $btn_buble)
_AddCtrlRegion($combined_rgn, $btn_transparent)
_AddCtrlRegion($combined_rgn, $btn_exit)
_WinAPI_SetWindowRgn($h_win, $combined_rgn)
EndFunc ;==>_GuiHole
; add control's area to given region
; respecting also window title/frame sizes
Func _AddCtrlRegion($full_rgn, $ctrl_id)
Local $ctrl_pos, $ctrl_rgn
$ctrl_pos = ControlGetPos($gui, "", $ctrl_id)
$ctrl_rgn = _WinAPI_CreateRectRgn($ctrl_pos + $frame, $ctrl_pos + $htit + $frame, _
$ctrl_pos + $ctrl_pos + $frame, $ctrl_pos + $ctrl_pos + $htit + $frame)
_WinAPI_CombineRgn($full_rgn, $full_rgn, $ctrl_rgn, $RGN_OR)
_WinAPI_DeleteObject($ctrl_rgn)
EndFunc ;==>_AddCtrlRegion是这种么?引自帮助中的例子 回复 3# tryhi
相当强大,学习了,呵呵~~加个皮肤一定会PL得不得了~ 回复 3# tryhi
能提供一下您的winapi.au3文件吗,我这里没运行起来,似乎我的winapi.au3文件太旧了。 谢谢楼主分享啊! 有点意思,学习了。。。。 很强大,收藏了 应该可以的,貌似 很强大 回复tryhi
能提供一下您的winapi.au3文件吗,我这里没运行起来,似乎我的winapi.au3文件太旧了。
kevinch 发表于 2011-6-8 07:05 http://www.autoitx.com/images/common/back.gif
回复 10# tryhi
多谢帮助,我下载了最新的au3程序,终于可以看到了,强大,我会好好学习这段代码,再次感谢! 回复tryhi
多谢帮助,我下载了最新的au3程序,终于可以看到了,强大,我会好好学习这段代码,再次感谢! ...
kevinch 发表于 2011-6-8 13:14 http://www.autoitx.com/images/common/back.gif
客气了 回复 3# tryhi
海大厉害!!!学习了 回复tryhi
海大厉害!!!学习了
komaau3 发表于 2011-6-9 23:03 http://www.autoitx.com/images/common/back.gif
这是帮助里的{:face (396):} 海兄,支持你
页:
[1]
2