Sign in to follow this  
Followers 0
Kickassjoe

Registering a contextmenuitem clicked?

6 posts in this topic

#1 ·  Posted (edited)

After the GUI is made, I made it check to see if $msg = the menuitem, it always returns yes... can anyone fix it?

EDIT:Uploading Code.

Download Here, .exe and .au3

Edited by Kickassjoe

What goes around comes around... Payback's a bitch.

Share this post


Link to post
Share on other sites



After the GUI is made, I made it check to see if $msg = the menuitem, it always returns yes... can anyone fix it?

EDIT:Uploading Code.

Download Here, .exe and .au3

Hi! And this not work?

#include <GuiConstants.au3>

$hGui = GUICreate("Context menu test", 300, 200)

$button = GUICtrlCreateButton("Button", 110, 80, 80, 25)
$ContextMenu = GUICtrlCreateContextMenu($button)
$MenuAbout = GUICtrlCreateMenuItem("About", $ContextMenu)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case -3
        ExitLoop
    Case $MenuAbout
        MsgBox(0, "About", "This is a button control", 2)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

I have looked your code and i think GuiSetOnEvent better then GuiGetMsg() for your code. :)

Share this post


Link to post
Share on other sites

Your code worked, my code didn't, and still doesn't, nor does that put me any closer to figuring out why it isn't working. Thanks for the help?

P.S. GuiSetOnEvent would mean i would have to basically rewrite all of that, and I think not using GuiSetOnEvent is doing just fine, other than it not working correctly. (Which GuiSetOnEvent would not help IMO)


What goes around comes around... Payback's a bitch.

Share this post


Link to post
Share on other sites

I can see why you'd be better off with OnEventMode , due to your cpu time will be chewed up every time the mouse is anywhere over gui even when not clicking anything. The While loop will start polling through the For loops and CPU time will sky rocket.

Other things I find to hard to work with are 3d and 4d arrays, I really can't see the point of them for your script.

I understand what they're for, but I cant see the need as you seem to be just complicating what should be a simple context menu per item and making one context menu into 3 different arrays of varying dimensions.

To each his own, but to me that's just making life hard for yourself.

A from scratch re-think of your control layout could probably save you some time in the long run and make it a hell of alot easier to follow where it's going wrong.

Cheers

Share this post


Link to post
Share on other sites

I guess I'll "redo" it to be GuiOnEvent... but isnt a 4d array necessary for the context menu? I want to keep track of 3 different kinds of abilities, on varying tabs (the first dimension), which have up to 10 different pictures on 10 different tab items (2nd and 3rd dimensions), and then which one is pressed (the 4th dimension). If you have another way of doing that, I'd be happy to know. I know I don't necessarily need any of the other arrays except $MenuItem, but how would I just put $MenuItem into a non-array variable without losing the functionality?


What goes around comes around... Payback's a bitch.

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