Thanks Harald. That did the trick, and it makes sense. Steve H. -----Original Message----- From: Piske, Harald [mailto:[EMAIL PROTECTED] Sent: Sunday, December 09, 2001 5:48 PM To: Howard, Steven (US - Tulsa); Perl-Win32-Gui-Users (E-mail) Subject: RE: [perl-win32-gui-users] Event handler stops working when style is added
I don't know for sure if that's the reason, but I remember Aldo warning about using the style option, because you inadvertently remove, or leave out, styles that may be important. Try using -addstyle to add styles and -remstyle to remove styles. That will leave all the standard style flags untouched. With a little luck, this also solves your problem. have fun, Harald -----Original Message----- From: Howard, Steven (US - Tulsa) [mailto:[EMAIL PROTECTED] Sent: Sunday, December 09, 2001 15:13 To: Perl-Win32-Gui-Users (E-mail) Subject: [perl-win32-gui-users] Event handler stops working when style is added I'm having a little problem with listboxes and the Click event handler when I add a -style option to the listbox. Hopefully someone here can spot what is going wrong and help me out. My list box is defined like this: my $lb = $disp->AddListbox ( -name => 'Paygroups', -pos => [20, 40], -height => $disp->ScaleHeight - 50, -width => 100, -style => WS_VSCROLL | WS_VISIBLE | WS_CHILD, ); # A second listbox is relevant to this example because items are added and removed in the event handler: my $locations = $disp->AddListbox ( -name => 'Locationbox', -pos => [140,40], -height => $disp->ScaleHeight - 50, -width => $disp->ScaleWidth - 160, # -style => WS_VSCROLL | WS_VISIBLE | WS_CHILD, ); #The first listbox is populated like this: my $select = qq{SELECT DISTINCT PAYGROUP, REPORTING_LOCATION FROM PS_JOB ORDER BY PAYGROUP, REPORTING_LOCATION}; my $sth = $dbh->prepare($select) || die "Can't prepare\n$select\n$DBI::errstr\n"; $sth->execute() || die "Can't execute\n$DBI::errstr\n"; while ($row = $sth->fetchrow_arrayref) { push (@{$payloc{$$row[0]}}, $$row[1]); } foreach (sort keys %payloc) { $lb->AddString("$_"); } # The Click event handler is this: sub Paygroups_Click { $locations->Clear(); my $item = $lb->SelectedItem(); my $key; if ($item != -1){ $key = $lb->GetString($item); foreach (sort(@{$payloc{$key}})) { $locations->AddString("$_"); } } print "Selected: $key\n"; } The problem is that if I comment out the -style option in the listbox $lb, everything works in the event handler subroutine exactly as I wanted it to, the only problem being that there are quite a large number of paygroups and no vertical scroll bar. That will be a large annoyance to others. When I un-remark the -style option on the $lb, the listbox is populated like I need, but the Click event handler no longer function. No print statements placed in the sub work, the second listbox is no longer populated with the locations listed in the @{$payloc{$item}} array - nothing. Can anyone tell me what is going wrong? Thanks in advance, Steve Howard Sr. DBA DTO Tulsa. - This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. - If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. - This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. - If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.