I copied your code into a script of mine and it worked. Please make sure you
have Win32-GUI 0.0.558 (in a dos window, run ppm query win32-gui).

As for your approach, I would recommend you create the dialogbox and all
it's controls outside the sub stored_Click, before you call
Win32::GUI::Dialog() and inside sub stored_Click, you just do $Win->Show().
That way, when you klick on 'stored' for the second time, you won't
re-create all the controls, but simply reuse them. In the sub Win_Terminate
(not the Window_Terminate for the main window, just the one for the
DialogBox), DON'T return -1, because that would end your only message loop
for both windows. Just do $Win->Hide(). That way, you will always be inside
one Win32::GUI::Dialog() call and only return from that when the main window
terminates.

Win32::GUI does no DestroyWindow calls, the windows only disappear from
memory after the script terminates. Meaning, you can go ahead and create
windows and controls dynamically inside _Click subs (or anywhere else), but
if you create the same DialogBox every time you use it, this will
effectively be a memory leak.

Have fun,
Harald

| -----Original Message-----
| From: Dave [mailto:[EMAIL PROTECTED]
| Sent: Thursday, May 24, 2001 9:20
| To: perl-win32-gui-users@lists.sourceforge.net
| Subject: [perl-win32-gui-users] New window?
| 
| 
| I am having a problem with a dialog box. The main problem is, it won't
| show up. Below is the code I am using to open a new window 
| from my main
| window when a button is pushed ( store ) . Before this code 
| is all of my
| normal application code ( which works fine ). I have tried it with and
| without the first and second Win32::GUI::Dialog(); entries. 
| Neither will
| make the new window appear. Can someone please tell me what I am doing
| wrong?
| 
| 
| <MainWindow GUI code is here >
| $MainWindow->Show();
| 
| Win32::GUI::Dialog();
| 
| <subs for main window are here>
| 
| sub stored_Click {
|       $Win=Win32::GUI::DialogBox->new(
| #      -left   => 341,
| #      -top    => 218,
|       -width  => 563,
|       -height => 368,
|       -name   => "Win",
|       -title   => "Window Title"
|       );
| 
| $Win->Show();
| 
| $Win->AddRichEdit(
|        -text    => "",
|        -name    => "RichEdit_1",
|        -left    => 1,
|        -top     => 1,
|        -width   => 552,
|        -height  => 306,
|       );
| 
| $Win->AddButton(
|        -text    => "Save",
|        -name    => "instrsave",
|        -left    => 132,
|        -top     => 316,
|        -width   => 90,
|        -height  => 21,
|        -foreground    => 0,
|       );
| 
| $Win->AddButton(
|        -text    => "Cancel",
|        -name    => "popupcancel",
|        -left    => 343,
|        -top     => 315,
|        -width   => 95,
|        -height  => 21,
|        -foreground    => 0,
|       );
| }
| Win32::GUI::Dialog();
| sub Window_Terminate {
|     return -1;
| }
| 
| sub Close_Click {
|     Window_Terminate();
| };
| 
| 
| _______________________________________________
| Perl-Win32-GUI-Users mailing list
| Perl-Win32-GUI-Users@lists.sourceforge.net
| http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
| 

Reply via email to