Sign in to follow this  
Followers 0
Tiger

How can I create a Ribbon Menu

8 posts in this topic

I would like to create a menu in the round button. I have a example in the attachment

The Code

Opt("GUIOnEventMode", 1)
#include <GUIConstants.au3>
GUICreate("", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_close")
$icon = GUICtrlCreateIcon("restart.ico", -1, 0, 0, 32, 32)
GUICtrlCreateMenuItem("Icon", $icon)
GUISetState(@SW_SHOW)
Func _close()
    Exit
EndFunc   ;==>_close
While 1 
    Sleep(250)
WEnd

post-21671-1218464065_thumb.jpg


My UDFs:- _RegEnumKey

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Hey Tiger.

Maybe what you want is a context menu for the control ...

GUICtrlCreateContextMenu ( [controlID] )

As far as I know, this is the only type of menu you can make for the little green button.

Edit 1: Correction - it wouldn't be simple, but you could make another window you built to appear when the mouse is hovering over the little green thing, and that window could be without a title bar and contain have only clickable label controls.

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

contextmenu = right click on the mouse

normal menu = left click on the mouse

And I would like to create a normal menu for the little green button


My UDFs:- _RegEnumKey

Share this post


Link to post
Share on other sites

Thanks but there is still no menuitem under the green icon

Opt("GUIOnEventMode", 1)
#include <GUIConstants.au3>
$gui = GUICreate("", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_close")
$ribbon = GUICtrlCreateIcon("restart.ico", -1, 0, 0, 32, 32, $BS_FLAT)
GUICtrlSetOnEvent(-1, "_ribbon")
$ribbondummy = GUICtrlCreateDummy()
$ribboncontext = GUICtrlCreateContextMenu($ribbondummy)
$ribbonexit = GUICtrlCreateMenuItem("Exit", $ribboncontext)

GUISetState(@SW_SHOW)

Func _ribbon()
    
    ShowMenu($gui, $ribbon, $ribboncontext)
    
EndFunc   ;==>_ribbon

Func _close()
    Exit
EndFunc   ;==>_close

; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $CtrlID, $nContextID)
    Local $hMenu = GUICtrlGetHandle($nContextID)
    
    $arPos = ControlGetPos($hWnd, "", $CtrlID)
    
    Local $x = $arPos[0]
    Local $y = $arPos[1] + $arPos[3]
    
    ClientToScreen($hWnd, $x, $y)
    TrackPopupMenu($hWnd, $hMenu, $x, $y)
EndFunc


; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")
    
    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))
    
    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    ; release Struct not really needed as it is a local 
    $stPoint = 0
EndFunc


; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc

While 1 
    Sleep(250)
WEnd

My UDFs:- _RegEnumKey

Share this post


Link to post
Share on other sites

You need to tell the GUI to fire a message for a ICO control:

$ribbon = GUICtrlCreateIcon("restart.ico", -1, 0, 0, 32, 32, BitOR($BS_FLAT,$SS_NOTIFY))

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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