找回密码
 加入
搜索
查看: 3770|回复: 1

[GUI管理] 求救 $WS_EX_MDICHILD为什么不能用(自己解决了)[已解决]

[复制链接]
发表于 2011-7-30 21:44:08 | 显示全部楼层 |阅读模式
本帖最后由 seniors 于 2011-7-30 22:44 编辑

问题情况说明
下面代码是从文白发表的天气预报中提取的代码
文白的天气预报可以从http://whenbye.com/?cat=1下载
我的代码如下,第9行中$WS_EX_MDICHILD去掉二幅图片多能出来 ,但是加上就只能出背景
文白的有$WS_EX_MDICHILD但是图片多能出来,闷啊,谢谢各位高手帮我看看代码哪里出错了
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GdiPlus.au3>

GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUIRegisterMsg($WM_NCLBUTTONDOWN, 'WM_NCLBUTTONDOWN')
$gui = GUICreate("1234", 305, 175, -1, @DesktopHeight - 250, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$kzgui = GUICreate("123", 20, 20, -1, @DesktopHeight - 198, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED, $WS_EX_TOPMOST), $gui)

Global $g_Dw_UI_Close_LeftMouseDown = False
_GDIPlus_Startup()

Global $hBitmap = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\back.png")
SetBitmap($gui, $hBitmap, 255)

Global $hImage1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\DeskLyricPng\Lock.png")
SetBitmap($kzgui, $hImage1, 127)

GUISetState(@SW_SHOW, $gui)
GUISetState(@SW_SHOW, $kzgui)

While 1
        $gMsg = GUIGetMsg()
        Switch $gMsg
                Case $GUI_EVENT_CLOSE
                        If $g_Dw_UI_Close_LeftMouseDown Then exitfunc()
        EndSwitch
WEnd

Func exitfunc()
        _GDIPlus_ImageDispose($hImage1)
        _GDIPlus_ImageDispose($hBitmap)
        _GDIPlus_Shutdown()
        GUIDelete($gui)
        GUIDelete($kzgui)
        Exit
EndFunc   ;==>exitfunc

Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
        Switch $hWnd
                Case $gui
                        If $g_Dw_UI_Close_LeftMouseDown Then $g_Dw_UI_Close_LeftMouseDown = False
                        SetBitmap($kzgui, $hImage1, 127)
                        Return $HTCAPTION
                Case $kzgui
                        If $g_Dw_UI_Close_LeftMouseDown Then
                                _SendMessage($gui, $WM_SYSCOMMAND, 0xF060, 0)
                        EndIf
                        SetBitmap($kzgui, $hImage1, 255)
                        Return $HTCLOSE
        EndSwitch
EndFunc   ;==>WM_NCHITTEST

Func WM_NCLBUTTONDOWN($hWnd, $Msg, $wParam, $lParam)
        Switch $hWnd
                Case $kzgui
                        If $wParam = $HTCLOSE Then
                                $g_Dw_UI_Close_LeftMouseDown = True
                        EndIf
        EndSwitch
EndFunc   ;==>WM_NCLBUTTONDOWN

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", 1)
        _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
 楼主| 发表于 2011-7-30 22:43:46 | 显示全部楼层
找到原因了,原来是第9行的代码有问题
应该是-1, @DesktopHeight - 198,这里有错
这个座标应该是相对于父窗口的,而我用了相对于屏幕
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-1 06:54 , Processed in 0.109068 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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