找回密码
 加入
搜索
查看: 3182|回复: 4

[GUI管理] 请教用PNG做透明菜单的几个问题!

  [复制链接]
发表于 2012-1-5 12:46:42 | 显示全部楼层 |阅读模式
父窗口中的子窗口如何取得它的点击等动作?
如何当点显示桌面之后,透明的窗口不最小化?
参照论坛里的透明菜单,他的点击是取得鼠标移到那里是否是那个控件ID,是的话再执行动作
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#include <Timers.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 214, 408, 621, 332);, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle("[Class:Progman;Title:Program Manager]"))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


Global Const $AC_SRC_ALPHA = 1
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("联络聊天.PNG")
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)

$Form2 = GUICreate("窗体1", $width, $height, 639, 374,  $WS_POPUP, $WS_EX_LAYERED,$Form1)
GUISetCursor(0)
;$Form2 = GUICreate("窗体1", 175, 141, 639, 374)
;$Label1 = GUICtrlCreateLabel("Label1", 0, $height, $width, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
;GUICtrlSetBkColor($Label1, $GUI_BKCOLOR_TRANSPARENT)
;GUICtrlSetColor($Label1, 0xFFFFFF) ;字体颜色
;$Input1 = GUICtrlCreateInput("Input1", 120, 32, 121, 21)
;$Button1 = GUICtrlCreateButton("Button1", 80, 128, 75, 25)
;MsgBox(0,$width,$height)

SetBitmap($Form2, $hImage, 255)
GUISetState(@SW_SHOW)



While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $GUI_EVENT_MINIMIZE
                        ;MsgBox(0,"","")
                        ;GUISetState(@SW_RESTORE)
                Case $GUI_EVENT_PRIMARYUP
                        MsgBox(0,"","")
        EndSwitch
WEnd
 
Func SetBitmap($hGUI, $hImage, $iOpacity)
        Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
        $hScrDC = _WinAPI_GetDC(0)
        $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
        $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
        $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
        $tSize = DllStructCreate($tagSIZE)
        $pSize = DllStructGetPtr($tSize)
        DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
        DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
        $tSource = DllStructCreate($tagPOINT)
        $pSource = DllStructGetPtr($tSource)
        $tBlend = DllStructCreate($tagBLENDFUNCTION)
        $pBlend = DllStructGetPtr($tBlend)
        DllStructSetData($tBlend, "Alpha", $iOpacity)
        DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
        _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
        _WinAPI_ReleaseDC(0, $hScrDC)
        _WinAPI_SelectObject($hMemDC, $hOld)
        _WinAPI_DeleteObject($hBitmap)
        _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap
发表于 2012-1-5 12:54:51 | 显示全部楼层
最好连所需的图片也上传来!
 楼主| 发表于 2012-1-5 12:59:50 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-1-5 14:22:00 | 显示全部楼层
上图演示就更好了
发表于 2012-1-5 21:22:39 | 显示全部楼层
检测鼠标位置是针对主窗口自绘控件的事件,子窗口的直接onevent模式就行了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 13:43 , Processed in 0.081982 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表