Sign in to follow this  
Followers 0
Snipz

Need Help Creating 2 Diffrent Menus

3 posts in this topic

#1 ·  Posted (edited)

Im trying to make and edit of Holgers SelfMadeMenu loacted here. So that i could have two diffrent menus for my Options and my Au3 menus. Its very confusing and cant seem to get it. Heres my code that I edited

; SelfMadeMenu V0.002;-) - Just for testing out something
; Written by Holger Kotsch
; Version: 3.1.1.X-Beta is needed

#include <GUIConstants.au3>
#include <gui pindle.au3>

Opt("WinTitleMatchMode", 4)

Global Const $WM_NCACTIVATE         = 0x0086
Global Const $BM_SETSTATE           = 0x00F3

$hMainGui   = GUICreate("SMM V0.002", 110, 170, -1, -1, BitOr($WS_CAPTION, $DS_MODALFRAME,$WS_SYSMENU))
;GUISetBkColor(0xAACCBB)

$icon1      = GUICtrlCreateIcon("shell32.dll", 4, 25, 25, 16, 16)
GUICtrlSetStyle(-1, BitOr($SS_ICON, $SS_NOTIFY))
$btn1       = GUICtrlCreateButton("   Run", 20, 20, 70, 26, $WS_CLIPSIBLINGS)
$icon2      = GUICtrlCreateIcon("shell32.dll", 44, 25, 75, 16, 16)
GUICtrlSetStyle(-1, BitOr($SS_ICON, $SS_NOTIFY))
$btn2       = GUICtrlCreateButton("   Options", 20, 70, 70, 26, $WS_CLIPSIBLINGS)
$icon3      = GUICtrlCreateIcon("shell32.dll", 39, 25, 125, 16, 16)
GUICtrlSetStyle(-1, BitOr($SS_ICON, $SS_NOTIFY))
$btn3       = GUICtrlCreateButton("Au3", 20, 120, 70, 26, $WS_CLIPSIBLINGS)

GUISetState()


;$hMenuGUI  = GUICreate("Menu", 74, 66, -1, -1, BitOr($WS_POPUP, $WS_BORDER), $WS_EX_TOOLWINDOW); Flat Menu
$hMenuGUI   = GUICreate("Menu", 90, 66, -1, -1, BitOr($WS_POPUP, $WS_DLGFRAME), $WS_EX_TOOLWINDOW)
GUISetBkColor(0xAACCBB)

GUICtrlCreatePic(@ScriptDir & "\menu.bmp", 0, -54, 20, 120)
$openhlp    = GUICtrlCreateIcon("shell32.dll", 4, 23, 2, 16, 16)
GUICtrlSetStyle(-1, BitOr($SS_ICON, $SS_NOTIFY))
$openlbl    = GUICtrlCreateLabel("      Open", 20, 0, 70, 20, BitOr($SS_CENTERIMAGE, $WS_CLIPSIBLINGS))
$savehlp    = GUICtrlCreateIcon("shell32.dll", 5, 23, 22, 16, 16)
GUICtrlSetStyle(-1, BitOr($SS_ICON, $SS_NOTIFY))
$savelbl    = GUICtrlCreateLabel("      Save", 20, 20, 70, 20, BitOr($SS_CENTERIMAGE, $WS_CLIPSIBLINGS))
GUICtrlCreateLabel("", 22, 42, 67, 2, $SS_SUNKEN)
$exithlp    = GUICtrlCreateIcon("shell32.dll", 27, 23, 48, 16, 16)
GUICtrlSetStyle(-1, BitOr($SS_ICON, $SS_NOTIFY))
$exitlbl    = GUICtrlCreateLabel("      Exit", 20, 46, 70, 20, BitOr($SS_CENTERIMAGE, $WS_CLIPSIBLINGS))

GUISwitch($hMainGui)

$hover      = 0
$rect       = DllStructCreate("int;int;int;int")
$btn1pressed = 0
$btn2pressed = 0
$btn3pressed = 0

