Sign in to follow this  
Followers 0
BugFix

Own context menu (with checkbox, radio, images [gif,jpg,bmp,ico], colored squares)

8 posts in this topic

#1 ·  Posted (edited)

With this UDF you can create own context menus with following features:

- Show menu only, if an condition is TRUE (ie: number of entries in an listview must be greater than zero)

- Item types: Label, Checkbox, Radio, Image (jpg,bmp,gif), Icon (from Icon file, DLL), Shape --- Image files should be (nearly) quadratic. It is scaled to 16 x 16 pixel.

- The menu width is selectable. (Default 200 px)

- Left margin for general and additional for each menu item can be set (Indents are thus possible)

- The Items are default controls. You can Disable/Enable them, change text color, set state. But don't change background color. The background color is changed when the mouse is over the entry.

- If you like an other hover color, you can change it during the menu creation. Or later with an own function.

Edit:

Now I've made some changes:

- more speed during hover (decrease adlib time from 50 to 10 ms)

- if menu is shown and you click with right: on menu - nothing happens, outside menu - menu will closed

- renamed functions to _GUICtrlOwnContext_...

- used funkeys tip for Bkcolor

- In my Win 7 the hover color is clearly to see. If you've a problem with this, change color during creation of menu or general with changing the declaration:

Global $__iMNU_DEF_HOVERCOLOR = 0xEFFFFF

Edit 2:

- Added: For each entry you can create an submenu (1 level depth). Important: First, create all entries to the menu. Only then can sub-menus and their entries are created. See the example.

- Changed:Now the entire area of the entry is detected as an control. Also used Images.

- Changed: No more Adlib function, all processing inside window- and mouse- procedures.

- New Example for v0.9 (dont works with older version)

Current version: v0.9

So it looks:

v0.8

Posted Image

v0.9

post-8176-0-60100000-1342361879_thumb.jp

OwnContext.au3

OwnContext_Example.au3

OwnContext0.9.au3

OwnContext_Example0.9.au3

Edited by BugFix
3 people like this

Best Regards BugFix  

Share this post


Link to post
Share on other sites



Very nice! Thanks for sharing. I will have use for it!

But there are a few things I have to say:

# MenuEx sounds like beeing an extension UDF of the original control. I would call it OwnMenu or GuiMenu or something, but that's just my opinion.

# On my Win7 the hover color is hard to see (nearly the same than the background color).

# And on my WinXP the color after control is hovered is wrong. I would change this line in __IsHover()

If $iID_LastOver <> 0 Then GUICtrlSetBkColor($iID_LastOver, 0x0F0F0F0)

to

If $iID_LastOver <> 0 Then GUICtrlSetBkColor($iID_LastOver, $GUI_BKCOLOR_TRANSPARENT)

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Very nice concept.

But there is a few problems that i have notice at the beginning:

* The hover is slow.

* If you right click on the gui after menu is shown, the menu is still there and hovering does not working.


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Thanks for testing and your replys.

@funkey

I'll change it with next version. (both points)

@MrCreatoR

* The hover is slow.

I'll decrease the Adlib-time to 10 ms. Than it should be fast enough. (atm i use 50 ms)

* If you right click on the gui after menu is shown, the menu is still there and hovering does not working.

I've never used right click if the menu is shown. So i have not seen this behavior. Thanks, that you've found this bug. I'll fix this with next version.


Best Regards BugFix  

Share this post


Link to post
Share on other sites

I've now taken your advices.

See changes in my first post.


Best Regards BugFix  

Share this post


Link to post
Share on other sites

You changed the name of your UDF - example is not working! ;)

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Oops :rolleyes:

The Include must be renamed, have changed it in example now. Thanks for your report.


Best Regards BugFix  

Share this post


Link to post
Share on other sites

New Version v0.9

Creating submenu is possible.

See post #1


Best Regards BugFix  

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