You can subscribe to this list here.
2001 |
Jan
(226) |
Feb
(139) |
Mar
(156) |
Apr
(95) |
May
(181) |
Jun
(166) |
Jul
(80) |
Aug
(59) |
Sep
(69) |
Oct
(83) |
Nov
(142) |
Dec
(33) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(42) |
Feb
(91) |
Mar
(76) |
Apr
(113) |
May
(67) |
Jun
(68) |
Jul
(37) |
Aug
(41) |
Sep
(16) |
Oct
(135) |
Nov
(51) |
Dec
(21) |
2003 |
Jan
(37) |
Feb
(36) |
Mar
(37) |
Apr
(103) |
May
(68) |
Jun
(70) |
Jul
(77) |
Aug
(12) |
Sep
(9) |
Oct
(53) |
Nov
(88) |
Dec
(63) |
2004 |
Jan
(263) |
Feb
(106) |
Mar
(36) |
Apr
(21) |
May
(21) |
Jun
(34) |
Jul
(33) |
Aug
(34) |
Sep
(35) |
Oct
(21) |
Nov
(43) |
Dec
(63) |
2005 |
Jan
(28) |
Feb
(42) |
Mar
(29) |
Apr
(14) |
May
(41) |
Jun
(20) |
Jul
(65) |
Aug
(136) |
Sep
(41) |
Oct
(74) |
Nov
(34) |
Dec
(94) |
2006 |
Jan
(85) |
Feb
(94) |
Mar
(68) |
Apr
(103) |
May
(66) |
Jun
(51) |
Jul
(24) |
Aug
(56) |
Sep
(57) |
Oct
(85) |
Nov
(73) |
Dec
(68) |
2007 |
Jan
(59) |
Feb
(32) |
Mar
(13) |
Apr
(32) |
May
(36) |
Jun
(36) |
Jul
(64) |
Aug
(35) |
Sep
(19) |
Oct
(10) |
Nov
(13) |
Dec
(20) |
2008 |
Jan
(26) |
Feb
(41) |
Mar
(19) |
Apr
(24) |
May
(16) |
Jun
(33) |
Jul
(34) |
Aug
(4) |
Sep
(11) |
Oct
|
Nov
(26) |
Dec
(23) |
2009 |
Jan
(5) |
Feb
(2) |
Mar
(21) |
Apr
(16) |
May
(13) |
Jun
(6) |
Jul
(34) |
Aug
(2) |
Sep
(1) |
Oct
(7) |
Nov
(5) |
Dec
(24) |
2010 |
Jan
(3) |
Feb
(5) |
Mar
(6) |
Apr
(6) |
May
(14) |
Jun
(6) |
Jul
(1) |
Aug
(12) |
Sep
(10) |
Oct
(9) |
Nov
|
Dec
(2) |
2011 |
Jan
(4) |
Feb
(5) |
Mar
(30) |
Apr
(1) |
May
(2) |
Jun
(5) |
Jul
(3) |
Aug
(2) |
Sep
(3) |
Oct
|
Nov
(6) |
Dec
|
2012 |
Jan
|
Feb
(10) |
Mar
|
Apr
|
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
|
Sep
(2) |
Oct
|
Nov
(2) |
Dec
(4) |
2013 |
Jan
(5) |
Feb
(3) |
Mar
|
Apr
(3) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(1) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(9) |
Nov
(7) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(5) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Kevin M. <kej...@ho...> - 2010-08-28 10:56:40
|
Hi Octavian, Thanks for your comments. It's good to know that you find it useful. I have been looking into Windows Accessibility to see how it works, and it seems that under normal circumstances (i.e. creating GUIs using C++, rather than Perl), the custom controls must provide an interface to the Accessibility API, which accessibility programs can use to interact with the control. Unfortunately, it looks like it is probably beyond the scope of the Win32::GUI module. Perhaps it is something that could be looked into for a separate module. Other people may have thoughts on the topic. Thanks again, Kevin. > Hi Kevin, > > Congratulations for the program! > > I have tested it with a screen reader and it works. I added the -dialogui => 1 option to the $winMain object to be able to use the keyboard for changing the focus. > > The only problem, which is an important one, is that if I arrow up or down in the list box, the screen reader announces just things like "item 1 of 8, item 2 of 8" and so on, without telling the label of the current item as it should. > > Do you (or somebody else) have any idea how to add accessibility features (MSAA) to this custom control in order to be as useful as a standard control? > > Basicly it should also report the labels of the list box items and not just print them. > > Thank you. > > Octavian > > ----- Original Message ----- > From: "Kevin Marshall"<kej...@ho...> > To:<per...@li...> > Sent: Saturday, August 28, 2010 8:07 AM > Subject: [perl-win32-gui-users] Win32::GUI Owner Drawn Controls > > > >> Hi everyone, >> >> After much experimentation, I have finally succeeded in creating an >> owner-drawn control in Win32::GUI. I decided to create this post >> detailing how to create an owner-drawn control in case someone else has >> the need to use one. >> >> For those of you who don't know, an owner-drawn control allows the user >> more control over the appearance of the control. This usually involves >> responding to messages sent whenever the control needs to be drawn and >> drawing the control in anyway that you wish. >> >> In order to get my sample to work you will need to install the PeekPoke >> module from CPAN. This module allows reading and writing of data to and >> from arbitrary memory locations. This is needed to set the height of the >> items of the listbox. More on this below. >> >> This example was created using ActiveState Perl v5.12.0 running on >> Windows XP. >> >> For this example, I will demonstrate how to create an owner-drawn >> listbox. The listbox will have items with a larger height, will display >> two lines of text with different formats, and an image. >> >> All of the files related to this example at the bottom of this post. >> >> Anyway, on with the example. >> >> I decided to store the information about each listbox item in an >> external XML file and use XML::Simple to parse it. This makes it rather >> simple to change the information for the listbox items. >> >> I also created 8 simple 40x40 bitmaps that will be displayed in each >> listbox item. >> >> Now for a description of the code. >> >> The first step is to create a window for our listbox and load our XML >> data from the file using XML::Simple::XMLin(). This is all fairly >> simple, so I won't bother explaining. >> >> Next step is to create a hook for the WM_MEASUREITEM message. This >> message is sent when the listbox is created so the user can specify the >> width and height of the listbox items. The $lParam variable contains the >> address of the structure that is passed to the message, which needs to >> be filled out. Here we use the poke() function to write the desired >> height into the structure, which in our case is 50. 16 is the offset of >> the itemHeight member of the structure which needs to contain the height >> that we want when the message returns. >> >> Next a hook is created for the WM_DRAWITEM message. This message is sent >> whenever an item in the listbox requires drawing. First step is to >> unpack the structure that is passed to the message. If the itemID >> contains -1, then the listbox is empty, so we simply return from the sub >> if this occurs. Otherwise, it contains the zero-based index of the item >> being drawn. The itemAction member contains the action required for the >> drawing. Here we respond if the entire item needs drawing. To begin with >> we draw the bitmap for the item. First we create a compatible DC from >> the DC that is passed to the message, then select the bitmap for the >> current item into it. Then we BitBlt() the contents of the compatible DC >> into the item DC. Next we need to draw the text that will be displayed >> in the item. We create a large font that will be used for the item's >> heading, and select the font into the item DC, remembering the old font. >> Then we draw the text into the item DC using DrawText(). Next we select >> the old font, and draw the other text that will be displayed in the >> item. That completes the drawing for the item, so we return from our sub. >> >> Next step is to create our listbox. The only difference here from >> creating an ordinary listbox is to specify the LBS_OWNERDRAWFIXED style. >> This specifies that the listbox will be owner-drawn, and all the items >> have the same height. An alternative would be to use the >> LBS_OWNERDRAWVARIABLE style instead, which specifies that each item will >> have a different height. In this case, the WM_MEASUREITEM would be sent >> for each item when the control is created, not just once like our case. >> >> Next we loop through each item returned from the XML file, create a >> Win32::GUI::Bitmap from the file name specified in the file, and add the >> relevant data to an array which will be used when drawing the listbox >> items. We also add an item to the listbox using the text as a place >> holder, although it won't get drawn, so it doesn't matter what is >> inserted here. Then we simply show the window and enter the dialog phase. >> >> The listbox acts like any other listbox, it just has larger items and >> different content. This is demonstrated here when an item is selected: >> the heading and text of the selected item are printed. >> >> That's it for creating an owner-drawn listbox. >> >> Various other controls can also be owner-draw, such as buttons, labels, >> and combo boxes. I have yet to try it with other controls, but it >> shouldn't be much different from a listbox. >> >> More information about owner-draw controls can be found in the Windows >> SDK Documentation. >> >> I hope that someone finds this example useful. If you come up with >> something interesting, I wouldn't mind a reply post detailing what you >> have done. >> >> Kevin. >> >> Here are the files: >> >> This is the main code: >> >> #!perl >> ################################################################################ >> # >> # customlistbox.pl >> # >> # Win32::GUI Owner-drawn Controls >> # >> # This script demonstrates the creation and use of an owner-drawn listbox. >> # >> # Requirements: >> # Win32::GUI >> # PeekPoke >> # XML::Simple >> # >> # This program was written using ActiveState Perl 5.12.0 Build 1200 >> running on >> # Windows XP and using Win32::GUI v1.06, PeekPoke v0.01, and >> XML::Simple v2.18 >> # >> ################################################################################ >> use strict; >> use warnings; >> >> use PeekPoke qw(poke); >> use Win32::GUI qw(); >> use Win32::GUI::Constants qw(CW_USEDEFAULT WM_MEASUREITEM WM_DRAWITEM >> ODA_DRAWENTIRE SRCCOPY DT_LEFT DT_TOP DT_WORDBREAK LBS_OWNERDRAWFIXED); >> use XML::Simple; >> >> # Create our main window >> my $winMain = Win32::GUI::Window->new( >> -name => 'winMain', >> -text => 'Owner-Drawn Listbox', >> -size => [ 320, 240 ], >> -minwidth => 320, >> -minheight => 240, >> ); >> >> # Load XML data >> my $ListBoxItems = XMLin('customlistbox.xml'); >> my @Items; >> >> # Create a hook to handle WM_MEASUREITEM message. This message is used >> to set the >> # height of the listbox items. >> $winMain->Hook( >> WM_MEASUREITEM, >> sub { >> my( $self, $wParam, $lParam, $type, $msgcode ) = @_; >> return 1 unless $type == 0; >> return 1 unless $msgcode == WM_MEASUREITEM; >> # Write desired height of items to structure. 16 is the offset >> of the >> # itemHeight member of the MEASUREITEMSTRUCT structure >> poke( $lParam + 16, 50 ); >> return 1; >> }, >> ); >> >> # Create a hook to handle the WM_DRAWITEM message. This message is sent >> whenever >> # a listbox item needs drawing >> $winMain->Hook( >> WM_DRAWITEM, >> sub { >> my( $self, $wParam, $lParam, $type, $msgcode ) = @_; >> my %drawitem; >> # Unpack data from the structure >> @drawitem{qw(CtlType CtlID itemID itemAction itemState hwndItem >> hDC left >> top right bottom itemData)} = unpack 'IIIIILLllllL', unpack >> 'P48', >> pack 'L', $lParam; >> # itemID will contain -1 if there are no items, so we just return >> return 1 if $drawitem{'itemID'} == -1; >> >> # Draw the bitmap and text for the list box item. >> if( $drawitem{'itemAction'} == ODA_DRAWENTIRE ){ >> my $hDC = $drawitem{'hDC'}; >> >> # Display the bitmap associated with the item. >> my $image = $Items[ $drawitem{'itemID'} ]{'image'}; >> my $memdc = Win32::GUI::DC::CreateCompatibleDC($hDC); >> my $oldimage = $memdc->SelectObject($image); >> Win32::GUI::DC::BitBlt( >> $hDC, $drawitem{'right'} - 45, $drawitem{'top'} + 5, >> 40, 40, $memdc, 0, 0, SRCCOPY >> ); >> >> # Display the text associated with the item. >> my $titlefont = Win32::GUI::Font->new( >> -height => 12, >> -weight => 700, >> ); >> my $oldfont = Win32::GUI::DC::SelectObject( $hDC, $titlefont ); >> Win32::GUI::DC::DrawText( >> $hDC, >> $Items[ $drawitem{'itemID'} ]{'heading'}, >> $drawitem{'left'} + 5, $drawitem{'top'} + 5, >> $drawitem{'right'} - 50, $drawitem{'bottom'} - 5, >> ); >> Win32::GUI::DC::SelectObject($drawitem{'hDC'}, $oldfont); >> Win32::GUI::DC::DrawText( >> $hDC, >> $Items[ $drawitem{'itemID'} ]{'text'}, >> $drawitem{'left'} + 5, $drawitem{'top'} + 30, >> $drawitem{'right'} - 50, $drawitem{'bottom'} - 5, >> DT_LEFT | DT_TOP | DT_WORDBREAK >> ); >> } >> return 1; >> } >> ); >> >> # Create our listbox control >> my $lsbCustom = $winMain->AddListbox( >> -name => 'lsbCustom', >> -pos => [ 10, 10 ], >> -size => [ $winMain->ScaleWidth() - 20, >> $winMain->ScaleHeight() - 20 ], >> -nointegralheight => 1, >> -vscroll => 1, >> -pushstyle => LBS_OWNERDRAWFIXED, >> ); >> # Add items to listbox >> foreach my $item ( @{ $ListBoxItems->{'item'} } ){ >> my $bmp = Win32::GUI::Bitmap->new( $item->{'image'} ); >> push @Items, { >> heading => $item->{'heading'}, >> text => $item->{'text'}, >> image => $bmp, >> }; >> $lsbCustom->InsertString( $item->{text} ); >> } >> >> $winMain->Show(); >> >> Win32::GUI::Dialog(); >> >> sub winMain_Terminate { >> return -1; >> } >> >> sub winMain_Resize { >> my $width = $winMain->ScaleWidth(); >> my $height = $winMain->ScaleHeight(); >> $lsbCustom->Resize( $width - 20, $height - 20 ); >> return 1; >> } >> >> sub lsbCustom_SelChange { >> my $index = $lsbCustom->GetCurSel(); >> print<<EOT; >> $Items[$index]{heading} >> $Items[$index]{text} >> EOT >> return 1; >> } >> >> __END__ # of customlistbox.pl >> >> >> >> This is the XML file that stores the data for each item in the listbox: >> >> <!-- customlistbox.xml --> >> <listboxitems> >> <item> >> <heading>Item 1</heading> >> <image>item1.bmp</image> >> <text>This is some text for item 1</text> >> </item> >> <item> >> <heading>Item 2</heading> >> <image>item2.bmp</image> >> <text>This is some text for item 2</text> >> </item> >> <item> >> <heading>Item 3</heading> >> <image>item3.bmp</image> >> <text>This is some text for item 3</text> >> </item> >> <item> >> <heading>Item 4</heading> >> <image>item4.bmp</image> >> <text>This is some text for item 4</text> >> </item> >> <item> >> <heading>Item 5</heading> >> <image>item5.bmp</image> >> <text>This is some text for item 5</text> >> </item> >> <item> >> <heading>Item 6</heading> >> <image>item6.bmp</image> >> <text>This is some text for item 6</text> >> </item> >> <item> >> <heading>Item 7</heading> >> <image>item7.bmp</image> >> <text>This is some text for item 7</text> >> </item> >> <item> >> <heading>Item 8</heading> >> <image>item8.bmp</image> >> <text>This is some text for item 8</text> >> </item> >> </listboxitems> >> <!-- end of customlistbox.xml --> >> >> If you execute this script, it will create a file called pics.7z file, >> which will contain the 8 bitmaps needed for this sample: >> >> #!perl >> use strict; >> use warnings; >> >> use MIME::Base64; >> >> open my $fh, '>', 'pics.7z' or die $!; >> binmode $fh; >> print {$fh} MIME::Base64::decode( >> 'N3q8ryccAANPwVVtOwEAAAAAAAAjAAAAAAAAAJASfkEAIRNayxcGoME2nyL7I4JzfZi4oHYg66A8 >> nm6WsRvMHTne+oX2PHIJM7ayDfdnbZ0DmCN8Mf70re7XhMyBeX4+OafcrXhvLiG669M+EMuzgnG7 >> JvuHqsUDJQokFWg0SzmcesrNrAHXMApzksKeghHSU1HMZ64/6cXUSTzQaCJdREH7ieEAAACBMweu >> D9Uvw85WbCkfSCtBMmjGwE0B4XqeDwoyHBt1/T8r3bH8o1BWWPseZbEvATR9EeL4s4UpAsX59y9L >> RF7bndv+H7Dz0pCHk43K2555nX5iAiwmibuV8uDOx83QgHHTqy9AORcPkqPfO6duMlkZ+UYo1t0/ >> TapX+1Jl1LSaAcpSost05OeRFdSSTWGt3tvzEPzEG8sIrZ+vTlWBzDSQrvvsJkdLC0r63jRJhP2+ >> sK6GAAAXBoCFAQmAtgAHCwEAASMDAQEFXQAQAAAMgWMKAVQcA6kAAA=='); >> close $fh; >> >> __END__ >> >> >> >> >> ------------------------------------------------------------------------------ >> Sell apps to millions through the Intel(R) Atom(Tm) Developer Program >> Be part of this innovative community and reach millions of netbook users >> worldwide. Take advantage of special opportunities to increase revenue and >> speed time-to-market. Join now, and jumpstart your future. >> http://p.sf.net/sfu/intel-atom-d2d >> _______________________________________________ >> Perl-Win32-GUI-Users mailing list >> Per...@li... >> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >> http://perl-win32-gui.sourceforge.net/ >> > > |
From: Octavian R. <ora...@gm...> - 2010-08-28 08:23:55
|
Hi Kevin, Congratulations for the program! I have tested it with a screen reader and it works. I added the -dialogui => 1 option to the $winMain object to be able to use the keyboard for changing the focus. The only problem, which is an important one, is that if I arrow up or down in the list box, the screen reader announces just things like "item 1 of 8, item 2 of 8" and so on, without telling the label of the current item as it should. Do you (or somebody else) have any idea how to add accessibility features (MSAA) to this custom control in order to be as useful as a standard control? Basicly it should also report the labels of the list box items and not just print them. Thank you. Octavian ----- Original Message ----- From: "Kevin Marshall" <kej...@ho...> To: <per...@li...> Sent: Saturday, August 28, 2010 8:07 AM Subject: [perl-win32-gui-users] Win32::GUI Owner Drawn Controls > Hi everyone, > > After much experimentation, I have finally succeeded in creating an > owner-drawn control in Win32::GUI. I decided to create this post > detailing how to create an owner-drawn control in case someone else has > the need to use one. > > For those of you who don't know, an owner-drawn control allows the user > more control over the appearance of the control. This usually involves > responding to messages sent whenever the control needs to be drawn and > drawing the control in anyway that you wish. > > In order to get my sample to work you will need to install the PeekPoke > module from CPAN. This module allows reading and writing of data to and > from arbitrary memory locations. This is needed to set the height of the > items of the listbox. More on this below. > > This example was created using ActiveState Perl v5.12.0 running on > Windows XP. > > For this example, I will demonstrate how to create an owner-drawn > listbox. The listbox will have items with a larger height, will display > two lines of text with different formats, and an image. > > All of the files related to this example at the bottom of this post. > > Anyway, on with the example. > > I decided to store the information about each listbox item in an > external XML file and use XML::Simple to parse it. This makes it rather > simple to change the information for the listbox items. > > I also created 8 simple 40x40 bitmaps that will be displayed in each > listbox item. > > Now for a description of the code. > > The first step is to create a window for our listbox and load our XML > data from the file using XML::Simple::XMLin(). This is all fairly > simple, so I won't bother explaining. > > Next step is to create a hook for the WM_MEASUREITEM message. This > message is sent when the listbox is created so the user can specify the > width and height of the listbox items. The $lParam variable contains the > address of the structure that is passed to the message, which needs to > be filled out. Here we use the poke() function to write the desired > height into the structure, which in our case is 50. 16 is the offset of > the itemHeight member of the structure which needs to contain the height > that we want when the message returns. > > Next a hook is created for the WM_DRAWITEM message. This message is sent > whenever an item in the listbox requires drawing. First step is to > unpack the structure that is passed to the message. If the itemID > contains -1, then the listbox is empty, so we simply return from the sub > if this occurs. Otherwise, it contains the zero-based index of the item > being drawn. The itemAction member contains the action required for the > drawing. Here we respond if the entire item needs drawing. To begin with > we draw the bitmap for the item. First we create a compatible DC from > the DC that is passed to the message, then select the bitmap for the > current item into it. Then we BitBlt() the contents of the compatible DC > into the item DC. Next we need to draw the text that will be displayed > in the item. We create a large font that will be used for the item's > heading, and select the font into the item DC, remembering the old font. > Then we draw the text into the item DC using DrawText(). Next we select > the old font, and draw the other text that will be displayed in the > item. That completes the drawing for the item, so we return from our sub. > > Next step is to create our listbox. The only difference here from > creating an ordinary listbox is to specify the LBS_OWNERDRAWFIXED style. > This specifies that the listbox will be owner-drawn, and all the items > have the same height. An alternative would be to use the > LBS_OWNERDRAWVARIABLE style instead, which specifies that each item will > have a different height. In this case, the WM_MEASUREITEM would be sent > for each item when the control is created, not just once like our case. > > Next we loop through each item returned from the XML file, create a > Win32::GUI::Bitmap from the file name specified in the file, and add the > relevant data to an array which will be used when drawing the listbox > items. We also add an item to the listbox using the text as a place > holder, although it won't get drawn, so it doesn't matter what is > inserted here. Then we simply show the window and enter the dialog phase. > > The listbox acts like any other listbox, it just has larger items and > different content. This is demonstrated here when an item is selected: > the heading and text of the selected item are printed. > > That's it for creating an owner-drawn listbox. > > Various other controls can also be owner-draw, such as buttons, labels, > and combo boxes. I have yet to try it with other controls, but it > shouldn't be much different from a listbox. > > More information about owner-draw controls can be found in the Windows > SDK Documentation. > > I hope that someone finds this example useful. If you come up with > something interesting, I wouldn't mind a reply post detailing what you > have done. > > Kevin. > > Here are the files: > > This is the main code: > > #!perl > ################################################################################ > # > # customlistbox.pl > # > # Win32::GUI Owner-drawn Controls > # > # This script demonstrates the creation and use of an owner-drawn listbox. > # > # Requirements: > # Win32::GUI > # PeekPoke > # XML::Simple > # > # This program was written using ActiveState Perl 5.12.0 Build 1200 > running on > # Windows XP and using Win32::GUI v1.06, PeekPoke v0.01, and > XML::Simple v2.18 > # > ################################################################################ > use strict; > use warnings; > > use PeekPoke qw(poke); > use Win32::GUI qw(); > use Win32::GUI::Constants qw(CW_USEDEFAULT WM_MEASUREITEM WM_DRAWITEM > ODA_DRAWENTIRE SRCCOPY DT_LEFT DT_TOP DT_WORDBREAK LBS_OWNERDRAWFIXED); > use XML::Simple; > > # Create our main window > my $winMain = Win32::GUI::Window->new( > -name => 'winMain', > -text => 'Owner-Drawn Listbox', > -size => [ 320, 240 ], > -minwidth => 320, > -minheight => 240, > ); > > # Load XML data > my $ListBoxItems = XMLin('customlistbox.xml'); > my @Items; > > # Create a hook to handle WM_MEASUREITEM message. This message is used > to set the > # height of the listbox items. > $winMain->Hook( > WM_MEASUREITEM, > sub { > my( $self, $wParam, $lParam, $type, $msgcode ) = @_; > return 1 unless $type == 0; > return 1 unless $msgcode == WM_MEASUREITEM; > # Write desired height of items to structure. 16 is the offset > of the > # itemHeight member of the MEASUREITEMSTRUCT structure > poke( $lParam + 16, 50 ); > return 1; > }, > ); > > # Create a hook to handle the WM_DRAWITEM message. This message is sent > whenever > # a listbox item needs drawing > $winMain->Hook( > WM_DRAWITEM, > sub { > my( $self, $wParam, $lParam, $type, $msgcode ) = @_; > my %drawitem; > # Unpack data from the structure > @drawitem{qw(CtlType CtlID itemID itemAction itemState hwndItem > hDC left > top right bottom itemData)} = unpack 'IIIIILLllllL', unpack > 'P48', > pack 'L', $lParam; > # itemID will contain -1 if there are no items, so we just return > return 1 if $drawitem{'itemID'} == -1; > > # Draw the bitmap and text for the list box item. > if( $drawitem{'itemAction'} == ODA_DRAWENTIRE ){ > my $hDC = $drawitem{'hDC'}; > > # Display the bitmap associated with the item. > my $image = $Items[ $drawitem{'itemID'} ]{'image'}; > my $memdc = Win32::GUI::DC::CreateCompatibleDC($hDC); > my $oldimage = $memdc->SelectObject($image); > Win32::GUI::DC::BitBlt( > $hDC, $drawitem{'right'} - 45, $drawitem{'top'} + 5, > 40, 40, $memdc, 0, 0, SRCCOPY > ); > > # Display the text associated with the item. > my $titlefont = Win32::GUI::Font->new( > -height => 12, > -weight => 700, > ); > my $oldfont = Win32::GUI::DC::SelectObject( $hDC, $titlefont ); > Win32::GUI::DC::DrawText( > $hDC, > $Items[ $drawitem{'itemID'} ]{'heading'}, > $drawitem{'left'} + 5, $drawitem{'top'} + 5, > $drawitem{'right'} - 50, $drawitem{'bottom'} - 5, > ); > Win32::GUI::DC::SelectObject($drawitem{'hDC'}, $oldfont); > Win32::GUI::DC::DrawText( > $hDC, > $Items[ $drawitem{'itemID'} ]{'text'}, > $drawitem{'left'} + 5, $drawitem{'top'} + 30, > $drawitem{'right'} - 50, $drawitem{'bottom'} - 5, > DT_LEFT | DT_TOP | DT_WORDBREAK > ); > } > return 1; > } > ); > > # Create our listbox control > my $lsbCustom = $winMain->AddListbox( > -name => 'lsbCustom', > -pos => [ 10, 10 ], > -size => [ $winMain->ScaleWidth() - 20, > $winMain->ScaleHeight() - 20 ], > -nointegralheight => 1, > -vscroll => 1, > -pushstyle => LBS_OWNERDRAWFIXED, > ); > # Add items to listbox > foreach my $item ( @{ $ListBoxItems->{'item'} } ){ > my $bmp = Win32::GUI::Bitmap->new( $item->{'image'} ); > push @Items, { > heading => $item->{'heading'}, > text => $item->{'text'}, > image => $bmp, > }; > $lsbCustom->InsertString( $item->{text} ); > } > > $winMain->Show(); > > Win32::GUI::Dialog(); > > sub winMain_Terminate { > return -1; > } > > sub winMain_Resize { > my $width = $winMain->ScaleWidth(); > my $height = $winMain->ScaleHeight(); > $lsbCustom->Resize( $width - 20, $height - 20 ); > return 1; > } > > sub lsbCustom_SelChange { > my $index = $lsbCustom->GetCurSel(); > print <<EOT; > $Items[$index]{heading} > $Items[$index]{text} > EOT > return 1; > } > > __END__ # of customlistbox.pl > > > > This is the XML file that stores the data for each item in the listbox: > > <!-- customlistbox.xml --> > <listboxitems> > <item> > <heading>Item 1</heading> > <image>item1.bmp</image> > <text>This is some text for item 1</text> > </item> > <item> > <heading>Item 2</heading> > <image>item2.bmp</image> > <text>This is some text for item 2</text> > </item> > <item> > <heading>Item 3</heading> > <image>item3.bmp</image> > <text>This is some text for item 3</text> > </item> > <item> > <heading>Item 4</heading> > <image>item4.bmp</image> > <text>This is some text for item 4</text> > </item> > <item> > <heading>Item 5</heading> > <image>item5.bmp</image> > <text>This is some text for item 5</text> > </item> > <item> > <heading>Item 6</heading> > <image>item6.bmp</image> > <text>This is some text for item 6</text> > </item> > <item> > <heading>Item 7</heading> > <image>item7.bmp</image> > <text>This is some text for item 7</text> > </item> > <item> > <heading>Item 8</heading> > <image>item8.bmp</image> > <text>This is some text for item 8</text> > </item> > </listboxitems> > <!-- end of customlistbox.xml --> > > If you execute this script, it will create a file called pics.7z file, > which will contain the 8 bitmaps needed for this sample: > > #!perl > use strict; > use warnings; > > use MIME::Base64; > > open my $fh, '>', 'pics.7z' or die $!; > binmode $fh; > print {$fh} MIME::Base64::decode( > 'N3q8ryccAANPwVVtOwEAAAAAAAAjAAAAAAAAAJASfkEAIRNayxcGoME2nyL7I4JzfZi4oHYg66A8 > nm6WsRvMHTne+oX2PHIJM7ayDfdnbZ0DmCN8Mf70re7XhMyBeX4+OafcrXhvLiG669M+EMuzgnG7 > JvuHqsUDJQokFWg0SzmcesrNrAHXMApzksKeghHSU1HMZ64/6cXUSTzQaCJdREH7ieEAAACBMweu > D9Uvw85WbCkfSCtBMmjGwE0B4XqeDwoyHBt1/T8r3bH8o1BWWPseZbEvATR9EeL4s4UpAsX59y9L > RF7bndv+H7Dz0pCHk43K2555nX5iAiwmibuV8uDOx83QgHHTqy9AORcPkqPfO6duMlkZ+UYo1t0/ > TapX+1Jl1LSaAcpSost05OeRFdSSTWGt3tvzEPzEG8sIrZ+vTlWBzDSQrvvsJkdLC0r63jRJhP2+ > sK6GAAAXBoCFAQmAtgAHCwEAASMDAQEFXQAQAAAMgWMKAVQcA6kAAA=='); > close $fh; > > __END__ > > > > > ------------------------------------------------------------------------------ > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program > Be part of this innovative community and reach millions of netbook users > worldwide. Take advantage of special opportunities to increase revenue and > speed time-to-market. Join now, and jumpstart your future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ |
From: Kevin M. <kej...@ho...> - 2010-08-28 05:08:03
|
Hi everyone, After much experimentation, I have finally succeeded in creating an owner-drawn control in Win32::GUI. I decided to create this post detailing how to create an owner-drawn control in case someone else has the need to use one. For those of you who don't know, an owner-drawn control allows the user more control over the appearance of the control. This usually involves responding to messages sent whenever the control needs to be drawn and drawing the control in anyway that you wish. In order to get my sample to work you will need to install the PeekPoke module from CPAN. This module allows reading and writing of data to and from arbitrary memory locations. This is needed to set the height of the items of the listbox. More on this below. This example was created using ActiveState Perl v5.12.0 running on Windows XP. For this example, I will demonstrate how to create an owner-drawn listbox. The listbox will have items with a larger height, will display two lines of text with different formats, and an image. All of the files related to this example at the bottom of this post. Anyway, on with the example. I decided to store the information about each listbox item in an external XML file and use XML::Simple to parse it. This makes it rather simple to change the information for the listbox items. I also created 8 simple 40x40 bitmaps that will be displayed in each listbox item. Now for a description of the code. The first step is to create a window for our listbox and load our XML data from the file using XML::Simple::XMLin(). This is all fairly simple, so I won't bother explaining. Next step is to create a hook for the WM_MEASUREITEM message. This message is sent when the listbox is created so the user can specify the width and height of the listbox items. The $lParam variable contains the address of the structure that is passed to the message, which needs to be filled out. Here we use the poke() function to write the desired height into the structure, which in our case is 50. 16 is the offset of the itemHeight member of the structure which needs to contain the height that we want when the message returns. Next a hook is created for the WM_DRAWITEM message. This message is sent whenever an item in the listbox requires drawing. First step is to unpack the structure that is passed to the message. If the itemID contains -1, then the listbox is empty, so we simply return from the sub if this occurs. Otherwise, it contains the zero-based index of the item being drawn. The itemAction member contains the action required for the drawing. Here we respond if the entire item needs drawing. To begin with we draw the bitmap for the item. First we create a compatible DC from the DC that is passed to the message, then select the bitmap for the current item into it. Then we BitBlt() the contents of the compatible DC into the item DC. Next we need to draw the text that will be displayed in the item. We create a large font that will be used for the item's heading, and select the font into the item DC, remembering the old font. Then we draw the text into the item DC using DrawText(). Next we select the old font, and draw the other text that will be displayed in the item. That completes the drawing for the item, so we return from our sub. Next step is to create our listbox. The only difference here from creating an ordinary listbox is to specify the LBS_OWNERDRAWFIXED style. This specifies that the listbox will be owner-drawn, and all the items have the same height. An alternative would be to use the LBS_OWNERDRAWVARIABLE style instead, which specifies that each item will have a different height. In this case, the WM_MEASUREITEM would be sent for each item when the control is created, not just once like our case. Next we loop through each item returned from the XML file, create a Win32::GUI::Bitmap from the file name specified in the file, and add the relevant data to an array which will be used when drawing the listbox items. We also add an item to the listbox using the text as a place holder, although it won't get drawn, so it doesn't matter what is inserted here. Then we simply show the window and enter the dialog phase. The listbox acts like any other listbox, it just has larger items and different content. This is demonstrated here when an item is selected: the heading and text of the selected item are printed. That's it for creating an owner-drawn listbox. Various other controls can also be owner-draw, such as buttons, labels, and combo boxes. I have yet to try it with other controls, but it shouldn't be much different from a listbox. More information about owner-draw controls can be found in the Windows SDK Documentation. I hope that someone finds this example useful. If you come up with something interesting, I wouldn't mind a reply post detailing what you have done. Kevin. Here are the files: This is the main code: #!perl ################################################################################ # # customlistbox.pl # # Win32::GUI Owner-drawn Controls # # This script demonstrates the creation and use of an owner-drawn listbox. # # Requirements: # Win32::GUI # PeekPoke # XML::Simple # # This program was written using ActiveState Perl 5.12.0 Build 1200 running on # Windows XP and using Win32::GUI v1.06, PeekPoke v0.01, and XML::Simple v2.18 # ################################################################################ use strict; use warnings; use PeekPoke qw(poke); use Win32::GUI qw(); use Win32::GUI::Constants qw(CW_USEDEFAULT WM_MEASUREITEM WM_DRAWITEM ODA_DRAWENTIRE SRCCOPY DT_LEFT DT_TOP DT_WORDBREAK LBS_OWNERDRAWFIXED); use XML::Simple; # Create our main window my $winMain = Win32::GUI::Window->new( -name => 'winMain', -text => 'Owner-Drawn Listbox', -size => [ 320, 240 ], -minwidth => 320, -minheight => 240, ); # Load XML data my $ListBoxItems = XMLin('customlistbox.xml'); my @Items; # Create a hook to handle WM_MEASUREITEM message. This message is used to set the # height of the listbox items. $winMain->Hook( WM_MEASUREITEM, sub { my( $self, $wParam, $lParam, $type, $msgcode ) = @_; return 1 unless $type == 0; return 1 unless $msgcode == WM_MEASUREITEM; # Write desired height of items to structure. 16 is the offset of the # itemHeight member of the MEASUREITEMSTRUCT structure poke( $lParam + 16, 50 ); return 1; }, ); # Create a hook to handle the WM_DRAWITEM message. This message is sent whenever # a listbox item needs drawing $winMain->Hook( WM_DRAWITEM, sub { my( $self, $wParam, $lParam, $type, $msgcode ) = @_; my %drawitem; # Unpack data from the structure @drawitem{qw(CtlType CtlID itemID itemAction itemState hwndItem hDC left top right bottom itemData)} = unpack 'IIIIILLllllL', unpack 'P48', pack 'L', $lParam; # itemID will contain -1 if there are no items, so we just return return 1 if $drawitem{'itemID'} == -1; # Draw the bitmap and text for the list box item. if( $drawitem{'itemAction'} == ODA_DRAWENTIRE ){ my $hDC = $drawitem{'hDC'}; # Display the bitmap associated with the item. my $image = $Items[ $drawitem{'itemID'} ]{'image'}; my $memdc = Win32::GUI::DC::CreateCompatibleDC($hDC); my $oldimage = $memdc->SelectObject($image); Win32::GUI::DC::BitBlt( $hDC, $drawitem{'right'} - 45, $drawitem{'top'} + 5, 40, 40, $memdc, 0, 0, SRCCOPY ); # Display the text associated with the item. my $titlefont = Win32::GUI::Font->new( -height => 12, -weight => 700, ); my $oldfont = Win32::GUI::DC::SelectObject( $hDC, $titlefont ); Win32::GUI::DC::DrawText( $hDC, $Items[ $drawitem{'itemID'} ]{'heading'}, $drawitem{'left'} + 5, $drawitem{'top'} + 5, $drawitem{'right'} - 50, $drawitem{'bottom'} - 5, ); Win32::GUI::DC::SelectObject($drawitem{'hDC'}, $oldfont); Win32::GUI::DC::DrawText( $hDC, $Items[ $drawitem{'itemID'} ]{'text'}, $drawitem{'left'} + 5, $drawitem{'top'} + 30, $drawitem{'right'} - 50, $drawitem{'bottom'} - 5, DT_LEFT | DT_TOP | DT_WORDBREAK ); } return 1; } ); # Create our listbox control my $lsbCustom = $winMain->AddListbox( -name => 'lsbCustom', -pos => [ 10, 10 ], -size => [ $winMain->ScaleWidth() - 20, $winMain->ScaleHeight() - 20 ], -nointegralheight => 1, -vscroll => 1, -pushstyle => LBS_OWNERDRAWFIXED, ); # Add items to listbox foreach my $item ( @{ $ListBoxItems->{'item'} } ){ my $bmp = Win32::GUI::Bitmap->new( $item->{'image'} ); push @Items, { heading => $item->{'heading'}, text => $item->{'text'}, image => $bmp, }; $lsbCustom->InsertString( $item->{text} ); } $winMain->Show(); Win32::GUI::Dialog(); sub winMain_Terminate { return -1; } sub winMain_Resize { my $width = $winMain->ScaleWidth(); my $height = $winMain->ScaleHeight(); $lsbCustom->Resize( $width - 20, $height - 20 ); return 1; } sub lsbCustom_SelChange { my $index = $lsbCustom->GetCurSel(); print <<EOT; $Items[$index]{heading} $Items[$index]{text} EOT return 1; } __END__ # of customlistbox.pl This is the XML file that stores the data for each item in the listbox: <!-- customlistbox.xml --> <listboxitems> <item> <heading>Item 1</heading> <image>item1.bmp</image> <text>This is some text for item 1</text> </item> <item> <heading>Item 2</heading> <image>item2.bmp</image> <text>This is some text for item 2</text> </item> <item> <heading>Item 3</heading> <image>item3.bmp</image> <text>This is some text for item 3</text> </item> <item> <heading>Item 4</heading> <image>item4.bmp</image> <text>This is some text for item 4</text> </item> <item> <heading>Item 5</heading> <image>item5.bmp</image> <text>This is some text for item 5</text> </item> <item> <heading>Item 6</heading> <image>item6.bmp</image> <text>This is some text for item 6</text> </item> <item> <heading>Item 7</heading> <image>item7.bmp</image> <text>This is some text for item 7</text> </item> <item> <heading>Item 8</heading> <image>item8.bmp</image> <text>This is some text for item 8</text> </item> </listboxitems> <!-- end of customlistbox.xml --> If you execute this script, it will create a file called pics.7z file, which will contain the 8 bitmaps needed for this sample: #!perl use strict; use warnings; use MIME::Base64; open my $fh, '>', 'pics.7z' or die $!; binmode $fh; print {$fh} MIME::Base64::decode( 'N3q8ryccAANPwVVtOwEAAAAAAAAjAAAAAAAAAJASfkEAIRNayxcGoME2nyL7I4JzfZi4oHYg66A8 nm6WsRvMHTne+oX2PHIJM7ayDfdnbZ0DmCN8Mf70re7XhMyBeX4+OafcrXhvLiG669M+EMuzgnG7 JvuHqsUDJQokFWg0SzmcesrNrAHXMApzksKeghHSU1HMZ64/6cXUSTzQaCJdREH7ieEAAACBMweu D9Uvw85WbCkfSCtBMmjGwE0B4XqeDwoyHBt1/T8r3bH8o1BWWPseZbEvATR9EeL4s4UpAsX59y9L RF7bndv+H7Dz0pCHk43K2555nX5iAiwmibuV8uDOx83QgHHTqy9AORcPkqPfO6duMlkZ+UYo1t0/ TapX+1Jl1LSaAcpSost05OeRFdSSTWGt3tvzEPzEG8sIrZ+vTlWBzDSQrvvsJkdLC0r63jRJhP2+ sK6GAAAXBoCFAQmAtgAHCwEAASMDAQEFXQAQAAAMgWMKAVQcA6kAAA=='); close $fh; __END__ |
From: Kevin M. <kej...@ho...> - 2010-08-23 05:58:07
|
Hi, Do you mean you are trying to read values from a listview control in a Window that you have created or a listview in a Window for another application. If you mean one you created, then this is how you do it: foreach my $index ($listvew->SelectedItems()){ my %info = $listview->GetItem($index); Data::Dump::dump(\%info); } __END__ On the other hand, if you are trying to get info about a listview item in a window that you haven't created, this is a little more involved (and probably not recommended). There is a previous post on this mailing list where someone wanted to access a toolbar in another application. Perhaps have a read of that post if this is what you are looking for. Kevin. > hello all, > I m trying to read the GUI and get the values. > there is a tab in GUI for which the Winspy shows the name as > "syslistview32" > how will i read the values of this item . > kindly help > -shilpa > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ |
From: shilpa h. <200...@gm...> - 2010-08-17 05:52:55
|
hello all, I m trying to read the GUI and get the values. there is a tab in GUI for which the Winspy shows the name as "syslistview32" how will i read the values of this item . kindly help -shilpa |
From: Dave M. <dsm...@gm...> - 2010-07-02 12:09:13
|
I have a lengthy textfield in my project, I found that if I enter a repeated number into the field it crashes the program. Repeated letters do not have the same effect. I removed all subroutines in my program that were affected by the control to be sure it wasn't in my code somewhere. Does anyone else notice this behavior, or is this a known bug, or am I just missing something? Thanks in advance. Dave |
From: Manuel S. <Man...@gm...> - 2010-06-21 15:25:18
|
Hi, perhaps I'm just being stupid, but I want to remove a Textfield after I added it, so: my $main=Win32::GUI::Window->new(-name => 'Main'); my $textField=$main->AddTextfield(-name => "textfield",); and then I want to remove the Textfield again. is that possible? Thanks Manuel |
From: Dagan <apt...@ho...> - 2010-06-11 11:35:49
|
Does anyone happen to know how do I go about adding a newline to a standard text field without the square non alpha numeric character showing up? It's probably simple, here is the code i'm using currently: $Main->tfOutput->Append($msg." \n"); This code DOES create newlines, but it contains a square at the end. \r\n does the same thing and \r does nothing Thanks =D _________________________________________________________________ The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5 |
From: Kevin M. <kej...@ho...> - 2010-06-10 12:58:41
|
Prasad, Did you create this ListView control yourself in a Perl Win32::GUI script? If so, you can use the object returned when creating the control to access methods for that control, like so: my $listview = Win32::GUI::ListView->new(...); # or my $listview = $parent->AddListView(...); Here is some code that can be used to iterate each item in a ListView control: for my $i (0 .. $listview->GetItemCount()-1){ my %item = $listview->GetItem($i); } To get at any of the items in a ListView control, you need to know the index of the item that you wish to query. Kevin. > > Hello, > > I want to read values present inside ListView Control which is > embedded inside System Tab Control. > > Flow is like this > > Form --------contains------------à Blank Dialog Class > --------contains-------------à System Tab Control ------------ one tab > contain --------à List view control. > > Can anyone please suggest how to read value inside this hierarchy? > > **Thanks & Regards** > > **Prasad V. Joshi** > > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ |
From: Joshi, P. <pv...@ti...> - 2010-06-10 05:22:09
|
Hello, I want to read values present inside ListView Control which is embedded inside System Tab Control. Flow is like this Form --------contains--------------> Blank Dialog Class --------contains---------------> System Tab Control ------------ one tab contain ----------> List view control. Can anyone please suggest how to read value inside this hierarchy? Thanks & Regards Prasad V. Joshi |
From: Jeremy W. <jez...@ho...> - 2010-06-08 07:34:22
|
> Hello! > > I have a question: How to improve refreshing speed? As a first step, try a profiler to see where your code is spending most of its time: try Devel-NYTProf: http://search.cpan.org/~timb/Devel-NYTProf-3.11/http://blog.timbunce.org/2009/12/24/nytprof-v3-worth-the-wait/ (make sure you use the latest version from cpan) This profiler works well with Win32::GUI. With a bit of luck you'll find a couple of simple hotspots that once fixed will give the speed increase you are after. If that fails, then you you'll need to draw the labels and text in a graphic control (using an offscreen DC, then bitblting the result to the screen DC). This will give you a big leap in performance, but am not sure how it would fit into your existing code. Cheers, jez. > Problem is as follows: I refresh labels and textfields very offen in table > views. The refreshing consists of changing mainly background, but also > foreground, fontsize etc. The way I am doing it is using > $object->Change( @parameters ) > function which is encapsulated in my Refresh(...) function (this function is > copied later on). As you can see the Change method is the main part of the > Refresh function. > > Because there is many such refreshings the user fills some slowness. Is it > possible in a relatively simple way to replace this Change function with some > other which would be closer (and therefore faster) to Windows system graphics? > > Waldemar _________________________________________________________________ http://clk.atdmt.com/UKM/go/197222280/direct/01/ We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now |
From: Waldemar B. <wb...@sa...> - 2010-06-08 06:16:21
|
Hello! I have a question: How to improve refreshing speed? Problem is as follows: I refresh labels and textfields very offen in table views. The refreshing consists of changing mainly background, but also foreground, fontsize etc. The way I am doing it is using $object->Change( @parameters ) function which is encapsulated in my Refresh(...) function (this function is copied later on). As you can see the Change method is the main part of the Refresh function. Because there is many such refreshings the user fills some slowness. Is it possible in a relatively simple way to replace this Change function with some other which would be closer (and therefore faster) to Windows system graphics? Waldemar ============================== sub Refresh { my ( $screen, $object, $type ) = ( shift, shift, shift ); $object = '' unless $object; return unless $screen->{$object}; my %parameter; my @attributes = (); my @attributes_2; my ( $par, $val ); my %new_font = Win32::GUI::Font::Info($screen->{$object}->GetFont()); my $change_value = 0; my $value = ''; my $change_visible = 0; my $visible = 0; my $change_readonly = 0; my $readonly = 0; my $change_font = 0; while ( $par = shift ) { $val = shift; #print "par/value = $par / $value\n"; if ( $par eq '-visible' ) { $change_visible = 1; $visible = $val; $visible = 0 unless $visible; } elsif ( $par eq '-readonly' ) { $change_readonly = 1; $readonly = 1 if $val; $readonly = 0 unless $readonly; } elsif ( $par eq '-background' ) { push @attributes, ( -background=>$val ); # push @attributes_2, ( -background=>$val ); } elsif ( $par eq '-text' ) { $change_value = 1; $value = $val; $value = '' unless defined $value; } else { push @attributes, ( $par=>$val ); } if ( $par =~ /-fontsize|-fontweight/ ) { $val = 0 unless $val; $val += 0; if ( $par eq '-fontsize' && $val != $new_font{-height} ) { $change_font = 1; $new_font{-height} = $val; } elsif ( $par eq '-fontweight' && $val != $new_font{-weight} ) { $change_font = 1; $new_font{-weight} = $val; } } elsif ( $par =~ /-fontname/ && $val ne $new_font{-name} ) { $change_font = 1; $new_font{-name} = $val; } } if ( $change_font ) { $screen->{$object.'font'} = Win32::GUI::Font->new( -name => $new_font{-name}, -size => $new_font{-height}, -weight=> $new_font{-weight}, ); push @attributes, ( -font=>$screen->{$object.'font'} ); } if ( $type =~ /checkbox|boolean/i ) { if ( $value ) { push @attributes, ( -background=>0xccffcc ) } elsif ( $value eq '0' ) { push @attributes, ( -background=>0xccccff ) } else { push @attributes, ( -background=>0xffffff ) } } elsif ( $type =~ /integer/i ) { my $val = $value; $val = 0 unless $val; $val =~ s/ //g; $val += 0; } elsif ( $type =~ /money/i ) { my $val = $value; $val = 0 unless $val; $val =~ s/ //g; $val += 0; if ( $val < 0 ) { push @attributes, ( -foreground=>0x0000aa ) } elsif ( $val > 0 ) { push @attributes, ( -foreground=>0x000000 ) } else { push @attributes, ( -foreground=>0x333333 ) } } if ( @attributes ) { #print "object = $object\n"; #print "attributes = @attributes\n"; $screen->{$object}->Hide() if $change_font; $screen->{$object}->Change(@attributes) if @attributes; $screen->{$object}->Show() if $change_font; } $screen->{$object.'_2'}->Change(-text=>'',@attributes_2) if @attributes_2 && $screen->{$object.'_2'} && $object=~/VAR|FILL/i; $screen->{$object.'_3'}->Change(-text=>'',@attributes_2) if @attributes_2 && $screen->{$object.'_3'} && $object=~/VAR|FILL/i; if ( $change_visible ) { $screen->{$object}->Show(1) if $visible; $screen->{$object.'_0'}->Show(1) if $visible && $screen- >{$object.'_0'}; $screen->{$object.'_1'}->Show(1) if $visible && $screen- >{$object.'_1'}; $screen->{$object.'_2'}->Show(1) if $visible && $screen- >{$object.'_2'}; $screen->{$object.'_3'}->Show(1) if $visible && $screen- >{$object.'_3'}; $screen->{$object}->Hide() if $visible == 0; $screen->{$object.'_0'}->Hide() if $visible == 0 && $screen- >{$object.'_0'}; $screen->{$object.'_1'}->Hide() if $visible == 0 && $screen- >{$object.'_1'}; $screen->{$object.'_2'}->Hide() if $visible == 0 && $screen- >{$object.'_2'}; $screen->{$object.'_3'}->Hide() if $visible == 0 && $screen- >{$object.'_3'}; } if ( $change_readonly ) { $screen->{$object}->ReadOnly( $readonly ); $screen->{$object.'_2'}->ReadOnly( $readonly ) if $screen- >{$object.'_2'} && $object =~ /VAR/;; $screen->{$object.'_3'}->ReadOnly( $readonly ) if $screen- >{$object.'_3'} && $object =~ /VAR/;; } if ( $change_value ) { if ( $type =~ /checkbox/i ) { $value = 1 if $value; $value = 0 unless $value; $screen->{$object}->SetCheck( $value ) } elsif ( $type =~ /datetime/i ) { $value =~ /(\d{2})-(\d{2})-(\d{4})/; $screen->{$object}->SetDate( $1, $2, $3 ); } else { if ( $type =~ /boolean/i ) { $value = 1 if $value; $value = 0 unless $value; } $value = '' unless defined $value; $screen->{$object}->Change( -text => $value ); } } } |
From: Kevin M. <kej...@ho...> - 2010-05-28 01:28:02
|
Thanks Robert for your help with this matter. I'll admit that I am not that experienced with Windows programming. I changed my sample code as per Robert's suggestions, but still couldn't get it to work properly. I think it has something to do with how strings are stored in a toolbar. I'm sure with some persistence it could be made to work, but I'm out of my depth at this point. Selva, as I said in my previous email, you could try searching Windows programming websites for a solution. I am sorry that I can't be of more help. Kevin. > Windows will only marshal messages in the range 0..WM_USER across > processes. > > The messages you are trying to use here are above WM_USER. So you are > passing to the other process an address (in the lParam of the > SendMessage) in your memory space - you are lucky not to crash the > other process :-) > > See this thread: > http://groups.google.com/group/microsoft.public.vc.mfc/browse_frm/thread/40c00794fa444323/291326274362ef36?lnk=st&q=dcsoft+sendmessageremote&rnum=1#291326274362ef36 > <http://groups.google.com/group/microsoft.public.vc.mfc/browse_frm/thread/40c00794fa444323/291326274362ef36?lnk=st&q=dcsoft+sendmessageremote&rnum=1#291326274362ef36> > for information about how to use VirtualAllocEx() and > ReadProcessMemory() to achieve what you want. > > Summary: > (1) Use VirtualAllocEx() to allocate some memory in the remote > process, and then use the address of that memory as the lParam to the > SnedMessage() call. > (2) Use ReadProcessMemory() to read the remote process memory back > into local memory. > > HTH. > Rob. > > On 27 May 2010 11:03, Kevin Marshall <kej...@ho... > <mailto:kej...@ho...>> wrote: > > Selva, > > I created a C/C++ version of my script and it still doesn't work. > The problem, it seems, is with the underlying Win32 API function > calls. It may be that what you are looking to do isn't possible. > Perhaps you could search C/C++ Windows programming websites, etc. > for your problem. Other than that, I am sorry that I can't be of > more help. If you do manage to find a solution, I wouldn't mind > hearing about it. > > Here is my code if you are interested: > > #define WIN32_LEAN_AND_MEAN > > #include <windows.h> > #include <windowsx.h> > #include <commctrl.h> > #include <stdio.h> > > HWND g_hWnd; > HWND g_hButton; > HWND g_hTextfield; > > int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, > LPSTR lpCmdLine, int nCmdShow ); > LRESULT CALLBACK WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, > LPARAM lParam ); > void Append( HWND handle, char * text ); > > int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE > hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){ > WNDCLASSEX winClass; > MSG Msg; > > ZeroMemory( &Msg, sizeof(MSG) ); > > winClass.lpszClassName = "MY_CLASS"; > winClass.cbSize = sizeof(WNDCLASSEX); > winClass.style = CS_HREDRAW | CS_VREDRAW; > winClass.lpfnWndProc = WindowProc; > winClass.hInstance = hInstance; > winClass.hIcon = LoadIcon( NULL, IDI_APPLICATION ); > winClass.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); > winClass.hCursor = LoadCursor( NULL, IDC_ARROW ); > winClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); > winClass.lpszMenuName = NULL; > winClass.cbClsExtra = 0; > winClass.cbWndExtra = 0; > > if( !RegisterClassEx(&winClass) ) > return E_FAIL; > > g_hWnd = CreateWindowEx( > NULL, "MY_CLASS", "Window Finder", > WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, > CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, > hInstance, NULL > ); > > if( g_hWnd == NULL ) > return E_FAIL; > > RECT hwndRect; > GetClientRect( g_hWnd, &hwndRect ); > g_hButton = CreateWindowEx( > NULL, "BUTTON", "Find Window", > WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, > hwndRect.right / 2 - 40, 5, 80, 25, > g_hWnd, NULL, hInstance, NULL > ); > if( g_hButton == NULL ) > return E_FAIL; > > g_hTextfield = CreateWindowEx( > WS_EX_CLIENTEDGE | WS_EX_NOPARENTNOTIFY , "EDIT", "", > WS_VISIBLE | WS_CHILD | WS_BORDER | WS_HSCROLL | > WS_VSCROLL | ES_LEFT | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, > 5, 35, hwndRect.right - 10, hwndRect.bottom - 40, > g_hWnd, NULL, hInstance, NULL > ); > if( g_hTextfield == NULL ) > return E_FAIL; > > ShowWindow( g_hWnd, nCmdShow ); > UpdateWindow( g_hWnd ); > > while( Msg.message != WM_QUIT ){ > if( GetMessage( &Msg, NULL, 0, 0 ) ){ > TranslateMessage( &Msg ); > DispatchMessage( &Msg ); > } > } > > UnregisterClass( "MY_CLASS", winClass.hInstance ); > > return Msg.wParam; > } > > LRESULT CALLBACK WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, > LPARAM lParam ){ > static bool bMouseDown = false; > static HWND hFoundHandle = NULL; > static HPEN hPenHilight = CreatePen( PS_SOLID, 5, RGB(0,0,0) ); > switch( uMsg ){ > case WM_KEYDOWN: { > switch( wParam ){ > case VK_ESCAPE: { > PostQuitMessage(0); > break; > } > } > break; > } > case WM_PARENTNOTIFY: { > int x = LOWORD(lParam); > int y = HIWORD(lParam); > > switch( LOWORD(wParam) ){ > case WM_LBUTTONDOWN: { > bMouseDown = true; > ShowWindow( g_hWnd, SW_HIDE ); > SetCapture( g_hWnd ); > break; > } > } > return 0; > break; > } > case WM_LBUTTONUP: { > bMouseDown = false; > if(hFoundHandle){ > InvalidateRect( hFoundHandle, NULL, true ); > UpdateWindow( hFoundHandle); > RedrawWindow( hFoundHandle, NULL, NULL, 1 ); > ShowWindow( g_hWnd, SW_SHOW ); > ReleaseCapture(); > char ClassName[MAX_PATH]; > GetClassName( hFoundHandle, ClassName, MAX_PATH ); > if(strcmp( ClassName, "ToolbarWindow32" ) == 0){ > Append( g_hTextfield, "Found toolbar\r\n" ); > int count = SendMessage( hFoundHandle, > TB_BUTTONCOUNT, 0, 0 ); > char string[MAX_PATH]; > sprintf( string, "Button count: %d\r\n", count ); > Append( g_hTextfield, string ); > for(int i = 0; i < count; i++){ > TBBUTTON button; > TBBUTTONINFO buttoninfo; > char text[MAX_PATH]; > SendMessage( hFoundHandle, TB_GETBUTTON, > (WPARAM)i, (LPARAM)&button ); > //SendMessage( hFoundHandle, > TB_GETBUTTONINFO, (WPARAM)button.idCommand, (LPARAM)&buttoninfo ); > //Append( g_hTextfield, buttoninfo.pszText ); > } > } > } > return 0; > break; > } > case WM_MOUSEMOVE: { > if( bMouseDown ){ > POINT point; > GetCursorPos( &point ); > HWND found = WindowFromPoint( point ); > if(found){ > hFoundHandle = found; > InvalidateRect( found, NULL, true ); > UpdateWindow( found ); > RedrawWindow( found, NULL, NULL, 1 ); > HDC hdc = GetDC( found ); > if(hdc){ > RECT rect; > GetWindowRect( found, &rect ); > HGDIOBJ oldpen = SelectObject( hdc, > hPenHilight ); > HGDIOBJ oldbrush = SelectObject( hdc, > GetStockObject(HOLLOW_BRUSH) ); > Rectangle( hdc, 0, 0, rect.right - > rect.left, rect.bottom - rect.top ); > SelectObject( hdc, oldpen ); > SelectObject( hdc, oldbrush ); > ReleaseDC( found, hdc); > } > } > } > return 0; > break; > } > case WM_CLOSE: { > PostQuitMessage(0); > return 0; > break; > } > default: > break; > } > return DefWindowProc( hWnd, uMsg, wParam, lParam ); > } > > void Append( HWND handle, char * text ){ > int length; > length = GetWindowTextLength( handle ); > SendMessage( handle, EM_SETSEL, length, length ); > SendMessage( handle, EM_REPLACESEL, (WPARAM) TRUE, (LPARAM) > text ); > } > /* END */ > > Kevin. >> Thx Kevin. >> I am trying the same thro sendmesssage of c/c++ and pack/unpack >> of Perl. >> However I did not get a lead on this and I am getting issue with >> sendmessage for toolbar control itself. >> Any idea on this,ofcourse, it may be out of your focus. >> Thx >> Selva D >> >> --- On *Thu, 20/5/10, Kevin Marshall /<kej...@ho...> >> <mailto:kej...@ho...>/* wrote: >> >> >> From: Kevin Marshall <kej...@ho...> >> <mailto:kej...@ho...> >> Subject: Re: [perl-win32-gui-users] Is it possible to work on >> toolbar controls with win32::GUI >> To: "selva ganapathy" <gan...@ya...> >> <mailto:gan...@ya...> >> Cc: per...@li... >> <mailto:per...@li...> >> Date: Thursday, 20 May, 2010, 5:38 AM >> >> Selva, >> >> I have managed to throw together a quick script that can be >> used to find info on a toolbar of another application. To use >> it, run the script and click and hold the left mouse button >> on the 'Find Window' button. This will hide the window, then >> while still holding the mouse button down, move the mouse >> over the toolbar of the other application and release the >> mouse. The window of the script should reappear, and display >> the number of buttons in the toolbar in the text box. >> Unfortunately, if you try to get the text of the toolbar >> buttons, the script crashes. At least, that is what happens >> for me when I try it on an instance of Notepad2 >> <http://www.flos-freeware.ch/notepad2.html>. Not sure exactly >> what causes this. It may work for you. Try un-commenting the >> block of code in the onMouseMove event to see what happens. >> Anyway, here is my script: >> >> #!perl >> use strict; >> use warnings; >> >> use Data::Dump qw(dump); >> #use Win32::API; >> use Win32::GUI qw(); >> use Win32::GUI::Constants qw(CW_USEDEFAULT HOLLOW_BRUSH WM_USER); >> #use constant {TB_GETBUTTON => WM_USER+23}; >> >> my $MouseDown = 0; >> my $FoundHandle; >> my $penHilight = Win32::GUI::Pen->new(-width => 5, -color => >> 0x000000, -style => 0); >> my $winMain = Win32::GUI::Window->new( >> -name => 'winMain', >> -text => 'Window Finder', >> -size => [320,240], >> -left => CW_USEDEFAULT, >> -maximizebox => 0, >> -resizable => 0, >> ); >> >> $winMain->AddButton( >> -name => 'btnWinFind', >> -text => 'Find Window', >> -pos => [$winMain->ScaleWidth()/2-40,5], >> -size => [80,25], >> -onMouseDown => sub { >> my($self,$x,$y,$flags) = @_; >> $MouseDown = 1; >> $winMain->Hide(); >> $self->SetCapture(); >> return 1; >> }, >> -onMouseUp => sub { >> my($self,$x,$y,$flags) = @_; >> $MouseDown = 0; >> if($FoundHandle){ >> Win32::GUI::InvalidateRect($FoundHandle, 1); >> Win32::GUI::Update($FoundHandle); >> Win32::GUI::Redraw($FoundHandle, 1); >> $winMain->Show(); >> $self->ReleaseCapture(); >> if(Win32::GUI::GetClassName($FoundHandle) eq >> 'ToolbarWindow32'){ >> my $count = >> Win32::GUI::Toolbar::ButtonCount($FoundHandle); >> $winMain->txtInfo->Text("$count\r\n"); >> # foreach(0..$count-1){ >> # my $tbbutton = "\0" x 20; >> # Win32::GUI::SendMessage($FoundHandle, >> TB_GETBUTTON, $_, $tbbutton); >> # dump $tbbutton; >> # my @button = >> Win32::GUI::Toolbar::GetButton($FoundHandle, $_); >> # my @size = >> Win32::GUI::Toolbar::GetButtonSize($FoundHandle); >> # my $text = >> Win32::GUI::Toolbar::GetButtonText($FoundHandle, $_); >> # $winMain->txtInfo->Append(join "\r\n", >> @size); >> # } >> } >> } >> return 1; >> }, >> -onMouseMove => sub { >> my($self,$x,$y,$flags) = @_; >> if($MouseDown){ >> my $found = >> Win32::GUI::WindowFromPoint($self->ClientToScreen($x,$y)); >> if($found){ >> $FoundHandle = $found; >> Win32::GUI::InvalidateRect($found, 1); >> Win32::GUI::Update($found); >> Win32::GUI::Redraw($found, 1); >> my $dc = Win32::GUI::DC::GetDC($found); >> my %rect; >> @rect{qw(left top right bottom)} = >> Win32::GUI::GetWindowRect($found); >> if($dc){ >> my $oldpen = >> Win32::GUI::DC::SelectObject($dc, $penHilight); >> my $oldbrush = >> Win32::GUI::DC::SelectObject($dc, >> Win32::GUI::DC::GetStockObject(HOLLOW_BRUSH)); >> >> Win32::GUI::DC::Rectangle($dc,0,0,$rect{right}-$rect{left},$rect{bottom}-$rect{top}); >> Win32::GUI::DC::SelectObject($dc, >> $oldpen) if $oldpen; >> Win32::GUI::DC::SelectObject($dc, >> $oldbrush) if $oldbrush; >> Win32::GUI::DC::ReleaseDC($found, $dc); >> } >> else { >> warn "Can't get DC: $^E"; >> } >> } >> } >> return 1; >> }, >> ); >> >> $winMain->AddTextfield( >> -name => 'txtInfo', >> -size => >> [$winMain->ScaleWidth()-10,$winMain->ScaleHeight()-40], >> -pos => [5,35], >> -multiline => 1, >> ); >> >> $winMain->Show(); >> >> Win32::GUI::Dialog(); >> >> __END__ >> >> I based this code off of some C/C++ code that was posted here >> <http://www.codeproject.com/kb/dialog/windowfinder.aspx>. >> >> Hope this helps, >> >> Kevin. >>> Kevin, >>> Thanks for your response.This is not created with Win32::GUI >>> This is VC++ application and in that application, in the >>> toolbar (you could see save image etc - attachment- red >>> colored is the toolbar INeed to work), I have to get/do the >>> Toolbar count , >>> Button click based on indiex or test >>> Click on IMage >>> Size of Each Button >>> Individual Button State. >>> My perl script will not create these window application, I >>> have to to some activity on these tollbar icons such as >>> click and for this I need use of this module. >>> Thx >>> Selva D >>> >>> --- On *Wed, 19/5/10, Kevin Marshall /<kej...@ho...> >>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=kej...@ho...>/* >>> wrote: >>> >>> >>> From: Kevin Marshall <kej...@ho...> >>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=kej...@ho...> >>> Subject: Re: [perl-win32-gui-users] Is it possible to >>> work on toolbar controls with win32::GUI >>> To: "selva ganapathy" <gan...@ya...> >>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=gan...@ya...> >>> Cc: per...@li... >>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=per...@li...> >>> Date: Wednesday, 19 May, 2010, 5:07 AM >>> >>> Selva, >>> >>> How exactly is this other window with toolbar created? >>> Is it from a completely separate script or from a module >>> that your script loads? Is it created using Win32::GUI >>> in Perl? Could you provide a small example of your problem? >>> >>> Sorry for the confusion. >>> >>> Kevin. >>>> Kevin. >>>> Thanks for the update. The one you have referred will >>>> get the tool bar button count for which you create the >>>> window and add content to that window and you are >>>> getting the same. >>>> But I look for the situation, where I have to get the >>>> Toolbar button count on existing window which I will >>>> not create on run time. >>>> I am looking some solution on the same . Any further >>>> thoughts from you is very much helpful. >>>> Thx in advance and I hope that I have clarified my >>>> requirement. >>>> Selva D >>>> >>>> --- On *Mon, 10/5/10, Kevin Marshall >>>> /<kej...@ho...> >>>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=kej...@ho...>/* >>>> wrote: >>>> >>>> >>>> From: Kevin Marshall <kej...@ho...> >>>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=kej...@ho...> >>>> Subject: RE: [perl-win32-gui-users] Is it possible >>>> to work on toolbar controls with win32::GUI >>>> To: gan...@ya... >>>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=gan...@ya...> >>>> Cc: "Perl-Win32-GUI-Users List" >>>> <per...@li...> >>>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=per...@li...> >>>> Date: Monday, 10 May, 2010, 7:44 AM >>>> >>>> Selva, >>>> >>>> You can use the ButtonCount() method to retrieve >>>> the number of buttons in the toolbar and the >>>> GetButtonText() method to retrieve the text of the >>>> specified button. Here is some sample code: >>>> >>>> #!perl >>>> use strict; >>>> use warnings; >>>> >>>> use Data::Dump qw(dump); >>>> use Win32::GUI qw(); >>>> use Win32::GUI::Constants qw(TBSTATE_ENABLED >>>> BTNS_SHOWTEXT IDB_STD_SMALL_COLOR CW_USEDEFAULT); >>>> >>>> my $win = Win32::GUI::Window->new( >>>> -name => 'win', >>>> -text => 'Toolbar Sample', >>>> -size => [320,240], >>>> -left => CW_USEDEFAULT, >>>> ); >>>> >>>> $win->AddToolbar( >>>> -name => 'toolbar', >>>> -adjustable => 1, >>>> -flat => 1, >>>> -multiline => 1, >>>> -nodivider => 1, >>>> ); >>>> my @buttons = (qw(Cut Copy Paste Undo Redo Delete >>>> New Open Save Preview >>>> Properties Help Find Replace Print)); >>>> $win->toolbar->LoadImages(IDB_STD_SMALL_COLOR); >>>> $win->toolbar->AddString($_) foreach @buttons; >>>> $win->toolbar->AddButtons( >>>> scalar @buttons, >>>> map >>>> {($_,$_+1,TBSTATE_ENABLED,BTNS_SHOWTEXT,$_)} >>>> 0..$#buttons >>>> ); >>>> >>>> $win->Show(); >>>> >>>> Win32::GUI::Dialog(); >>>> >>>> sub win_Resize { >>>> $win->toolbar->Width($win->Width()); >>>> return 1; >>>> } >>>> >>>> sub toolbar_ButtonClick { >>>> my($index,$dropdown) = @_; >>>> printf "Button %02d of %02d text => %s\n", $index, >>>> $win->toolbar->ButtonCount(), >>>> $win->toolbar->GetButtonText($index); >>>> return 1; >>>> } >>>> __END__ >>>> >>>> Hope this helps, >>>> >>>> Kevin. >>>> >>>> > Date: Tue, 4 May 2010 05:38:04 -0700 >>>> > From: gan...@ya... >>>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=gan...@ya...> >>>> > To: per...@li... >>>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=per...@li...> >>>> > Subject: [perl-win32-gui-users] Is it possible to >>>> work on toolbar controls with win32::GUI >>>> > >>>> > Hi, >>>> > I exhaustively looked at win32::GUI and please >>>> clarify on the same. >>>> > I just want to get the toolbar item- count and >>>> also the text of the items in toolbar. I saw >>>> win32::GUI was creating an window and doing adding >>>> some control for the same. >>>> > Is there any way to test the toolbar controls for >>>> the existing toolbar by passing the window handler. >>>> > >>>> > I also tried with win32::GUItest..but not >>>> succeeded.(by using sendmessage ) Please any clue >>>> on this? >>>> > >>>> > Thanks >>>> > Selva D >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> ------------------------------------------------------------------------------ >>>> > _______________________________________________ >>>> > Perl-Win32-GUI-Users mailing list >>>> > Per...@li... >>>> <http://aa.mc561.mail.yahoo.com/mc/compose?to=Per...@li...> >>>> > >>>> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >>>> > http://perl-win32-gui.sourceforge.net/ >>>> >>>> ------------------------------------------------------------------------ >>>> Looking for a hot date? View photos of singles in >>>> your area! >>>> <http://clk.atdmt.com/NMN/go/150855801/direct/01/> >>>> >>>> >>> >>> >> >> >> > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > <mailto:Per...@li...> > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > |
From: Robert M. <rob...@us...> - 2010-05-27 11:41:54
|
Windows will only marshal messages in the range 0..WM_USER across processes. The messages you are trying to use here are above WM_USER. So you are passing to the other process an address (in the lParam of the SendMessage) in your memory space - you are lucky not to crash the other process :-) See this thread: http://groups.google.com/group/microsoft.public.vc.mfc/browse_frm/thread/40c00794fa444323/291326274362ef36?lnk=st&q=dcsoft+sendmessageremote&rnum=1#291326274362ef36 for information about how to use VirtualAllocEx() and ReadProcessMemory() to achieve what you want. Summary: (1) Use VirtualAllocEx() to allocate some memory in the remote process, and then use the address of that memory as the lParam to the SnedMessage() call. (2) Use ReadProcessMemory() to read the remote process memory back into local memory. HTH. Rob. On 27 May 2010 11:03, Kevin Marshall <kej...@ho...> wrote: > Selva, > > I created a C/C++ version of my script and it still doesn't work. The > problem, it seems, is with the underlying Win32 API function calls. It may > be that what you are looking to do isn't possible. Perhaps you could search > C/C++ Windows programming websites, etc. for your problem. Other than that, > I am sorry that I can't be of more help. If you do manage to find a > solution, I wouldn't mind hearing about it. > > Here is my code if you are interested: > > #define WIN32_LEAN_AND_MEAN > > #include <windows.h> > #include <windowsx.h> > #include <commctrl.h> > #include <stdio.h> > > HWND g_hWnd; > HWND g_hButton; > HWND g_hTextfield; > > int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR > lpCmdLine, int nCmdShow ); > LRESULT CALLBACK WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM > lParam ); > void Append( HWND handle, char * text ); > > int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR > lpCmdLine, int nCmdShow ){ > WNDCLASSEX winClass; > MSG Msg; > > ZeroMemory( &Msg, sizeof(MSG) ); > > winClass.lpszClassName = "MY_CLASS"; > winClass.cbSize = sizeof(WNDCLASSEX); > winClass.style = CS_HREDRAW | CS_VREDRAW; > winClass.lpfnWndProc = WindowProc; > winClass.hInstance = hInstance; > winClass.hIcon = LoadIcon( NULL, IDI_APPLICATION ); > winClass.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); > winClass.hCursor = LoadCursor( NULL, IDC_ARROW ); > winClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); > winClass.lpszMenuName = NULL; > winClass.cbClsExtra = 0; > winClass.cbWndExtra = 0; > > if( !RegisterClassEx(&winClass) ) > return E_FAIL; > > g_hWnd = CreateWindowEx( > NULL, "MY_CLASS", "Window Finder", > WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, > CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, hInstance, NULL > ); > > if( g_hWnd == NULL ) > return E_FAIL; > > RECT hwndRect; > GetClientRect( g_hWnd, &hwndRect ); > g_hButton = CreateWindowEx( > NULL, "BUTTON", "Find Window", > WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, > hwndRect.right / 2 - 40, 5, 80, 25, > g_hWnd, NULL, hInstance, NULL > ); > if( g_hButton == NULL ) > return E_FAIL; > > g_hTextfield = CreateWindowEx( > WS_EX_CLIENTEDGE | WS_EX_NOPARENTNOTIFY , "EDIT", "", > WS_VISIBLE | WS_CHILD | WS_BORDER | WS_HSCROLL | WS_VSCROLL | > ES_LEFT | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, > 5, 35, hwndRect.right - 10, hwndRect.bottom - 40, > g_hWnd, NULL, hInstance, NULL > ); > if( g_hTextfield == NULL ) > return E_FAIL; > > ShowWindow( g_hWnd, nCmdShow ); > UpdateWindow( g_hWnd ); > > while( Msg.message != WM_QUIT ){ > if( GetMessage( &Msg, NULL, 0, 0 ) ){ > TranslateMessage( &Msg ); > DispatchMessage( &Msg ); > } > } > > UnregisterClass( "MY_CLASS", winClass.hInstance ); > > return Msg.wParam; > } > > LRESULT CALLBACK WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM > lParam ){ > static bool bMouseDown = false; > static HWND hFoundHandle = NULL; > static HPEN hPenHilight = CreatePen( PS_SOLID, 5, RGB(0,0,0) ); > switch( uMsg ){ > case WM_KEYDOWN: { > switch( wParam ){ > case VK_ESCAPE: { > PostQuitMessage(0); > break; > } > } > break; > } > case WM_PARENTNOTIFY: { > int x = LOWORD(lParam); > int y = HIWORD(lParam); > > switch( LOWORD(wParam) ){ > case WM_LBUTTONDOWN: { > bMouseDown = true; > ShowWindow( g_hWnd, SW_HIDE ); > SetCapture( g_hWnd ); > break; > } > } > return 0; > break; > } > case WM_LBUTTONUP: { > bMouseDown = false; > if(hFoundHandle){ > InvalidateRect( hFoundHandle, NULL, true ); > UpdateWindow( hFoundHandle); > RedrawWindow( hFoundHandle, NULL, NULL, 1 ); > ShowWindow( g_hWnd, SW_SHOW ); > ReleaseCapture(); > char ClassName[MAX_PATH]; > GetClassName( hFoundHandle, ClassName, MAX_PATH ); > if(strcmp( ClassName, "ToolbarWindow32" ) == 0){ > Append( g_hTextfield, "Found toolbar\r\n" ); > int count = SendMessage( hFoundHandle, TB_BUTTONCOUNT, > 0, 0 ); > char string[MAX_PATH]; > sprintf( string, "Button count: %d\r\n", count ); > Append( g_hTextfield, string ); > for(int i = 0; i < count; i++){ > TBBUTTON button; > TBBUTTONINFO buttoninfo; > char text[MAX_PATH]; > SendMessage( hFoundHandle, TB_GETBUTTON, (WPARAM)i, > (LPARAM)&button ); > //SendMessage( hFoundHandle, TB_GETBUTTONINFO, > (WPARAM)button.idCommand, (LPARAM)&buttoninfo ); > //Append( g_hTextfield, buttoninfo.pszText ); > } > } > } > return 0; > break; > } > case WM_MOUSEMOVE: { > if( bMouseDown ){ > POINT point; > GetCursorPos( &point ); > HWND found = WindowFromPoint( point ); > if(found){ > hFoundHandle = found; > InvalidateRect( found, NULL, true ); > UpdateWindow( found ); > RedrawWindow( found, NULL, NULL, 1 ); > HDC hdc = GetDC( found ); > if(hdc){ > RECT rect; > GetWindowRect( found, &rect ); > HGDIOBJ oldpen = SelectObject( hdc, hPenHilight ); > HGDIOBJ oldbrush = SelectObject( hdc, > GetStockObject(HOLLOW_BRUSH) ); > Rectangle( hdc, 0, 0, rect.right - rect.left, > rect.bottom - rect.top ); > SelectObject( hdc, oldpen ); > SelectObject( hdc, oldbrush ); > ReleaseDC( found, hdc); > } > } > } > return 0; > break; > } > case WM_CLOSE: { > PostQuitMessage(0); > return 0; > break; > } > default: > break; > } > return DefWindowProc( hWnd, uMsg, wParam, lParam ); > } > > void Append( HWND handle, char * text ){ > int length; > length = GetWindowTextLength( handle ); > SendMessage( handle, EM_SETSEL, length, length ); > SendMessage( handle, EM_REPLACESEL, (WPARAM) TRUE, (LPARAM) text ); > } > /* END */ > > Kevin. > > Thx Kevin. > I am trying the same thro sendmesssage of c/c++ and pack/unpack of Perl. > However I did not get a lead on this and I am getting issue with > sendmessage for toolbar control itself. > Any idea on this,ofcourse, it may be out of your focus. > > Thx > Selva D > > --- On *Thu, 20/5/10, Kevin Marshall <kej...@ho...><kej...@ho...> > * wrote: > > > From: Kevin Marshall <kej...@ho...> <kej...@ho...> > Subject: Re: [perl-win32-gui-users] Is it possible to work on toolbar > controls with win32::GUI > To: "selva ganapathy" <gan...@ya...><gan...@ya...> > Cc: per...@li... > Date: Thursday, 20 May, 2010, 5:38 AM > > Selva, > > I have managed to throw together a quick script that can be used to find > info on a toolbar of another application. To use it, run the script and > click and hold the left mouse button on the 'Find Window' button. This will > hide the window, then while still holding the mouse button down, move the > mouse over the toolbar of the other application and release the mouse. The > window of the script should reappear, and display the number of buttons in > the toolbar in the text box. Unfortunately, if you try to get the text of > the toolbar buttons, the script crashes. At least, that is what happens for > me when I try it on an instance of Notepad2<http://www.flos-freeware.ch/notepad2.html>. > Not sure exactly what causes this. It may work for you. Try un-commenting > the block of code in the onMouseMove event to see what happens. Anyway, here > is my script: > > #!perl > use strict; > use warnings; > > use Data::Dump qw(dump); > #use Win32::API; > use Win32::GUI qw(); > use Win32::GUI::Constants qw(CW_USEDEFAULT HOLLOW_BRUSH WM_USER); > #use constant {TB_GETBUTTON => WM_USER+23}; > > my $MouseDown = 0; > my $FoundHandle; > my $penHilight = Win32::GUI::Pen->new(-width => 5, -color => 0x000000, > -style => 0); > my $winMain = Win32::GUI::Window->new( > -name => 'winMain', > -text => 'Window Finder', > -size => [320,240], > -left => CW_USEDEFAULT, > -maximizebox => 0, > -resizable => 0, > ); > > $winMain->AddButton( > -name => 'btnWinFind', > -text => 'Find Window', > -pos => [$winMain->ScaleWidth()/2-40,5], > -size => [80,25], > -onMouseDown => sub { > my($self,$x,$y,$flags) = @_; > $MouseDown = 1; > $winMain->Hide(); > $self->SetCapture(); > return 1; > }, > -onMouseUp => sub { > my($self,$x,$y,$flags) = @_; > $MouseDown = 0; > if($FoundHandle){ > Win32::GUI::InvalidateRect($FoundHandle, 1); > Win32::GUI::Update($FoundHandle); > Win32::GUI::Redraw($FoundHandle, 1); > $winMain->Show(); > $self->ReleaseCapture(); > if(Win32::GUI::GetClassName($FoundHandle) eq > 'ToolbarWindow32'){ > my $count = Win32::GUI::Toolbar::ButtonCount($FoundHandle); > $winMain->txtInfo->Text("$count\r\n"); > # foreach(0..$count-1){ > # my $tbbutton = "\0" x 20; > # Win32::GUI::SendMessage($FoundHandle, TB_GETBUTTON, > $_, $tbbutton); > # dump $tbbutton; > # my @button = > Win32::GUI::Toolbar::GetButton($FoundHandle, $_); > # my @size = > Win32::GUI::Toolbar::GetButtonSize($FoundHandle); > # my $text = > Win32::GUI::Toolbar::GetButtonText($FoundHandle, $_); > # $winMain->txtInfo->Append(join "\r\n", @size); > # } > } > } > return 1; > }, > -onMouseMove => sub { > my($self,$x,$y,$flags) = @_; > if($MouseDown){ > my $found = > Win32::GUI::WindowFromPoint($self->ClientToScreen($x,$y)); > if($found){ > $FoundHandle = $found; > Win32::GUI::InvalidateRect($found, 1); > Win32::GUI::Update($found); > Win32::GUI::Redraw($found, 1); > my $dc = Win32::GUI::DC::GetDC($found); > my %rect; > @rect{qw(left top right bottom)} = > Win32::GUI::GetWindowRect($found); > if($dc){ > my $oldpen = Win32::GUI::DC::SelectObject($dc, > $penHilight); > my $oldbrush = Win32::GUI::DC::SelectObject($dc, > Win32::GUI::DC::GetStockObject(HOLLOW_BRUSH)); > > Win32::GUI::DC::Rectangle($dc,0,0,$rect{right}-$rect{left},$rect{bottom}-$rect{top}); > Win32::GUI::DC::SelectObject($dc, $oldpen) if $oldpen; > Win32::GUI::DC::SelectObject($dc, $oldbrush) if > $oldbrush; > Win32::GUI::DC::ReleaseDC($found, $dc); > } > else { > warn "Can't get DC: $^E"; > } > } > } > return 1; > }, > ); > > $winMain->AddTextfield( > -name => 'txtInfo', > -size => [$winMain->ScaleWidth()-10,$winMain->ScaleHeight()-40], > -pos => [5,35], > -multiline => 1, > ); > > $winMain->Show(); > > Win32::GUI::Dialog(); > > __END__ > > I based this code off of some C/C++ code that was posted here<http://www.codeproject.com/kb/dialog/windowfinder.aspx> > . > > Hope this helps, > > Kevin. > > Kevin, > Thanks for your response.This is not created with Win32::GUI > This is VC++ application and in that application, in the toolbar (you could > see save image etc - attachment- red colored is the toolbar INeed to work), > I have to get/do the > Toolbar count , > Button click based on indiex or test > Click on IMage > Size of Each Button > Individual Button State. > > My perl script will not create these window application, I have to to some > activity on these tollbar icons such as click and for this I need use of > this module. > Thx > Selva D > > --- On *Wed, 19/5/10, Kevin Marshall <kej...@ho...><http://aa.mc561.mail.yahoo.com/mc/compose?to=kej...@ho...> > * wrote: > > > From: Kevin Marshall <kej...@ho...><http://aa.mc561.mail.yahoo.com/mc/compose?to=kej...@ho...> > Subject: Re: [perl-win32-gui-users] Is it possible to work on toolbar > controls with win32::GUI > To: "selva ganapathy" <gan...@ya...><http://aa.mc561.mail.yahoo.com/mc/compose?to=gan...@ya...> > Cc: per...@li...<http://aa.mc561.mail.yahoo.com/mc/compose?to=per...@li...> > Date: Wednesday, 19 May, 2010, 5:07 AM > > Selva, > > How exactly is this other window with toolbar created? Is it from a > completely separate script or from a module that your script loads? Is it > created using Win32::GUI in Perl? Could you provide a small example of your > problem? > > Sorry for the confusion. > > Kevin. > > Kevin. > Thanks for the update. The one you have referred will get the tool bar > button count for which you create the window and add content to that window > and you are getting the same. > > But I look for the situation, where I have to get the Toolbar button > count on existing window which I will not create on run time. > > I am looking some solution on the same . Any further thoughts from you is > very much helpful. > Thx in advance and I hope that I have clarified my requirement. > Selva D > > --- On *Mon, 10/5/10, Kevin Marshall <kej...@ho...><http://aa.mc561.mail.yahoo.com/mc/compose?to=kej...@ho...> > * wrote: > > > From: Kevin Marshall <kej...@ho...><http://aa.mc561.mail.yahoo.com/mc/compose?to=kej...@ho...> > Subject: RE: [perl-win32-gui-users] Is it possible to work on toolbar > controls with win32::GUI > To: gan...@ya...<http://aa.mc561.mail.yahoo.com/mc/compose?to=gan...@ya...> > Cc: "Perl-Win32-GUI-Users List" > <per...@li...><http://aa.mc561.mail.yahoo.com/mc/compose?to=per...@li...> > Date: Monday, 10 May, 2010, 7:44 AM > > Selva, > > You can use the ButtonCount() method to retrieve the number of buttons in > the toolbar and the GetButtonText() method to retrieve the text of the > specified button. Here is some sample code: > > #!perl > use strict; > use warnings; > > use Data::Dump qw(dump); > use Win32::GUI qw(); > use Win32::GUI::Constants qw(TBSTATE_ENABLED BTNS_SHOWTEXT > IDB_STD_SMALL_COLOR CW_USEDEFAULT); > > my $win = Win32::GUI::Window->new( > -name => 'win', > -text => 'Toolbar Sample', > -size => [320,240], > -left => CW_USEDEFAULT, > ); > > $win->AddToolbar( > -name => 'toolbar', > -adjustable => 1, > -flat => 1, > -multiline => 1, > -nodivider => 1, > ); > my @buttons = (qw(Cut Copy Paste Undo Redo Delete New Open Save Preview > Properties Help Find Replace Print)); > $win->toolbar->LoadImages(IDB_STD_SMALL_COLOR); > $win->toolbar->AddString($_) foreach @buttons; > $win->toolbar->AddButtons( > scalar @buttons, > map {($_,$_+1,TBSTATE_ENABLED,BTNS_SHOWTEXT,$_)} 0..$#buttons > ); > > $win->Show(); > > Win32::GUI::Dialog(); > > sub win_Resize { > $win->toolbar->Width($win->Width()); > return 1; > } > > sub toolbar_ButtonClick { > my($index,$dropdown) = @_; > printf "Button %02d of %02d text => %s\n", $index, > $win->toolbar->ButtonCount(), $win->toolbar->GetButtonText($index); > return 1; > } > __END__ > > Hope this helps, > > Kevin. > > > Date: Tue, 4 May 2010 05:38:04 -0700 > > From: gan...@ya...<http://aa.mc561.mail.yahoo.com/mc/compose?to=gan...@ya...> > > To: per...@li...<http://aa.mc561.mail.yahoo.com/mc/compose?to=per...@li...> > > Subject: [perl-win32-gui-users] Is it possible to work on toolbar > controls with win32::GUI > > > > Hi, > > I exhaustively looked at win32::GUI and please clarify on the same. > > I just want to get the toolbar item- count and also the text of the items > in toolbar. I saw win32::GUI was creating an window and doing adding some > control for the same. > > Is there any way to test the toolbar controls for the existing toolbar by > passing the window handler. > > > > I also tried with win32::GUItest..but not succeeded.(by using sendmessage > ) Please any clue on this? > > > > Thanks > > Selva D > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > > Perl-Win32-GUI-Users mailing list > > Per...@li...<http://aa.mc561.mail.yahoo.com/mc/compose?to=Per...@li...> > > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > > http://perl-win32-gui.sourceforge.net/ > > ------------------------------ > Looking for a hot date? View photos of singles in your area!<http://clk.atdmt.com/NMN/go/150855801/direct/01/> > > > > > > > > > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > |
From: Kevin M. <kej...@ho...> - 2010-05-27 10:04:04
|
Selva, I created a C/C++ version of my script and it still doesn't work. The problem, it seems, is with the underlying Win32 API function calls. It may be that what you are looking to do isn't possible. Perhaps you could search C/C++ Windows programming websites, etc. for your problem. Other than that, I am sorry that I can't be of more help. If you do manage to find a solution, I wouldn't mind hearing about it. Here is my code if you are interested: #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <windowsx.h> #include <commctrl.h> #include <stdio.h> HWND g_hWnd; HWND g_hButton; HWND g_hTextfield; int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ); LRESULT CALLBACK WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); void Append( HWND handle, char * text ); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){ WNDCLASSEX winClass; MSG Msg; ZeroMemory( &Msg, sizeof(MSG) ); winClass.lpszClassName = "MY_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW; winClass.lpfnWndProc = WindowProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon( NULL, IDI_APPLICATION ); winClass.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); winClass.hCursor = LoadCursor( NULL, IDC_ARROW ); winClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); winClass.lpszMenuName = NULL; winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; if( !RegisterClassEx(&winClass) ) return E_FAIL; g_hWnd = CreateWindowEx( NULL, "MY_CLASS", "Window Finder", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, hInstance, NULL ); if( g_hWnd == NULL ) return E_FAIL; RECT hwndRect; GetClientRect( g_hWnd, &hwndRect ); g_hButton = CreateWindowEx( NULL, "BUTTON", "Find Window", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, hwndRect.right / 2 - 40, 5, 80, 25, g_hWnd, NULL, hInstance, NULL ); if( g_hButton == NULL ) return E_FAIL; g_hTextfield = CreateWindowEx( WS_EX_CLIENTEDGE | WS_EX_NOPARENTNOTIFY , "EDIT", "", WS_VISIBLE | WS_CHILD | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_LEFT | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, 5, 35, hwndRect.right - 10, hwndRect.bottom - 40, g_hWnd, NULL, hInstance, NULL ); if( g_hTextfield == NULL ) return E_FAIL; ShowWindow( g_hWnd, nCmdShow ); UpdateWindow( g_hWnd ); while( Msg.message != WM_QUIT ){ if( GetMessage( &Msg, NULL, 0, 0 ) ){ TranslateMessage( &Msg ); DispatchMessage( &Msg ); } } UnregisterClass( "MY_CLASS", winClass.hInstance ); return Msg.wParam; } LRESULT CALLBACK WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ){ static bool bMouseDown = false; static HWND hFoundHandle = NULL; static HPEN hPenHilight = CreatePen( PS_SOLID, 5, RGB(0,0,0) ); switch( uMsg ){ case WM_KEYDOWN: { switch( wParam ){ case VK_ESCAPE: { PostQuitMessage(0); break; } } break; } case WM_PARENTNOTIFY: { int x = LOWORD(lParam); int y = HIWORD(lParam); switch( LOWORD(wParam) ){ case WM_LBUTTONDOWN: { bMouseDown = true; ShowWindow( g_hWnd, SW_HIDE ); SetCapture( g_hWnd ); break; } } return 0; break; } case WM_LBUTTONUP: { bMouseDown = false; if(hFoundHandle){ InvalidateRect( hFoundHandle, NULL, true ); UpdateWindow( hFoundHandle); RedrawWindow( hFoundHandle, NULL, NULL, 1 ); ShowWindow( g_hWnd, SW_SHOW ); ReleaseCapture(); char ClassName[MAX_PATH]; GetClassName( hFoundHandle, ClassName, MAX_PATH ); if(strcmp( ClassName, "ToolbarWindow32" ) == 0){ Append( g_hTextfield, "Found toolbar\r\n" ); int count = SendMessage( hFoundHandle, TB_BUTTONCOUNT, 0, 0 ); char string[MAX_PATH]; sprintf( string, "Button count: %d\r\n", count ); Append( g_hTextfield, string ); for(int i = 0; i < count; i++){ TBBUTTON button; TBBUTTONINFO buttoninfo; char text[MAX_PATH]; SendMessage( hFoundHandle, TB_GETBUTTON, (WPARAM)i, (LPARAM)&button ); //SendMessage( hFoundHandle, TB_GETBUTTONINFO, (WPARAM)button.idCommand, (LPARAM)&buttoninfo ); //Append( g_hTextfield, buttoninfo.pszText ); } } } return 0; break; } case WM_MOUSEMOVE: { if( bMouseDown ){ POINT point; GetCursorPos( &point ); HWND found = WindowFromPoint( point ); if(found){ hFoundHandle = found; InvalidateRect( found, NULL, true ); UpdateWindow( found ); RedrawWindow( found, NULL, NULL, 1 ); HDC hdc = GetDC( found ); if(hdc){ RECT rect; GetWindowRect( found, &rect ); HGDIOBJ oldpen = SelectObject( hdc, hPenHilight ); HGDIOBJ oldbrush = SelectObject( hdc, GetStockObject(HOLLOW_BRUSH) ); Rectangle( hdc, 0, 0, rect.right - rect.left, rect.bottom - rect.top ); SelectObject( hdc, oldpen ); SelectObject( hdc, oldbrush ); ReleaseDC( found, hdc); } } } return 0; break; } case WM_CLOSE: { PostQuitMessage(0); return 0; break; } default: break; } return DefWindowProc( hWnd, uMsg, wParam, lParam ); } void Append( HWND handle, char * text ){ int length; length = GetWindowTextLength( handle ); SendMessage( handle, EM_SETSEL, length, length ); SendMessage( handle, EM_REPLACESEL, (WPARAM) TRUE, (LPARAM) text ); } /* END */ Kevin. > Thx Kevin. > I am trying the same thro sendmesssage of c/c++ and pack/unpack of Perl. > However I did not get a lead on this and I am getting issue with > sendmessage for toolbar control itself. > Any idea on this,ofcourse, it may be out of your focus. > Thx > Selva D > > --- On *Thu, 20/5/10, Kevin Marshall /<kej...@ho...>/* wrote: > > > From: Kevin Marshall <kej...@ho...> > Subject: Re: [perl-win32-gui-users] Is it possible to work on > toolbar controls with win32::GUI > To: "selva ganapathy" <gan...@ya...> > Cc: per...@li... > Date: Thursday, 20 May, 2010, 5:38 AM > > Selva, > > I have managed to throw together a quick script that can be used > to find info on a toolbar of another application. To use it, run > the script and click and hold the left mouse button on the 'Find > Window' button. This will hide the window, then while still > holding the mouse button down, move the mouse over the toolbar of > the other application and release the mouse. The window of the > script should reappear, and display the number of buttons in the > toolbar in the text box. Unfortunately, if you try to get the text > of the toolbar buttons, the script crashes. At least, that is what > happens for me when I try it on an instance of Notepad2 > <http://www.flos-freeware.ch/notepad2.html>. Not sure exactly what > causes this. It may work for you. Try un-commenting the block of > code in the onMouseMove event to see what happens. Anyway, here is > my script: > > #!perl > use strict; > use warnings; > > use Data::Dump qw(dump); > #use Win32::API; > use Win32::GUI qw(); > use Win32::GUI::Constants qw(CW_USEDEFAULT HOLLOW_BRUSH WM_USER); > #use constant {TB_GETBUTTON => WM_USER+23}; > > my $MouseDown = 0; > my $FoundHandle; > my $penHilight = Win32::GUI::Pen->new(-width => 5, -color => > 0x000000, -style => 0); > my $winMain = Win32::GUI::Window->new( > -name => 'winMain', > -text => 'Window Finder', > -size => [320,240], > -left => CW_USEDEFAULT, > -maximizebox => 0, > -resizable => 0, > ); > > $winMain->AddButton( > -name => 'btnWinFind', > -text => 'Find Window', > -pos => [$winMain->ScaleWidth()/2-40,5], > -size => [80,25], > -onMouseDown => sub { > my($self,$x,$y,$flags) = @_; > $MouseDown = 1; > $winMain->Hide(); > $self->SetCapture(); > return 1; > }, > -onMouseUp => sub { > my($self,$x,$y,$flags) = @_; > $MouseDown = 0; > if($FoundHandle){ > Win32::GUI::InvalidateRect($FoundHandle, 1); > Win32::GUI::Update($FoundHandle); > Win32::GUI::Redraw($FoundHandle, 1); > $winMain->Show(); > $self->ReleaseCapture(); > if(Win32::GUI::GetClassName($FoundHandle) eq > 'ToolbarWindow32'){ > my $count = > Win32::GUI::Toolbar::ButtonCount($FoundHandle); > $winMain->txtInfo->Text("$count\r\n"); > # foreach(0..$count-1){ > # my $tbbutton = "\0" x 20; > # Win32::GUI::SendMessage($FoundHandle, > TB_GETBUTTON, $_, $tbbutton); > # dump $tbbutton; > # my @button = > Win32::GUI::Toolbar::GetButton($FoundHandle, $_); > # my @size = > Win32::GUI::Toolbar::GetButtonSize($FoundHandle); > # my $text = > Win32::GUI::Toolbar::GetButtonText($FoundHandle, $_); > # $winMain->txtInfo->Append(join "\r\n", @size); > # } > } > } > return 1; > }, > -onMouseMove => sub { > my($self,$x,$y,$flags) = @_; > if($MouseDown){ > my $found = > Win32::GUI::WindowFromPoint($self->ClientToScreen($x,$y)); > if($found){ > $FoundHandle = $found; > Win32::GUI::InvalidateRect($found, 1); > Win32::GUI::Update($found); > Win32::GUI::Redraw($found, 1); > my $dc = Win32::GUI::DC::GetDC($found); > my %rect; > @rect{qw(left top right bottom)} = > Win32::GUI::GetWindowRect($found); > if($dc){ > my $oldpen = Win32::GUI::DC::SelectObject($dc, > $penHilight); > my $oldbrush = > Win32::GUI::DC::SelectObject($dc, > Win32::GUI::DC::GetStockObject(HOLLOW_BRUSH)); > > Win32::GUI::DC::Rectangle($dc,0,0,$rect{right}-$rect{left},$rect{bottom}-$rect{top}); > Win32::GUI::DC::SelectObject($dc, $oldpen) if > $oldpen; > Win32::GUI::DC::SelectObject($dc, $oldbrush) > if $oldbrush; > Win32::GUI::DC::ReleaseDC($found, $dc); > } > else { > warn "Can't get DC: $^E"; > } > } > } > return 1; > }, > ); > > $winMain->AddTextfield( > -name => 'txtInfo', > -size => [$winMain->ScaleWidth()-10,$winMain->ScaleHeight()-40], > -pos => [5,35], > -multiline => 1, > ); > > $winMain->Show(); > > Win32::GUI::Dialog(); > > __END__ > > I based this code off of some C/C++ code that was posted here > <http://www.codeproject.com/kb/dialog/windowfinder.aspx>. > > Hope this helps, > > Kevin. >> Kevin, >> Thanks for your response.This is not created with Win32::GUI >> This is VC++ application and in that application, in the toolbar >> (you could see save image etc - attachment- red colored is the >> toolbar INeed to work), I have to get/do the >> Toolbar count , >> Button click based on indiex or test >> Click on IMage >> Size of Each Button >> Individual Button State. >> My perl script will not create these window application, I have >> to to some activity on these tollbar icons such as click and for >> this I need use of this module. >> Thx >> Selva D >> >> --- On *Wed, 19/5/10, Kevin Marshall /<kej...@ho...>/* wrote: >> >> >> From: Kevin Marshall <kej...@ho...> >> Subject: Re: [perl-win32-gui-users] Is it possible to work on >> toolbar controls with win32::GUI >> To: "selva ganapathy" <gan...@ya...> >> Cc: per...@li... >> Date: Wednesday, 19 May, 2010, 5:07 AM >> >> Selva, >> >> How exactly is this other window with toolbar created? Is it >> from a completely separate script or from a module that your >> script loads? Is it created using Win32::GUI in Perl? Could >> you provide a small example of your problem? >> >> Sorry for the confusion. >> >> Kevin. >>> Kevin. >>> Thanks for the update. The one you have referred will get >>> the tool bar button count for which you create the window >>> and add content to that window and you are getting the same. >>> But I look for the situation, where I have to get the >>> Toolbar button count on existing window which I will not >>> create on run time. >>> I am looking some solution on the same . Any further >>> thoughts from you is very much helpful. >>> Thx in advance and I hope that I have clarified my requirement. >>> Selva D >>> >>> --- On *Mon, 10/5/10, Kevin Marshall >>> /<kej...@ho...>/* wrote: >>> >>> >>> From: Kevin Marshall <kej...@ho...> >>> Subject: RE: [perl-win32-gui-users] Is it possible to >>> work on toolbar controls with win32::GUI >>> To: gan...@ya... >>> Cc: "Perl-Win32-GUI-Users List" >>> <per...@li...> >>> Date: Monday, 10 May, 2010, 7:44 AM >>> >>> Selva, >>> >>> You can use the ButtonCount() method to retrieve the >>> number of buttons in the toolbar and the GetButtonText() >>> method to retrieve the text of the specified button. >>> Here is some sample code: >>> >>> #!perl >>> use strict; >>> use warnings; >>> >>> use Data::Dump qw(dump); >>> use Win32::GUI qw(); >>> use Win32::GUI::Constants qw(TBSTATE_ENABLED >>> BTNS_SHOWTEXT IDB_STD_SMALL_COLOR CW_USEDEFAULT); >>> >>> my $win = Win32::GUI::Window->new( >>> -name => 'win', >>> -text => 'Toolbar Sample', >>> -size => [320,240], >>> -left => CW_USEDEFAULT, >>> ); >>> >>> $win->AddToolbar( >>> -name => 'toolbar', >>> -adjustable => 1, >>> -flat => 1, >>> -multiline => 1, >>> -nodivider => 1, >>> ); >>> my @buttons = (qw(Cut Copy Paste Undo Redo Delete New >>> Open Save Preview >>> Properties Help Find Replace Print)); >>> $win->toolbar->LoadImages(IDB_STD_SMALL_COLOR); >>> $win->toolbar->AddString($_) foreach @buttons; >>> $win->toolbar->AddButtons( >>> scalar @buttons, >>> map {($_,$_+1,TBSTATE_ENABLED,BTNS_SHOWTEXT,$_)} >>> 0..$#buttons >>> ); >>> >>> $win->Show(); >>> >>> Win32::GUI::Dialog(); >>> >>> sub win_Resize { >>> $win->toolbar->Width($win->Width()); >>> return 1; >>> } >>> >>> sub toolbar_ButtonClick { >>> my($index,$dropdown) = @_; >>> printf "Button %02d of %02d text => %s\n", $index, >>> $win->toolbar->ButtonCount(), >>> $win->toolbar->GetButtonText($index); >>> return 1; >>> } >>> __END__ >>> >>> Hope this helps, >>> >>> Kevin. >>> >>> > Date: Tue, 4 May 2010 05:38:04 -0700 >>> > From: gan...@ya... >>> > To: per...@li... >>> > Subject: [perl-win32-gui-users] Is it possible to work >>> on toolbar controls with win32::GUI >>> > >>> > Hi, >>> > I exhaustively looked at win32::GUI and please clarify >>> on the same. >>> > I just want to get the toolbar item- count and also >>> the text of the items in toolbar. I saw win32::GUI was >>> creating an window and doing adding some control for the >>> same. >>> > Is there any way to test the toolbar controls for the >>> existing toolbar by passing the window handler. >>> > >>> > I also tried with win32::GUItest..but not >>> succeeded.(by using sendmessage ) Please any clue on this? >>> > >>> > Thanks >>> > Selva D >>> > >>> > >>> > >>> > >>> > >>> > >>> ------------------------------------------------------------------------------ >>> > _______________________________________________ >>> > Perl-Win32-GUI-Users mailing list >>> > Per...@li... >>> > >>> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >>> > http://perl-win32-gui.sourceforge.net/ >>> >>> ------------------------------------------------------------------------ >>> Looking for a hot date? View photos of singles in your >>> area! <http://clk.atdmt.com/NMN/go/150855801/direct/01/> >>> >>> >> >> > > > |
From: Kevin M. <kej...@ho...> - 2010-05-20 00:08:18
|
Selva, I have managed to throw together a quick script that can be used to find info on a toolbar of another application. To use it, run the script and click and hold the left mouse button on the 'Find Window' button. This will hide the window, then while still holding the mouse button down, move the mouse over the toolbar of the other application and release the mouse. The window of the script should reappear, and display the number of buttons in the toolbar in the text box. Unfortunately, if you try to get the text of the toolbar buttons, the script crashes. At least, that is what happens for me when I try it on an instance of Notepad2 <http://www.flos-freeware.ch/notepad2.html>. Not sure exactly what causes this. It may work for you. Try un-commenting the block of code in the onMouseMove event to see what happens. Anyway, here is my script: #!perl use strict; use warnings; use Data::Dump qw(dump); #use Win32::API; use Win32::GUI qw(); use Win32::GUI::Constants qw(CW_USEDEFAULT HOLLOW_BRUSH WM_USER); #use constant {TB_GETBUTTON => WM_USER+23}; my $MouseDown = 0; my $FoundHandle; my $penHilight = Win32::GUI::Pen->new(-width => 5, -color => 0x000000, -style => 0); my $winMain = Win32::GUI::Window->new( -name => 'winMain', -text => 'Window Finder', -size => [320,240], -left => CW_USEDEFAULT, -maximizebox => 0, -resizable => 0, ); $winMain->AddButton( -name => 'btnWinFind', -text => 'Find Window', -pos => [$winMain->ScaleWidth()/2-40,5], -size => [80,25], -onMouseDown => sub { my($self,$x,$y,$flags) = @_; $MouseDown = 1; $winMain->Hide(); $self->SetCapture(); return 1; }, -onMouseUp => sub { my($self,$x,$y,$flags) = @_; $MouseDown = 0; if($FoundHandle){ Win32::GUI::InvalidateRect($FoundHandle, 1); Win32::GUI::Update($FoundHandle); Win32::GUI::Redraw($FoundHandle, 1); $winMain->Show(); $self->ReleaseCapture(); if(Win32::GUI::GetClassName($FoundHandle) eq 'ToolbarWindow32'){ my $count = Win32::GUI::Toolbar::ButtonCount($FoundHandle); $winMain->txtInfo->Text("$count\r\n"); # foreach(0..$count-1){ # my $tbbutton = "\0" x 20; # Win32::GUI::SendMessage($FoundHandle, TB_GETBUTTON, $_, $tbbutton); # dump $tbbutton; # my @button = Win32::GUI::Toolbar::GetButton($FoundHandle, $_); # my @size = Win32::GUI::Toolbar::GetButtonSize($FoundHandle); # my $text = Win32::GUI::Toolbar::GetButtonText($FoundHandle, $_); # $winMain->txtInfo->Append(join "\r\n", @size); # } } } return 1; }, -onMouseMove => sub { my($self,$x,$y,$flags) = @_; if($MouseDown){ my $found = Win32::GUI::WindowFromPoint($self->ClientToScreen($x,$y)); if($found){ $FoundHandle = $found; Win32::GUI::InvalidateRect($found, 1); Win32::GUI::Update($found); Win32::GUI::Redraw($found, 1); my $dc = Win32::GUI::DC::GetDC($found); my %rect; @rect{qw(left top right bottom)} = Win32::GUI::GetWindowRect($found); if($dc){ my $oldpen = Win32::GUI::DC::SelectObject($dc, $penHilight); my $oldbrush = Win32::GUI::DC::SelectObject($dc, Win32::GUI::DC::GetStockObject(HOLLOW_BRUSH)); Win32::GUI::DC::Rectangle($dc,0,0,$rect{right}-$rect{left},$rect{bottom}-$rect{top}); Win32::GUI::DC::SelectObject($dc, $oldpen) if $oldpen; Win32::GUI::DC::SelectObject($dc, $oldbrush) if $oldbrush; Win32::GUI::DC::ReleaseDC($found, $dc); } else { warn "Can't get DC: $^E"; } } } return 1; }, ); $winMain->AddTextfield( -name => 'txtInfo', -size => [$winMain->ScaleWidth()-10,$winMain->ScaleHeight()-40], -pos => [5,35], -multiline => 1, ); $winMain->Show(); Win32::GUI::Dialog(); __END__ I based this code off of some C/C++ code that was posted here <http://www.codeproject.com/kb/dialog/windowfinder.aspx>. Hope this helps, Kevin. > Kevin, > Thanks for your response.This is not created with Win32::GUI > This is VC++ application and in that application, in the toolbar (you > could see save image etc - attachment- red colored is the toolbar > INeed to work), I have to get/do the > Toolbar count , > Button click based on indiex or test > Click on IMage > Size of Each Button > Individual Button State. > My perl script will not create these window application, I have to > to some activity on these tollbar icons such as click and for this I > need use of this module. > Thx > Selva D > > --- On *Wed, 19/5/10, Kevin Marshall /<kej...@ho...>/* wrote: > > > From: Kevin Marshall <kej...@ho...> > Subject: Re: [perl-win32-gui-users] Is it possible to work on > toolbar controls with win32::GUI > To: "selva ganapathy" <gan...@ya...> > Cc: per...@li... > Date: Wednesday, 19 May, 2010, 5:07 AM > > Selva, > > How exactly is this other window with toolbar created? Is it from > a completely separate script or from a module that your script > loads? Is it created using Win32::GUI in Perl? Could you provide a > small example of your problem? > > Sorry for the confusion. > > Kevin. >> Kevin. >> Thanks for the update. The one you have referred will get the >> tool bar button count for which you create the window and add >> content to that window and you are getting the same. >> But I look for the situation, where I have to get the Toolbar >> button count on existing window which I will not create on run time. >> I am looking some solution on the same . Any further thoughts >> from you is very much helpful. >> Thx in advance and I hope that I have clarified my requirement. >> Selva D >> >> --- On *Mon, 10/5/10, Kevin Marshall /<kej...@ho...>/* wrote: >> >> >> From: Kevin Marshall <kej...@ho...> >> Subject: RE: [perl-win32-gui-users] Is it possible to work on >> toolbar controls with win32::GUI >> To: gan...@ya... >> Cc: "Perl-Win32-GUI-Users List" >> <per...@li...> >> Date: Monday, 10 May, 2010, 7:44 AM >> >> Selva, >> >> You can use the ButtonCount() method to retrieve the number >> of buttons in the toolbar and the GetButtonText() method to >> retrieve the text of the specified button. Here is some >> sample code: >> >> #!perl >> use strict; >> use warnings; >> >> use Data::Dump qw(dump); >> use Win32::GUI qw(); >> use Win32::GUI::Constants qw(TBSTATE_ENABLED BTNS_SHOWTEXT >> IDB_STD_SMALL_COLOR CW_USEDEFAULT); >> >> my $win = Win32::GUI::Window->new( >> -name => 'win', >> -text => 'Toolbar Sample', >> -size => [320,240], >> -left => CW_USEDEFAULT, >> ); >> >> $win->AddToolbar( >> -name => 'toolbar', >> -adjustable => 1, >> -flat => 1, >> -multiline => 1, >> -nodivider => 1, >> ); >> my @buttons = (qw(Cut Copy Paste Undo Redo Delete New Open >> Save Preview >> Properties Help Find Replace Print)); >> $win->toolbar->LoadImages(IDB_STD_SMALL_COLOR); >> $win->toolbar->AddString($_) foreach @buttons; >> $win->toolbar->AddButtons( >> scalar @buttons, >> map {($_,$_+1,TBSTATE_ENABLED,BTNS_SHOWTEXT,$_)} 0..$#buttons >> ); >> >> $win->Show(); >> >> Win32::GUI::Dialog(); >> >> sub win_Resize { >> $win->toolbar->Width($win->Width()); >> return 1; >> } >> >> sub toolbar_ButtonClick { >> my($index,$dropdown) = @_; >> printf "Button %02d of %02d text => %s\n", $index, >> $win->toolbar->ButtonCount(), >> $win->toolbar->GetButtonText($index); >> return 1; >> } >> __END__ >> >> Hope this helps, >> >> Kevin. >> >> > Date: Tue, 4 May 2010 05:38:04 -0700 >> > From: gan...@ya... >> > To: per...@li... >> > Subject: [perl-win32-gui-users] Is it possible to work on >> toolbar controls with win32::GUI >> > >> > Hi, >> > I exhaustively looked at win32::GUI and please clarify on >> the same. >> > I just want to get the toolbar item- count and also the >> text of the items in toolbar. I saw win32::GUI was creating >> an window and doing adding some control for the same. >> > Is there any way to test the toolbar controls for the >> existing toolbar by passing the window handler. >> > >> > I also tried with win32::GUItest..but not succeeded.(by >> using sendmessage ) Please any clue on this? >> > >> > Thanks >> > Selva D >> > >> > >> > >> > >> > >> > >> ------------------------------------------------------------------------------ >> > _______________________________________________ >> > Perl-Win32-GUI-Users mailing list >> > Per...@li... >> > >> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >> > http://perl-win32-gui.sourceforge.net/ >> >> ------------------------------------------------------------------------ >> Looking for a hot date? View photos of singles in your area! >> <http://clk.atdmt.com/NMN/go/150855801/direct/01/> >> >> > > |
From: Kevin M. <kej...@ho...> - 2010-05-18 23:37:44
|
Selva, How exactly is this other window with toolbar created? Is it from a completely separate script or from a module that your script loads? Is it created using Win32::GUI in Perl? Could you provide a small example of your problem? Sorry for the confusion. Kevin. > Kevin. > Thanks for the update. The one you have referred will get the tool bar > button count for which you create the window and add content to that > window and you are getting the same. > But I look for the situation, where I have to get the Toolbar button > count on existing window which I will not create on run time. > I am looking some solution on the same . Any further thoughts from you > is very much helpful. > Thx in advance and I hope that I have clarified my requirement. > Selva D > > --- On *Mon, 10/5/10, Kevin Marshall /<kej...@ho...>/* wrote: > > > From: Kevin Marshall <kej...@ho...> > Subject: RE: [perl-win32-gui-users] Is it possible to work on > toolbar controls with win32::GUI > To: gan...@ya... > Cc: "Perl-Win32-GUI-Users List" > <per...@li...> > Date: Monday, 10 May, 2010, 7:44 AM > > Selva, > > You can use the ButtonCount() method to retrieve the number of > buttons in the toolbar and the GetButtonText() method to retrieve > the text of the specified button. Here is some sample code: > > #!perl > use strict; > use warnings; > > use Data::Dump qw(dump); > use Win32::GUI qw(); > use Win32::GUI::Constants qw(TBSTATE_ENABLED BTNS_SHOWTEXT > IDB_STD_SMALL_COLOR CW_USEDEFAULT); > > my $win = Win32::GUI::Window->new( > -name => 'win', > -text => 'Toolbar Sample', > -size => [320,240], > -left => CW_USEDEFAULT, > ); > > $win->AddToolbar( > -name => 'toolbar', > -adjustable => 1, > -flat => 1, > -multiline => 1, > -nodivider => 1, > ); > my @buttons = (qw(Cut Copy Paste Undo Redo Delete New Open Save > Preview > Properties Help Find Replace Print)); > $win->toolbar->LoadImages(IDB_STD_SMALL_COLOR); > $win->toolbar->AddString($_) foreach @buttons; > $win->toolbar->AddButtons( > scalar @buttons, > map {($_,$_+1,TBSTATE_ENABLED,BTNS_SHOWTEXT,$_)} 0..$#buttons > ); > > $win->Show(); > > Win32::GUI::Dialog(); > > sub win_Resize { > $win->toolbar->Width($win->Width()); > return 1; > } > > sub toolbar_ButtonClick { > my($index,$dropdown) = @_; > printf "Button %02d of %02d text => %s\n", $index, > $win->toolbar->ButtonCount(), > $win->toolbar->GetButtonText($index); > return 1; > } > __END__ > > Hope this helps, > > Kevin. > > > Date: Tue, 4 May 2010 05:38:04 -0700 > > From: gan...@ya... > > To: per...@li... > > Subject: [perl-win32-gui-users] Is it possible to work on > toolbar controls with win32::GUI > > > > Hi, > > I exhaustively looked at win32::GUI and please clarify on the same. > > I just want to get the toolbar item- count and also the text of > the items in toolbar. I saw win32::GUI was creating an window and > doing adding some control for the same. > > Is there any way to test the toolbar controls for the existing > toolbar by passing the window handler. > > > > I also tried with win32::GUItest..but not succeeded.(by using > sendmessage ) Please any clue on this? > > > > Thanks > > Selva D > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > > Perl-Win32-GUI-Users mailing list > > Per...@li... > > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > > http://perl-win32-gui.sourceforge.net/ > > ------------------------------------------------------------------------ > Looking for a hot date? View photos of singles in your area! > <http://clk.atdmt.com/NMN/go/150855801/direct/01/> > > |
From: Jeremy W. <jez...@ho...> - 2010-05-12 08:38:22
|
Hi, Dealing with your last question first. All GUI toolkits have "problems" and are prone to crashing when things go wrong internally. What version of Perl and Win32::GUI are you using? I couldn't see any leak with Tutorial_Part1_hello1.pl? Is your crash random? Or is it due to running out of memory? Does the application crash when you use the menu system, or shortly after? How are you changing the colors on the controls? Are you using the change method? If so, this is the cause of the leak, see the tracker item: http://sourceforge.net/tracker/?func=detail&aid=2864551&group_id=16572&atid=116572 I know it's a pain to do, but could you produce a minimal example that crashes and leaks? I'll take a look (feel free to email off list). Cheers, jez. > From: wb...@sa... > To: per...@li... > Date: Tue, 11 May 2010 21:32:26 +0200 > Subject: [perl-win32-gui-users] Problem with graphic application > > Hello! > > I have a GUI application which from time to time crashes. Buttons, textfield > and other object disappear, but not the all. It's very strange because the > application can work persistent few hours without problem but sometimes the > problem happens few times in one hour. This is an application which > dynamically creates many windows with database data - about 20-40 in one > session. The window contains only textfields, buttons and labels, but there can > by many of them (100-200 tetxfields sometimes more). All the objects can also > have dynamically determined colors which depend on values of the textfields. > Additionally icons are stored inside the application by using the module: > > use Win32::GUI::BitmapInline(); > > At last I should add that all the window is scaled along x and y axis > independently. So many graphical operations... > > > I wonder if it could be a leak memory which is similar to the "leak" which can > be found in a demo application like Tutorial_Part1_hello1.pl demo. It can be > seen when you open Task Manager and watch the amount of memory perl consumes. > Even the simple mouse moving when the application is active shows that the > memory rise up constantly. Is it problem with Win32::GUI? > > Another question is as follows. Has the small errors (warnings) meaning in the > context of the crashes? I thing about for instance warning in counting the > exprossion like substr($foo,3,4) when $foo has only length of 2. Usually I > start the perl with the: > > #perl -W > use warnings; > use strict; > > Could it be proper to switch off the options? > > Ane comments and experience sharing is much appriciated. And is there similar > problem in other GUI perl libraries? > > Waldemar > > ------------------------------------------------------------------------------ > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ _________________________________________________________________ http://clk.atdmt.com/UKM/go/197222280/direct/01/ Do you have a story that started on Hotmail? Tell us now |
From: Kevin M. <kej...@ho...> - 2010-05-12 05:41:22
|
Waldemar, Do you mean when you application exits, because Win32::GUI generally takes care of the destruction of any windows on exit. Sometimes, however, you may receive an error along the lines of "Can't call method STORE on an undefined value...". In which case, you can just undef() your windows before you exit to suppress these messages. If you are needing to reuse windows, then hiding them instead of destroying them could be better, since there would probably be some overhead in creating a window each time it is needed. You would just have to remember to reset all the window's controls when the window is needed again. I know for programs I have written that use a lot of windows, there are a lot which are created, and then shown using DoModal(), in subroutines that are called from events, so they are automatically destroyed when the subroutine returns. I could probably improve performance by creating them beforehand, but I suppose it depends on the situation. I have also seen code where the windows are hidden after the Win32::GUI::Dialog() call, before the program exits. I am not sure if there is anything to be gained from this; again, it all comes down to personal preference. There's no functional difference between "Label${Counter}" and "Label$Counter", it's just that putting braces around the names of variables in strings prevents Perl from thinking that trailing alphanumeric characters are part of the variable name. For instance, if you had the string "$CounterLabel" instead, then Perl would look for a $CounterLabel variable. Check out the perldata manpage for more info. It's just a habit that I have gotten into to make variables in strings clearer. Kevin. _________________________________________________________________ New, Used, Demo, Dealer or Private? Find it at CarPoint.com.au http://clk.atdmt.com/NMN/go/206222968/direct/01/ |
From: Kevin M. <kej...@ho...> - 2010-05-11 23:39:48
|
Waldemar, One reason for your controls disappearing might be that they don't have unique names. If you create a control with the same name as an existing control, the previous control is destroyed. A possible solution could be to keep a counter of the number of controls created which could be used to create unique names, example: my $Counter = 1; foreach(1..10){ $win->AddTextfield -name => "Textfield${Counter}", ); $Counter++; } foreach(1..10){ $win->AddLabel( -name => "Label${Counter}", ); $Counter++; } __END__ Hope this helps, Kevin. _________________________________________________________________ Need a new place to live? Find it on Domain.com.au http://clk.atdmt.com/NMN/go/157631292/direct/01/ |
From: Waldemar B. <wb...@sa...> - 2010-05-11 20:32:40
|
Hello! I have a GUI application which from time to time crashes. Buttons, textfield and other object disappear, but not the all. It's very strange because the application can work persistent few hours without problem but sometimes the problem happens few times in one hour. This is an application which dynamically creates many windows with database data - about 20-40 in one session. The window contains only textfields, buttons and labels, but there can by many of them (100-200 tetxfields sometimes more). All the objects can also have dynamically determined colors which depend on values of the textfields. Additionally icons are stored inside the application by using the module: use Win32::GUI::BitmapInline(); At last I should add that all the window is scaled along x and y axis independently. So many graphical operations... I wonder if it could be a leak memory which is similar to the "leak" which can be found in a demo application like Tutorial_Part1_hello1.pl demo. It can be seen when you open Task Manager and watch the amount of memory perl consumes. Even the simple mouse moving when the application is active shows that the memory rise up constantly. Is it problem with Win32::GUI? Another question is as follows. Has the small errors (warnings) meaning in the context of the crashes? I thing about for instance warning in counting the exprossion like substr($foo,3,4) when $foo has only length of 2. Usually I start the perl with the: #perl -W use warnings; use strict; Could it be proper to switch off the options? Ane comments and experience sharing is much appriciated. And is there similar problem in other GUI perl libraries? Waldemar |
From: Kevin M. <kej...@ho...> - 2010-05-10 02:14:39
|
Selva, You can use the ButtonCount() method to retrieve the number of buttons in the toolbar and the GetButtonText() method to retrieve the text of the specified button. Here is some sample code: #!perl use strict; use warnings; use Data::Dump qw(dump); use Win32::GUI qw(); use Win32::GUI::Constants qw(TBSTATE_ENABLED BTNS_SHOWTEXT IDB_STD_SMALL_COLOR CW_USEDEFAULT); my $win = Win32::GUI::Window->new( -name => 'win', -text => 'Toolbar Sample', -size => [320,240], -left => CW_USEDEFAULT, ); $win->AddToolbar( -name => 'toolbar', -adjustable => 1, -flat => 1, -multiline => 1, -nodivider => 1, ); my @buttons = (qw(Cut Copy Paste Undo Redo Delete New Open Save Preview Properties Help Find Replace Print)); $win->toolbar->LoadImages(IDB_STD_SMALL_COLOR); $win->toolbar->AddString($_) foreach @buttons; $win->toolbar->AddButtons( scalar @buttons, map {($_,$_+1,TBSTATE_ENABLED,BTNS_SHOWTEXT,$_)} 0..$#buttons ); $win->Show(); Win32::GUI::Dialog(); sub win_Resize { $win->toolbar->Width($win->Width()); return 1; } sub toolbar_ButtonClick { my($index,$dropdown) = @_; printf "Button %02d of %02d text => %s\n", $index, $win->toolbar->ButtonCount(), $win->toolbar->GetButtonText($index); return 1; } __END__ Hope this helps, Kevin. > Date: Tue, 4 May 2010 05:38:04 -0700 > From: gan...@ya... > To: per...@li... > Subject: [perl-win32-gui-users] Is it possible to work on toolbar controls with win32::GUI > > Hi, > I exhaustively looked at win32::GUI and please clarify on the same. > I just want to get the toolbar item- count and also the text of the items in toolbar. I saw win32::GUI was creating an window and doing adding some control for the same. > Is there any way to test the toolbar controls for the existing toolbar by passing the window handler. > > I also tried with win32::GUItest..but not succeeded.(by using sendmessage ) Please any clue on this? > > Thanks > Selva D > > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ _________________________________________________________________ View photos of singles in your area! Looking for a hot date? http://clk.atdmt.com/NMN/go/150855801/direct/01/ |
From: selva g. <gan...@ya...> - 2010-05-04 12:38:20
|
Hi, I exhaustively looked at win32::GUI and please clarify on the same. I just want to get the toolbar item- count and also the text of the items in toolbar. I saw win32::GUI was creating an window and doing adding some control for the same. Is there any way to test the toolbar controls for the existing toolbar by passing the window handler. I also tried with win32::GUItest..but not succeeded.(by using sendmessage ) Please any clue on this? Thanks Selva D |
From: Kevin M. <kej...@ho...> - 2010-05-04 05:43:33
|
Ramakanta, The problem is that system will block until the script completes, which means the join() on the thread will also block. If you can do without the return value, you can detach() the thread instead of join()ing it. I'm not too sure as to how you can call DoEvents() while waiting for system() to return and also return a value. Someone else may reply to your email with an elegant solution. Otherwise, you could try searching the Win32::GUI Users mail archive here. There are quite a number of posts concerning threads and Win32::GUI; some also have sample code, which you may find useful. Sorry I can't be of more help. Kevin. _________________________________________________________________ Browse profiles for FREE! Meet local singles online. http://clk.atdmt.com/NMN/go/150855801/direct/01/ |
From: Kevin M. <kej...@ho...> - 2010-05-04 04:02:14
|
Ramakanta, I'm not sure what you are trying to do here: sub Loop_Click { print "Loop clicked \n"; $win ->( -activate => (1)); #<========== my $thr2 = threads->create( \&thread2); $res =$thr2->join(); print "hello $res\n"; }; __END__ I think you meant: sub Loop_Click { print "Loop clicked \n"; $win->Animate( -activate => (1)); #<========== # you could use $win->Show() instead my $thr2 = threads->create( \&thread2); $res =$thr2->join(); print "hello $res\n"; }; __END__ Also, in the file 'rama.pl', you haven't incremented $i, so it loops indefinitely and never returns. Change it to something like this: $i=0; while ( $i++ < 5 ) #<====== #or even for(1..5) { print" hi ramakanta\n"; sleep 5; } __END__ You program will still block until this script completes, which means the windows will not respond until then. You will need to somehow call DoEvents() while this script is running. Hope this helps, Kevin. _________________________________________________________________ Browse profiles for FREE! Meet local singles online. http://clk.atdmt.com/NMN/go/150855801/direct/01/ |