Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Which is why I don't understand why it's relevant. How does it help my solve the problem?

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?

So there you go :) smile (:

You posted a link to the tutorial. ...

:) I linked specifically to an example of the functional interface, how to use handles without turning them into objects

:) Sure its got nothing to do with menus , but then it wasn't supposed to

Fair enough: CODE

Employing Basic debugging checklist I get

( bless({ -handle => 28640341, Alpha => bless({ -id => 102, -menu => 41813267 }, "Win32::GUI::M +enuItem"), Beta => bless({ -id => 103, -menu => 41813267 }, "Win32::GUI::M +enuItem"), Program => bless({ -handle => 41813267 }, "Win32::GUI::MenuButton" +), }, "Win32::GUI::Menu"), bless({ # tied Win32::GUI::Window -accel => 0, -handle => 7734092, -name => "Main", -type => 0, }, "Win32::GUI::Window"), ) bless({ -handle => 13304919 }, "Win32::GUI::Menu")

so what you want to do is skip GetMenu and either use global variables , or store $Menu inside $WinMain

Like this

#!/usr/bin/perl -- #!perl use Win32::GUI; use Data::Dump; Main( @ARGV ); exit 0; sub Main { my $Menu = Win32::GUI::MakeMenu( '&Program' => 'Program', ' > &Alpha' => { -name => 'Alpha', -onClick => \&Alpha_Select +}, ' > &Beta' => { -name => 'Beta', -onClick => \&Beta_Select }, ); my $WinMain = Win32::GUI::Window->new( -name => 'Main', -menu => $Menu, -text => 'Menu Test', -width => 300, -height => 200, -onTerminate => \&Main_Terminate, ); $WinMain->Show(); $WinMain->{__special_Menu} = $Menu; dd $Menu, $WinMain; Win32::GUI::Dialog(); delete $WinMain->{__special_Menu}; # "DESTROY"/destructor/manual m +emory cycle break } sub Main_Terminate { -1; } sub Alpha_Select { 1; } sub Beta_Select { my($Window)=@_; my $menuhandle=$Window->GetMenu(); my $menu = bless { -handle => $menuhandle }, 'Win32::GUI::Menu'; dd $menu; #~ $menu->{'Beta'}->Enabled(0); # Doesn't work. $Window->{__special_Menu}->{'Beta'}->Enabled(0); return 1; }

Useful regarding memory management, Tutorials: Variable Scoping in Perl: the basics, Coping with Scoping , Mini-Tutorial: Perl's Memory Management, Lexical scoping like a fox, Read this if you want to cut your development time in half!

I'll be back with more:) maybe


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (13)
    As of 2014-10-20 13:12 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (76 votes), past polls