kenan 发表于 2011-7-8 23:38:50

我系统是xp,找了另一台xp也是这样
但在win7上试就没问题
这是为啥啊?郁闷。。。

powerofos 发表于 2011-7-8 23:53:29

回复 14# kenan

哦,是的,没仔细看。

dyd 发表于 2011-7-9 08:09:39

弄不懂啊...

夜猫猫 发表于 2011-7-9 09:49:25

还是不懂!.............

kenan 发表于 2011-7-9 21:16:27

本帖最后由 kenan 于 2011-7-9 21:37 编辑

难道没人知道这到底是什么原因吗

我自己想到的解决办法就是不注册WM_NCHITTEST和WM_MOVING,但这样窗体就不能移动了,所以再放一个跟hGUI上的png图片一样大的透明label,当$CursorInfo=label并且$CursorInfo=1就用相应的代码去移动窗体。。。。。不过这样感觉不爽。。。蛋疼。。。

kenan 发表于 2011-7-12 00:55:09

本帖最后由 kenan 于 2011-7-12 00:58 编辑

只注册WM_MOVING,_SendMessage($hGUI, $WM_SYSCOMMAND, $SC_MOVE + $HTCAPTION, 0)搞定#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <Memory.au3>
Global Const $AC_SRC_ALPHA = 1
Global Const $SC_MOVE = 0xF010
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("meiko.png")
$Width=_GDIPlus_ImageGetWidth ($hImage)
$Height=_GDIPlus_ImageGetHeight($hImage)

$about_normal= _GDIPlus_ImageLoadFromFile( "about_normal.png")
$hGUI = GUICreate(" ", 250, 250, @DesktopWidth/2-$Width/2, @DesktopHeight/2-$Height/2, BitXOR($WS_POPUP,$GUI_SS_DEFAULT_GUI),$WS_EX_LAYERED)
$GC = _GDIPlus_ImageGetGraphicsContext($hImage)
$bkbitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $GC)
$newGC = _GDIPlus_ImageGetGraphicsContext($bkbitmap)
_GDIPlus_GraphicsDrawImageRect($newGC, $hImage, 0, 0, $Width, $Height)

_GDIPlus_GraphicsDrawImageRect($newGC, $about_normal, 315, 300, 50, 50)


SetBitMap($hGUI, $bkbitmap, 255)


GUISetState()

$hGUI2 = GUICreate("", 850, 450,-1,-1,$WS_POPUP,BitOR($WS_SYSMENU,$WS_EX_LAYERED,$WS_EX_MDICHILD),$hGUI)

$Label1= GUICtrlCreateLabel("", 313,279,50,50,BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUISetBkColor(0xfffffe,$hGUI2)
_WinAPI_SetLayeredWindowAttributes($hGUI2, 0xfffffe, 255)
;~ GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUIRegisterMsg(0x0216, "WM_MOVING")
GUISetState()
While 1
                $CursorInfo = GUIGetCursorInfo($hGUI2)

                If $CursorInfo=$Label1 Then
                        
                ;Sleep(50)
                If $CursorInfo==1 Then MsgBox(0,'','')

                EndIf
                If $CursorInfo==1 Then _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_MOVE + $HTCAPTION, 0)
            If GUIGetMsg()=$GUI_EVENT_CLOSE Then Exit
WEnd


Func WM_MOVING($hWnd, $msg, $wParam, $lParam)
      $tBuffer = DllStructCreate($tagRECT, $lParam)
      $iLeft = DllStructGetData($tBuffer, "Left")
      $iTop = DllStructGetData($tBuffer, "Top")
      _WinAPI_MoveWindow($hWnd,$iLeft,$iTop,$Width,$Height)
      Return $GUI_RUNDEFMSG
EndFunc


Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    if ($hWnd = $hGUI ) and ($iMsg = $WM_NCHITTEST) then Return

EndFunc

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))
      DllStructSetData($tSize, "X", $Width)

      DllStructSetData($tSize, "Y", $Height)

      $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
页: 1 [2]
查看完整版本: WM_NCHITTEST消息问题【已解决】