in reply to Re^2: Win32::GUI Issues
in thread Win32::GUI Issues
#!c:\perl\wperl.exe -w use strict; use warnings; use Win32::GUI; my $t_font = Win32::GUI::Font->new( -name => "Arial", -size => 7 ); my $accelerators = new Win32::GUI::AcceleratorTable("Return" => "Enter +"); my $main = Win32::GUI::Window->new(-name=>'main',-text=>'test',-width= +>200,-height=>200,-dialogui=>1,-accel=>$accelerators); my $button1 = $main->AddButton(-name=>'button1',-top=>10,-left=>10,-te +xt=>"button1",-ok=>0); my $lotid = $main->AddTextfield( -name => "lotid", -keepselection => 1, -top => 30, -left => 10, -width => 125, -height => 20, -font => $t_font, -readonly => 0, ); my $lotid_hwnd = $main->lotid->{-handle}; #print "Handle of the lotid textfield: $lotid_hwnd\n"; $main->Show(); Win32::GUI::Dialog(); exit; sub Enter_Click { my $control_hwnd = $main->GetFocus(); #print "handle of the control with the focus: $control_hwnd\n"; if($control_hwnd == $lotid_hwnd) { $main->MessageBox("You pressed Return in while in the textfiel +d. This is what was int he textfield: \"" . $lotid->Text() . "\"","En +ter_Click"); button1_Click(); } else { $main->MessageBox("You pressed Return in while NOT in the text +field.","Enter_Click"); } return 1; } sub button1_Click { $main->MessageBox("You clicked button1.","button1"); } sub main_Termintate { $main->Hide(); return -1; }
|
|---|