Jump to content

Problem with WM_MOVE !


MrVietA2
 Share

Recommended Posts

Hi all !

I created a script, it has two GUI : One was Main, one was child, and I put the child GUI in the Tab control :

#include 
#include 

_Main()

Func _Main()
Global $iX_Min = 0, $iX_Max = @DesktopWidth - 500, $iY_Min = 0, $iY_Max = @DesktopHeight - 500

$hGUI = GUICreate("Test", 500, 500)
$Tab = GUICtrlCreateTab(16, 16, 450, 450)
Global $ViewerVideo = GUICreate("K Muzik Viewer Video", 250, 250, 20, 50, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_DISABLED, $WS_EX_MDICHILD), $hGUI )
GUISetBkColor(0x00000, $ViewerVideo)
WinSetTrans($ViewerVideo, "", 220)


GUISetState(@SW_SHOW, $ViewerVideo)
GUISetState(@SW_SHOW, $hGUI)

GUIRegisterMsg($WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING")

While 1

Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch

WEnd
EndFunc

Func WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)
Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam)

Local $iLeft = DllStructGetData($stWinPos, 3)
Local $iTop = DllStructGetData($stWinPos, 4)
Local $iWidth = DllStructGetData($stWinPos, 5)
Local $iHeight = DllStructGetData($stWinPos, 6)

If $iLeft < $iX_Min Then DllStructSetData($stWinPos, 3, $iX_Min)
If $iTop < $iY_Min Then DllStructSetData($stWinPos, 4, $iY_Min)
If $iLeft > $iX_Max Then DllStructSetData($stWinPos, 3, $iX_Max)
If $iTop > $iY_Max Then DllStructSetData($stWinPos, 4, $iY_Max)

EndFunc

If I move main GUI to the right of the screen, then child GUI will be have wrong position. This also display if I move main GUI to the bottom of the screen. Please help me to resolve this problem, thank you !

Link to comment
Share on other sites

Try this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $hGUI, $iX_Min = 0, $iX_Max = @DesktopWidth - 500, $iY_Min = 0, $iY_Max = @DesktopHeight - 500
Global $ViewerVideo

_Main()

Func _Main()
    $hGUI = GUICreate("Test", 500, 500)
    $Tab = GUICtrlCreateTab(16, 16, 450, 450)

    $ViewerVideo = GUICreate("K Muzik Viewer Video", 250, 250, 20, 50, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_DISABLED, $WS_EX_MDICHILD), $hGUI)
    GUISetBkColor(0x00000, $ViewerVideo)
    WinSetTrans($ViewerVideo, "", 220)


    GUISetState(@SW_SHOWNOACTIVATE, $ViewerVideo)
    GUISetState(@SW_SHOW, $hGUI)

    GUIRegisterMsg($WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING")

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch

    WEnd
EndFunc   ;==>_Main

Func WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)
    If $hWnd = $hGUI Then
        Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam)

        Local $iLeft = DllStructGetData($stWinPos, 3)
        Local $iTop = DllStructGetData($stWinPos, 4)
        Local $iWidth = DllStructGetData($stWinPos, 5)
        Local $iHeight = DllStructGetData($stWinPos, 6)

        If $iLeft < $iX_Min Then DllStructSetData($stWinPos, 3, $iX_Min)
        If $iTop < $iY_Min Then DllStructSetData($stWinPos, 4, $iY_Min)
        If $iLeft > $iX_Max Then DllStructSetData($stWinPos, 3, $iX_Max)
        If $iTop > $iY_Max Then DllStructSetData($stWinPos, 4, $iY_Max)
    EndIf
EndFunc   ;==>WM_WINDOWPOSCHANGING

JS

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...