I use the -dialogui option on all my windows and I would have expected it to be the default also. I must disagree that the problem is that the example only contains the buttons. The project I'm working on has one main window that contains many tabstrips and controls that are hidden and shown at runtime depending on the tab chosen to give the effect of tabs within tabs and different pages. I have modified the example to include two textfields and the result is the same. Here's the code:
#!c:\perl\wperl.exe -w use strict; use warnings; use Win32::GUI; my @page; my $font1 = Win32::GUI::Font->new( -name => "Arial", -size => 7 ); my $mainform = Win32::GUI::Window->new(-name=>'main',-text=>'test',-wi +dth=>200,-height=>200,-dialogui=>1); my $button1 = $mainform->AddButton(-name=>'button1',-top=>10,-left=>10 +,-text=>"button1",-ok=>1); my $text1 = $mainform->AddTextfield(-name=>'text1',-top=>10,-left=>100 +,-width=>50,-height=>20); my $button2 = $mainform->AddButton(-name=>'button2',-top=>40,-left=>10 +,-text=>"button2",-ok=>0); my $text2 = $mainform->AddTextfield(-name=>'text2',-top=>40,-left=>100 +,-width=>50,-height=>20); $mainform->Show(); Win32::GUI::Dialog(); exit; sub button1_Click { $mainform->MessageBox("You clicked button1. Changing the default +to button2.","button1"); $button1->Change(-ok=>0); #$button2->Change(-ok=>1,-addstyle=>BS_DEFPUSHBUTTON); $button1->Update(); $button2->Update(); $mainform->Update(); } sub button2_Click { Win32::GUI->MessageBox("You clicked button2. Changing the default + to button1.","button2"); $button2->Change(-ok=>0); #$button1->Change(-ok=>1,-addstyle=>BS_DEFPUSHBUTTON); $button1->Update(); $button2->Update(); $mainform->Update(); } sub main_Termintate { $mainform->Hide(); return -1; }
As you can see in the code I have also added the Update method to the buttons and window after the changes are made but that does not help either. I also tried using -addstyle=>BS_DEFPUSHBUTTON which also didn't help. What worries me with that approach would be that I don't know how to remove the style after it is applied. But it doesn't work anyway, so that's not going to be an issue.

In reply to Re^2: How to change the default (ok) button in Win32::GUI by ChrisR
in thread How to change the default (ok) button in Win32::GUI by ChrisR

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.