Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Keep It Simple, Stupid
 
PerlMonks  

Re^6: How to get a window's menu as a Win32::GUI::Menu object?

by shadrack (Initiate)
on Feb 17, 2013 at 10:44 UTC ( #1019124=note: print w/ replies, xml ) Need Help??


in reply to Re^5: How to get a window's menu as a Win32::GUI::Menu object?
in thread How to get a window's menu as a Win32::GUI::Menu object?

I don't know, but it certainly answers the question you asked , and I quote
"returns a menu HANDLE, not an object reference. This seems to be more or less useless -- unless there's a way to turn the handle into an object? "

Yes, but not just any old object -- THE object the handle was associated with. Sorry, but I would have thought this was obvious given the context of the question. :-/

I am actually using a global now, but I'm looking for a way around it since I'm also using threads which sometimes don't seem to play well with global Win32::GUI object variables.

Anyway, thanks for the suggestions. Storing $Menu inside $WinMain is the solution I'm looking for. I tried something like this before (on a different Win32::GUI issue), but I couldn't make it work -- it's been a while, but IIRC the stored variable refused to "stick" to the object (it was undefined when I tried to access it later). Chalk it up to my lack of understanding of perl's object handling I guess.


Comment on Re^6: How to get a window's menu as a Win32::GUI::Menu object?
Re^7: How to get a window's menu as a Win32::GUI::Menu object?
by Anonymous Monk on Feb 17, 2013 at 11:16 UTC

    Yes, but not just any old object -- THE object the handle was associated with. Sorry, but I would have thought this was obvious given the context of the question. :-/

    :) Well, sorry, it wasn't obvious to me -- Win32::GUI simply doesn't do that, its not Tk.pm or Wx.pm or some such

    There is the undocumented Win32::GUI::GetWindowObject($handle) but it doesn't work with menus

    foreget this update: http://search.cpan.org/grep?cpanid=ROBERTMAY&release=Win32-GUI-1.06&string=hmenu&i=1&n=1&C=0 reveals GetMenuFromID

    I guess you could remove the IsWindow check from GetWindowObject, recompile Win32::GUI, and try that ... but if this doesn't make you rethink choosing Win32::GUI :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019124]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-04-20 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls