Jump to content

SplashImageOn with Menus


xroot
 Share

Recommended Posts

Was Playing around with the SplashImageOn command trying to control it.

Created menu rc file compiled to a menu res file (see files).

Loaded the menu res file into the script creating the menu.

Subclassed the menu to get control.

All of this is real basic and has been done before.

It was still fun trying to control the SplashImageOn command.

Also, added round corners and exit animation.

With the subclassing in place adding a command button would be real easy.

If you don't want a title and still want to move the window uncomment the comments.

Check it out and have some fun.

Global Const $WM_CHAR=0x0102
Global Const $WM_COMMAND=0x0111
;Global Const $WM_LBUTTONDOWN=0x0201
;Global Const $WM_NCLBUTTONDOWN=0x00A1
;Global Const $HTCAPTION=2
Global Const $GWL_WNDPROC=-4
Global Const $Esc=0x1B
Global Const $Exit=1001
Global Const $AboutBox=1002
Global Const $Implode=0x10010

Func Animate_Win($hWin,$aType,$aSpeed=500)
    DllCall("user32.dll","int","AnimateWindow","hwnd",$hWin,"int",$aSpeed,"int",$aType)
    Exit
EndFunc

Func Msg_Loop($hWin,$uMsg,$wParam,$lParam)
    Switch $uMsg
        Case $WM_CHAR
            If $wParam=$Esc Then Animate_Win($hWnd,$Implode)
        ;Case $WM_LBUTTONDOWN
            ;DllCall("user32.dll","int","ReleaseCapture")
            ;DllCall("user32.dll","int","SendMessage","hwnd",$hWin, _
            ;                                         "int",$WM_NCLBUTTONDOWN, _
            ;                                         "wparam",$HTCAPTION, _
            ;                                         "lparam",0)
        Case $WM_COMMAND
            Switch $wParam
                Case $AboutBox
                    MsgBox(4096,"Help About","Hi, From SplashImage",2)
                Case $Exit
                    Animate_Win($hWin,$Implode)
            EndSwitch
    EndSwitch
    Local $ret=DllCall("user32.dll","int","CallWindowProcA","hwnd",$oML[0], _
                                                            "hwnd",$hWin, _
                                                            "int",$uMsg, _
                                                            "int",$wParam, _
                                                            "int",$lParam)
    Return $ret[0]
EndFunc

Func Round_Window($hWin,$W=60,$H=60)
    Local $Pos=WinGetPos($hWin)
    Local $ret=DllCall("gdi32.dll","hwnd","CreateRoundRectRgn","int",0, _
                                                               "int",0, _
                                                               "int",$Pos[2], _
                                                               "int",$Pos[3], _
                                                               "int",$W, _
                                                               "int",$H)
    DllCall("user32.dll","int","SetWindowRgn","hwnd",$hWin,"hwnd",$ret[0],"int",True)
    Return
EndFunc

Func Load_Menu($hWin,$ResFile)
    Local $RES="0x"&StringMid(FileRead(FileOpen($ResFile,16)),131)
    Local $LM=DllStructCreate("byte["&StringLen($RES)&"]")
    DllStructSetData($LM,1,$RES)
    Local $Menu=DllCall("user32.dll","hwnd","LoadMenuIndirectA","ptr",DllStructGetPtr($LM))
    DllCall("user32.dll","int","SetMenu","hwnd",$hWin,"hwnd",$Menu[0])
    Local $pML=DllCallbackGetPtr(DllCallbackRegister("Msg_Loop","int","hwnd;uint;wparam;lparam"))
    Global $oML=DllCall("user32.dll","int","SetWindowLongA","hwnd",$hWin, _
                                                            "int",$GWL_WNDPROC, _
                                                            "int",$pML)
    Return
EndFunc

Local $Title="SplashImage Menu Test",$Image=@ScriptDir&"\redline.bmp",$Menu=@ScriptDir&"\Menu.res"

SplashImageOn($Title,$Image,-1,-1,-1,-1,16)
Local $hWnd=WinGetHandle($Title)

Round_Window($hWnd,30,30)
Load_Menu($hWnd,$Menu)

WinActivate($hWnd)

While True
    Sleep(1)
WEnd

Splash.zip

Link to comment
Share on other sites

Not an AutoIT error dialog, but a system crash on my XP Pro Machine

I am running XP Pro here and it worked for me.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

hmm .. must be some system setting with mine then

thanks for the reply

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

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...