Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: win32::Gui -- Paradigm problem...How do you get info back from a dialog?

by dada (Chaplain)
on Jul 05, 2002 at 09:45 UTC ( [id://179594]=note: print w/replies, xml ) Need Help??


in reply to Re: win32::Gui -- Paradigm problem...How do you get info back from a dialog?
in thread win32::Gui -- Paradigm problem...How do you get info back from a dialog?

BrowserUk,

there is a difficult in what you say here: Win32::GUI itself makes heavy usage of that "extra" window words for its own business. they're used to store pointers to Perl callbacks, window properties that are not directly related to the underlying API (eg. which event model to use), and lot of other stuff that just makes Win32::GUI works. so it's not advisable at all to use Get/SetWindowLong() unless you have a very, very deep knowledge of the module's guts.

the functions are there because I think if someone wants to hack deeply, he should be able to do it. but they're not for everyone (or "for the faint of heart", as they say :-). this should've been made clearer in the docs, but you all know what a mess the docs are at this point, don't you?

so I would suggest to talwyn: go the Perlish way, store the results somewhere in Perl (one global hash would be my best bet).

cheers,
Aldo

__END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print;
  • Comment on Re: Re: win32::Gui -- Paradigm problem...How do you get info back from a dialog?
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: win32::Gui -- Paradigm problem...How do you get info back from a dialog?
by BrowserUk (Patriarch) on Jul 05, 2002 at 10:12 UTC

    Makes sense Aldo, glad you where around to intervene before I sent Talwyn on a short-wavelength visible-light Clupea Pallasii pursuit.

    As a minor suggestion if you ever get around to re-writing any of the code:

    With the Get/SetWindowLong() calls you could inspect the index parameter and adjust it internally to allow users to add their own window words without colliding with yours. Say for example you are using 10 words internally, you could add ten to the user supplied index on the way through to calling the native API's and if anyone needs to access YOUR window words, they could use the negative offset convention in the same way as these are used by the underlying API's for their internal stuff.

    In that way, you still provide access to the full API but protect your internals from fools like me:)

Re: Re: Re: win32::Gui -- Paradigm problem...How do you get info back from a dialog?
by talwyn (Monk) on Jul 07, 2002 at 20:54 UTC
    Hey Aldo,

    I tried the Global hash approach and it works ...sort of...

    I think I need some pointers on how to tune DoEvents(). When I entered data in the dialog box I got ~880 key repetitions. I was able to get those 880 letters back to the originating function though... so I'm making progress.

    Snippet Follows

    #Events----------------------------------------------- sub ::Dialog1_Terminate { defined(my $win = $Win32::GUI::Loft::window{winMain}) or return(1); print_dbg(" I am now enabling the window!"); $win->Enable(); return(1); } sub ::btnDialog1_Click{ defined(my $win = $Win32::GUI::Loft::window{Dialog1}) or return(1); our %MSG = %main::MSG; my $text = $win->tfDialog1->Text(); $MSG{"Dialogue"}{"Text"}= $text; return -1; } #App---------------------------------------------- sub GetDestination{ #( $combobox ) #This function returns the drive library or other Destination #Selected in the Combobox object passed to it. my $combobox = shift; local %::MSG = %main::MSG; defined(my $win = $Win32::GUI::Loft::window{winMain}) or return(1); #Ensure $combobox is infact a combobox object abort if not. unless ( "ComboBox" eq $combobox->GetClassName() ){ print_dbg ($combobox->GetClassName()); die "REcieved a bad object!"; } my $destination = $combobox->Text(); print_dbg ("Selected:".$destination); $destination =~s/\s//; if ($destination eq ''){ print_dbg ("No Destination!"); $win->Disable(); # disable main window until we get info we ne +ed. my $dlg = configure_window ('dialog.gld'); $dlg = build_window($dlg, "Dialog1"); $dlg->lblPrompt->Text( "You must enter a destination. \n". 'Type one in the box below.'); $dlg->Show(); do{ Win32::GUI::DoEvents(); } until ($::MSG{"Dialogue"}{"Text"} ne ''); print_dbg ("The user entered: ".$::MSG{"Dialogue"}{"Text"}); } print_dbg ("I AM A STUB FIX ME!"); return ($destination); }
      Hmm, I now have it working. I replaced :
      do{ Win32::GUI::DoEvents(); } until ($::MSG{"Dialogue"}{"Text"} ne '');
      with
      $dlg->Dialog(); print "User Entered:".$::MSG{"Dialogue"}{"Text"}."\n";
      Which by the way the Docs say explicitly NOT to do. Are there any potential gotchas I should be aware of when I use this ?

      Talwyn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-18 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found