While 1
    $msg = GUIGetMsg(1)
    
    If $msg[1] = $hMainGui Then
        GUISetState(@SW_HIDE, $hMenuGui)
        GUISwitch($hMainGui)
    EndIf
    
    If $msg[1] = $hMenuGui Then
        $info = GUIGetCursorInfo()
        
        $ctrl = $info[4]
        If $ctrl <> $hover Then
            GUICtrlSetColor($hover, -1)
            GUICtrlSetBkColor($hover, 0xAACCBB)
        EndIf

        Switch $hover
            Case $openhlp
                $hover = $openlbl
            Case $savehlp
                $hover = $savelbl
            Case $exithlp
                $hover = $exitlbl
        EndSwitch
        
        If $hover > 0 Then
            GUICtrlSetColor($hover, -1)
            GUICtrlSetBkColor($hover, 0xAACCBB)
        EndIf
        
        GUICtrlSetColor($ctrl, 0xFFFFFF)
        GUICtrlSetBkColor($ctrl, 0x663344)
        If $ctrl = $openhlp Then
            GUICtrlSetColor($openlbl, 0xFFFFFF)
            GUICtrlSetBkColor($openlbl, 0x663344)
        ElseIf $ctrl = $savehlp Then
            GUICtrlSetColor($savelbl, 0xFFFFFF)
            GUICtrlSetBkColor($savelbl, 0x663344)
        ElseIf $ctrl = $exithlp Then
            GUICtrlSetColor($exitlbl, 0xFFFFFF)
            GUICtrlSetBkColor($exitlbl, 0x663344)
        EndIf
        
        $height = 18
        $top    = 1
        
        Switch $ctrl
            Case $openlbl, $openhlp
                $top = 1
            Case $savelbl, $savehlp
                $top = 21
            Case $exitlbl, $exithlp
                $top = 47
        EndSwitch
        
        Switch $ctrl
            Case $openlbl, $openhlp, $savelbl, $savehlp, $exitlbl, $exithlp
                $hdc = DllCall("user32.dll", "hwnd", "GetDC", "hwnd", $hMenuGui)
                $hdc = $hdc[0]
            
                DllStructSetData($rect, 1, 22)         ; Left
                DllStructSetData($rect, 2, $top)       ; Top
                DllStructSetData($rect, 3, 40)         ; Right
                DllStructSetData($rect, 4, $top + $height); Bottom
            
                DllCall("user32.dll", "int", "DrawEdge", "hwnd", $hdc, "ptr", DllStructGetPtr($rect), "int", 0x0004, "int", 0x000F)
                DllCall("user32.dll", "hwnd", "ReleaseDC", "hwnd", $hMenuGui, "hwnd", $hdc)
        EndSwitch
        
        $hover = $ctrl
    EndIf
    
    $x = 90
    
    $info = GUIGetCursorInfo()
    If Not $info[2] Then
        If $btn1pressed Then
            GUICtrlSendMsg($btn1, $BM_SETSTATE, 0, 0)
            $btn1pressed = 0
        EndIf
        If $btn2pressed Then
            GUICtrlSendMsg($btn2, $BM_SETSTATE, 0, 0)
            $btn2pressed = 0
        EndIf
        If $btn3pressed Then
            GUICtrlSendMsg($btn3, $BM_SETSTATE, 0, 0)
            $btn3pressed = 0
        EndIf
    EndIf
            
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE
            ExitLoop
        
            
        Case $btn1, $icon1
            If $msg[0] = $icon1 And $btn1pressed = 0 Then
                GUICtrlSendMsg($btn1, $BM_SETSTATE, 1, 0)
                $btn1pressed = 1
            EndIf           
            GUICtrlSetState($btn1, $GUI_FOCUS)
                $y = 20
            Menu()
        


            
        Case $btn2, $icon2
            If $msg[0] = $icon2 And $btn2pressed = 0 Then
                GUICtrlSendMsg($btn1, $BM_SETSTATE, 1, 0)
                $btn2pressed = 2
            EndIf
            GUICtrlSetState($btn2, $GUI_FOCUS)
                $y = 70
            ConvertCoords($x, $y)
            WinMove($hMenuGUI, "", $x, $y)
            GUISetState(@SW_SHOW, $hMenuGUI)
            DllCall("user32.dll", "int", "SendMessage", "hwnd", $hMainGui, "int", $WM_NCACTIVATE, "int", 1, "int", 0)
        



        Case $btn3, $icon3
            If $msg[0] = $icon3 And $btn3pressed = 0 Then
                GUICtrlSendMsg($btn1, $BM_SETSTATE, 1, 0)
                $btn3pressed = 3
            EndIf
            GUICtrlSetState($btn3, $GUI_FOCUS)
            $y = 120
            ConvertCoords($x, $y)
            WinMove($hMenuGUI, "", $x, $y)
            GUISetState(@SW_SHOW, $hMenuGUI)
            DllCall("user32.dll", "int", "SendMessage", "hwnd", $hMainGui, "int", $WM_NCACTIVATE, "int", 1, "int", 0)
        
        Case $openlbl, $savelbl, $exitlbl, $openhlp, $savehlp, $exithlp
            GUISetState(@SW_HIDE, $hMenuGUI)
            Switch $msg[0]
                Case $openlbl, $openhlp
                    FileOpenDialog("Choose files", @ScriptDir, "Images (*.jpg;*.bmp)|All Files (*.*)")
                Case $savelbl, $savehlp
                
                Case $exitlbl, $exithlp
                    ExitLoop
            EndSwitch
                
    EndSwitch

WEnd

DllStructDelete($rect)

Exit

Func ConvertCoords(ByRef $x, ByRef $y)
    $point = DllStructCreate("int;int")
    DllStructSetData($point, 1, $x)
    DllStructSetData($point, 2, $y)
    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hMainGui, "ptr", DllStructGetPtr($point))
    $x = DllStructGetData($point, 1)
    $y = DllStructGetData($point, 2)
    DllStructDelete($point)
EndFunc
Edited by Snipz

Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi B)

can you tell me what do you have edited? - I see no difference to my posting but only 1 line "#include <gui pindle.au3>"

So long...

Holger

Edit: maybe I will write a small UDF the next days which makes it easier to create such 'menus' :o

Edited by Holger

Share this post


Link to post
Share on other sites

Hi B)

can you tell me what do you have edited? - I see no difference to my posting but only 1 line "#include <gui pindle.au3>"

So long...

Holger

Edit: maybe I will write a small UDF the next days which makes it easier to create such 'menus' :o

Nothing really but the menu titles and the icons. Do you get what im saying by the 2 diffrent menus?


Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go?

Share this post


Link to post
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
Sign in to follow this  
Followers 0