anselmomh has asked for the wisdom of the Perl Monks concerning the following question:

Ok i have to problems i need to fix for my program.
1. I have a list of ComboBox items in a column and they slightly overlap. The realestate that im given doesnt allow me to space them out so i need to resize the ComboBox items. However i cannot get this to work if i try using the height options then it adjusts the dropdown not the actual combobox that you see.

2. TextField item i have i would like to add an event to capture an enter is there a way to do this?

Replies are listed 'Best First'.
Re: Win32::GUI Issues
by eibwen (Friar) on Apr 21, 2005 at 00:38 UTC
    Please post the relevant code and expound upon the following:

    capture an enter

    I belive you mean to say:

    1. How can I change the height of a Combo/Select Box widget itself? (irrespective of the drop-down "menu" height)
    2. How can I detect when a text field has been updated? (Not while being updated, but after having been updated)

    Please verify (and post the code).

Re: Win32::GUI Issues
by ChrisR (Hermit) on Apr 21, 2005 at 02:35 UTC
    I agree that you should show some code, however I'll offer this:

    1) try changing the font of the combobox to something that fits your needs
    my $font1 = Win32::GUI::Font->new( -name => "Arial", -size => 8 ); $form->AddCombobox(-font=>$font1, ...
    2) you could set a default-ok button using:
    AddButton(-ok=>1, ...
    Be sure to use the -dialogui=>1 option when you create the window if you want this to work. Or, you could use Win32::GUI::AcceleratorTable. I haven't used it yet but as I stated in a recent thread How to change the default (ok) button in Win32::GUI, I am about to try it myself.

    I hope this helps, but if it doesn't, please be more clear in your post.
      This is the AddTextfield code i have that you were asking for there is no way that i have found (looked all over the net and my books) to do an enter event for this Widget. I.E. i want to have an event handler for when the user hits the ENTER key inside this Widget, so that i can invoke the same code that happens if they use the mouse to click the "Update Wafers" button.
      my $lotid = $main->AddTextfield( -name => "lotid", -keepselection => 1, -top => $row0, -left => $col1, -width => 125, -height => 20, -font => $t_font, -readonly => 0, );

      The other question about changing the size of the ComboBox Widget independantly of the Dropdown size or FONT was my intention. As memtioned before i can make the font smaller and its size will decrease, i just thought maybe i could get rid of some of the whitespace that resided on top and bottom of the FONT that im using. I ended up just decreasing the size by 2 pts and it fits fine now.
        I don't think you can use the Win32::GUI::AcceleratorTable for a widget ( I couldn't get tit to work for the Textfield anyway ). But here is some code that does what you are looking for. At least I think it does. You should really post more code to show the situation you are dealing as well as tell us what you have tried so far. Anyway, here's some code that gives an example of at least one way to do it:
        #!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; }