in reply to Re: How to change the default (ok) button in Win32::GUI
in thread How to change the default (ok) button in Win32::GUI

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.