Jump to content
Sign in to follow this  
vacko

Context Menu doesn't work when mouse is above Text Label ?

Recommended Posts

vacko

Hi,

I have some GUI with context menu and with many text labels, but context menu doesn't work when mouse cursor stay above some of these labels.

Is it possible change GUI to let context menu works in any place ? Example is below

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

$Form2 = GUICreate("Form2", 347, 137)
$Group1 = GUICtrlCreateGroup("Context menu doesn't work here", 8, 72, 329, 57)
$Label1 = GUICtrlCreateLabel("SomeLabelSomeLabelSome", 16, 88, 316, 33)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

Local $contextmenu = GUICtrlCreateContextMenu()
$ContextMenuItem1 = GUICtrlCreateMenuItem("Open" &@TAB&"Alt+O", $contextmenu)
$ContextMenuItem2 = GUICtrlCreateMenuItem("Exit" &@TAB&"Alt+X", $contextmenu)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $ContextMenuItem2
   Exit
EndSwitch
WEnd

Share this post


Link to post
Share on other sites
armoros

Hello vacko

from help file

Remarks

After creating the context menu main control with this function, each menu item can be created by using GUICtrlCreateMenuItem.

Sub-menus can be created using GUICtrlCreateMenu.

If you use no parameters or -1 in this function then the context menu that is created is associated with the entire GUI window rather than an individual control.

Only one context menu per control is possible. If you wish to create a new context menu one you have to delete the existing menu first.

Note: You can't create context menus for controls that already have system context menus, i.e. edit or input controls.


[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites
vacko

Hello vacko

from help file

Remarks

After creating the context menu main control with this function, each menu item can be created by using GUICtrlCreateMenuItem.

Sub-menus can be created using GUICtrlCreateMenu.

If you use no parameters or -1 in this function then the context menu that is created is associated with the entire GUI window rather than an individual control.

Only one context menu per control is possible. If you wish to create a new context menu one you have to delete the existing menu first.

Note: You can't create context menus for controls that already have system context menus, i.e. edit or input controls.

I don't get it, I didn't use any parameter, so context menu should apply to entire GUI (include all controls), isn't it ?

Share this post


Link to post
Share on other sites
armoros

vacko as i get it you can have 1 context menu for a control etc.

I made a mistake vacko sorry..so i deleted the code..

I am not a expert so wait for a better advice ;)

Edited by armoros

[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites
stormbreaker
;) I don't have much time for now... But I suggest you create a dummy control, set its context menu and modify ShowMenu() function (from GuiCtrlCreateContextMenu example in help file) according to your needs (I could do it, but I guess it would be fun doing it yourself..) A bit modification and the context menu could then be displayed on any control... :)

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites
Melba23

vacko,

The context menu does not fire when over the label because the label is reagrded as a separate control which could well have its own context menu. If you remove the default $SS_NOTIFY style from the label it is no longer regarded as a separate control and the GUI context menu will appear: :)

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

$Form2 = GUICreate("Form2", 347, 137)
$Group1 = GUICtrlCreateGroup("Context menu doesn't work here", 8, 72, 329, 57)
$Label1 = GUICtrlCreateLabel("SomeLabelSomeLabelSome", 16, 88, 316, 33)
GUICtrlSetStyle(-1, $SS_LEFT) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

Local $contextmenu = GUICtrlCreateContextMenu()
$ContextMenuItem1 = GUICtrlCreateMenuItem("Open" & @TAB & "Alt+O", $contextmenu)
$ContextMenuItem2 = GUICtrlCreateMenuItem("Exit" & @TAB & "Alt+X", $contextmenu)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ContextMenuItem2
            Exit
    EndSwitch
WEnd

All clear? ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
armoros

That is great info Mkish and Melba23.....nice to know.


[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites
vacko

vacko,

The context menu does not fire when over the label because the label is reagrded as a separate control which could well have its own context menu. If you remove the default $SS_NOTIFY style from the label it is no longer regarded as a separate control and the GUI context menu will appear: :)

All clear? :)

M23

Great ! Thank you for help.

I have over 30 labels in my GUI, now just modify them... ;)

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  

×