[perl-win32-gui-users] Wrappers for listviews/comboboxes etc...
Hi all, I've been using Win32::GUI for a while now and regularly scanning the archives of this list. At long last, I finally have something worth posting to the group about... In a number of my applications I have found that my lisview/comboboxes etc. tend to represent either a subset of a database table or a collection of objects. Because of the nature of this kind of work, I am often hiding primary keys in 0-width columns in listview or writing subs to check the selection on a drop-down and return some other value. I decided that it was time to whip up some wrapper modules that do all of this for me. It seems to me like it would be a pretty handy thing to have around, so here are a few questions for the group: Have any of you done this sort of thing before? If so, can I have a look? Does this make any sense? Any helpful suggestions? -Ariel
Re: [perl-win32-gui-users] Wrappers for listviews/comboboxes etc...
Thanks for the responses... That's good to know about Text() on the comboboxes. I've been doing it the other way, as well. I'm not sure if there's any weirdness related to having the 0-width column because I always do fullrowselect. I've thought about the shadow array idea before and it is probably the best way to go. One of the benefits to having the hidden field is that I can expand it when debugging my code, but that doesn't seem to be a good reason to design the wrapper in that manner. Now that I think about it, the array would probably be best for consistency, since there's nowhere to hide a key field in the comboboxes. I'm not exactly sure how I would like to implement this either. It would be cool to be able to do something like: # get some data $sth = $dbh->prepare('select person_id, first_name, last_name from people'); ... # call a method to assign ids and populate the LV. # if called without a key field it could # automagically assign ids $lv_wrapper->populate($sth->fetchall_hashref, 'person_id'); # suppose we have a button to remove items # from the LV btnRemove_Click { $id = $lv_wrapper->id(); $lv_wrapper->remove($id); return 1; } The neat thing about the hashref idea is that columns could be named just by setting the AS params in the sql and everything would be taken care of. This is a decent model for when I'm building gui elements from a DB, but it doesn't really match up to situations where I build elements from an array of objects. Any opinions? -Ariel
Re: [perl-win32-gui-users] RegEx
perlmonks.com is a great place to look for answers to questions like this. The quick answer to your question is: $stuff = 'Client/workstation///printserver/printer,winspool,ne01:'; my ($client, $station, $server, $printer, $spool, $otherthing) = ($stuff =~ m|(\w+)/(\w+)///(\w+)/(\w+),(\w+),(\w+):|); print "$client, $station, $server, $printer, $spool, $otherthing\n"; --- MJG <[EMAIL PROTECTED]> wrote: > I'm in need of the RegEx users. > > In the Terminal server environment, printer mapping > creates a long > string. > > Client/workstation///printserver/printer,winspool,ne01: > > I need to parse this information out without doing a > dozen splits if at > all possible. > > The outcome I need is: > > 1). Each element, client,workstation, etc > 2). Client/workstation///printserver/printer > 3). Winspool,ne01: > > Can this be done with an all inclusive RegEx? > > Thanks > > MJG > > > --- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT > Products from real users. > Discover which products truly live up to the hype. > Start reading now. > http://ads.osdn.com/?ad_ide95&alloc_id396&op=click > ___ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >
[perl-win32-gui-users] wrappers revisited
I've been toying with the listview wrapper idea that I brought up last week. I threw together a module to show off the basic idea, though it needs to be reworked. I wanted to make it easy to set up a listview and keep track of the items by some id. When I started writing this, I used the hashref-of-hashrefs idea like DBI returns from fetchall_hashref() because it seemed like a good way of matching name/value pairs up with their respective ids. The problem with this is that there currently isn't a good way to sort the items in the listview because of the nature of hashing. If you're interested in having a look, I have the rough module and a test script here: http://www.serbin.org/ariel/mms.zip I can easily fix this up to suit my immediate needs, but I think that it would be nice to make it more generic so that it would be helpful to others. If anyone has any opinions as to how this could be better implemented, please offer them up... -Ariel
Re: [perl-win32-gui-users] wrappers revisited
--- Johan Lindstrom <[EMAIL PROTECTED]> wrote: > Have you considered subclassing Win32::GUI::ListView > and just add the > ability to specify an optional -id when adding an > Item? This would have the As someone who has come to rely pretty heavily on Win32::GUI, I did think about subclassing/modifying the ListView object, but I have a few good reasons why I didn't go that route. First of all, I'm not much of an OO programmer. I like to encapsulate my modules as objects, but have only done the most basic of inheritance type stuff. Secondly, I don't really understand how Win32::GUI works. I've never done XS and the whole thing is a bit of a black box to me. I would love to muck about in Win32::GUI::ListView::Add() if only I could find it! Finally, as I understand it (see preceding paragraph for qualifications), Win32::GUI is basically a wrapper that calls some functions in some windows dll. I'm not sure if it's appropriate to be beefing it up with too much perl-side logic. For that reason, subclassing it seems more natural than altering the module itself...
Re: [perl-win32-gui-users] wrappers revisited
I made some changes to my wrapper module that I mentioned the other day. I had considered the sorting issues that Joe mentioned and added sorting routines similar to the code that he posted. The wrapper now has a sorting scheme that defaults to a regular cmp, but lets you pass in a sub to convert the data if you want. For an example, uncomment the code in the lv_ColumnClick event handler in my new test script: http://www.serbin.org/ariel/mms.zip So far, this seems to be a pretty handy way to manage listviews for me. The think that I like about it is really easy to show the results of the query and the wrapper can return either the relevant ID or the underlying data. (see the mybutton_Click handler for an example.) In one app that I'm working on, I'd like to let the user decide which columns they would like to see in the listview. At first, I had planned to just write something to collapse unwanted columns to 0 width, but I think that using this module is much more intuitive. I also like the fact that the "rows" are not limited to what is shown in the listview. As always, thoughts are appreciated. -Ariel
[perl-win32-gui-users] Listview double click
Is there a double click event fired for listviews?
[perl-win32-gui-users] AxWindow examples
Does anyone have any axwindow examples that embed applications other that IE? I've gotten IE to work nicely, but have run into some weird behavior with Excel. Now I am specing an application which would need a viewer for a variety of document types. I would be interested in seeing examples for any program other than IE and would be willing to clean them up for submission to the axwindow documentation. thanks, -Ariel
[perl-win32-gui-users] AxWindow Application Error
I'm having a problem with AxWindow throwing an error when it quits. I'm embedding the Microsoft Office Document Imaging program into my app. When my program exits, i get a dialog box that reads: -- The instruction at "xx" referenced memory at "xx". The memory could not be "read". Click OK to terminate the program -- Does anyone know how to track down why/where this error is occurring? The MODI control seems to be initialized properly and working fine while the program is running. Please note that I am calling $Control->Release() as mentioned in the AxWindow docs. Here is a stripped down version of my code. Please note that MODI will only embed with Office 2003 or later... (using perl 5.8, ax 0.07, win xp) use Win32::GUI; use Win32::GUI::AxWindow; use Win32::OLE; use Win32::OLE::Const; # main Window $Window = new Win32::GUI::Window ( -title=> "Win32::GUI::AxWindow test", -pos => [100, 100], -size=> [400, 400], -name => "Window", ) or die "new Window"; # Create AxWindow $Control = new Win32::GUI::AxWindow ( -parent => $Window, -name=> "Control", -pos => [10, 10], -size=> [300, 300], -control => 'MiDocViewer.MiDocView', ) or die "new Control"; sub Window_Terminate { $Control->Release(); return -1; } If anyone knows where I should look to resolve this, I would be extremely grateful. Once I get this working, I will submit some examples (and possibly a module) showing how to play with MODI. Thanks, -Ariel
Re: [perl-win32-gui-users] AxWindow Application Error
Jez, Thanks for the reply. I tried undefing the window, ax-control and ole-control in various orders. All of them still generated the error. I tried stepping through the script to see which undef was causing the error, but it seems to be caused by something under the hood that happens after all of that. This error occurs on both my home computer and my work computer, which are basically the same configuration. FYI, this control will let you view/ocr/search .tif and .mdi files. It just didn't do anything because we're not asking it to. If you'd like to see it in action, add this after the control is set up: $v = $Control->GetOLE(); $v->{FileName} = 'test.TIF'; there's a decent description of the object model here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mspauto/html/welcomemodi_hv01135783.asp -ariel --- Jez White <[EMAIL PROTECTED]> wrote: > Hi Ariel, > > As a guess this could be a scoping issue. When your > app is shutting down, > various Perl variables will be destroyed and where > appropriate, they will > call the destructors "elsewhere" (in the xs code), > i.e., your main window > might be getting destroyed before your control (or > vice versa) resulting in > crashes. If this is a scoping issue, then it should > be easily solvable... > > BTW - I ran your code on my box here (perl 5.6 and > ax 0.7 I added > $Window->Show();Win32::GUI::Dialog(); to your > example) and it didn't crash > on exit - although I've no idea what the control > should be:) > > Have a play with undef'ing the window and controls > in various orders and see > if that makes any difference. > > Cheers, > > jez. > > - Original Message - > From: "Ariel Serbin" <[EMAIL PROTECTED]> > To: > Sent: Saturday, May 07, 2005 6:02 PM > Subject: [perl-win32-gui-users] AxWindow Application > Error > > > > I'm having a problem with AxWindow throwing an > error > > when it quits. I'm embedding the Microsoft Office > > Document Imaging program into my app. When my > program > > exits, i get a dialog box that reads: > > > > -- > > The instruction at "xx" referenced memory at > > "xx". The memory could not be "read". Click > OK > > to terminate the program > > -- > > > > Does anyone know how to track down why/where this > > error is occurring? > > > > The MODI control seems to be initialized properly > and > > working fine while the program is running. Please > > note that I am calling $Control->Release() as > > mentioned in the AxWindow docs. > > > > Here is a stripped down version of my code. > Please > > note that MODI will only embed with Office 2003 or > > later... > > > > (using perl 5.8, ax 0.07, win xp) > > > > use Win32::GUI; > > use Win32::GUI::AxWindow; > > use Win32::OLE; > > use Win32::OLE::Const; > > > > # main Window > > $Window = new Win32::GUI::Window ( > >-title=> "Win32::GUI::AxWindow test", > >-pos => [100, 100], > >-size=> [400, 400], > >-name => "Window", > > ) or die "new Window"; > > > > # Create AxWindow > > $Control = new Win32::GUI::AxWindow ( > > -parent => $Window, > > -name=> "Control", > > -pos => [10, 10], > > -size=> [300, 300], > > -control => 'MiDocViewer.MiDocView', > > ) or die "new Control"; > > > > sub Window_Terminate { > > $Control->Release(); > > return -1; > > } > > > > If anyone knows where I should look to resolve > this, I > > would be extremely grateful. Once I get this > working, > > I will submit some examples (and possibly a > module) > > showing how to play with MODI. > > > > Thanks, > > > > -Ariel > > > > > > > --- > > This SF.Net email is sponsored by: NEC IT Guy > Games. > > Get your fingers limbered up and give it your best > shot. 4 great events, 4 > > opportunities to win big! Highest score wins.NEC > IT Guy Games. Play to > > win an NEC 61 plasma display. Visit > http://www.necitguy.com/?r=20 > > ___ > > Perl-Win32-GUI-Users mailing list > > Perl-Win32-GUI-Users@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > > >
Re: [perl-win32-gui-users] Simple Text
To add plain text, you can use a label: $W->AddLabel( -name => "mylabel1", -left => 10, -top => 150, -width=> 100, -height => 22, -text => "Some Text Here" ); --- MJG <[EMAIL PROTECTED]> wrote: > I have a simple window I've created. Usually, I > just do windows with > buttons, but I have a need for text with the window. > I have not found > any examples of how to do this. Can someone provide > an example within > my example of how to just add text to the main > portion of the window? > Thank you in advance > > > Use Win32::GUI; > use Win32 (); > > &Win32_GUI(); > > quit(0); > > sub Win32_GUI > { > > my $I = new Win32::GUI::Icon('icon.ICO'); > my $C = new Win32::GUI::Bitmap("./harrow.cur", 2); > > my $F = new Win32::GUI::Font( > -name => "Comic Sans MS", > -size => 10, > -bold => 0, > -underline=>0, > ); > > # Register a BUTTON class with cursor > my $BC = new Win32::GUI::Class( > -name => 'Class_Button', > -extends => 'BUTTON', > -widget => 'Button', > -cursor => $C, > ); > > my $WC = new Win32::GUI::Class( > -name => '_Button', > -cursor => $C, > -icon => $I, > -color => 2, > ); > > my $W = new Win32::GUI::Window( > -title=> "Uptime Monitor", > -pos => [100, 100], > -size => [400, 400], > -left => 300, > -top => 100, > -width=> 300, > -height => 600, > -name => "Main", > -class=> $WC, > -topmost => 1, > -font => $F, > -sysmenu => 0, > -resizable=>0, > ); > > $W->AddButton( >-text=> "Server List", >-name=> "GroupBox_1", >-left=> 2, >-top => 40, >-width => 290, >-height => 530, >-style => WS_CHILD | WS_VISIBLE | 7, # GroupBox > ); > > $W->AddButton( > -name=> "Update", > -left=> 150, > -top => 5, > -text=> "Update", > -tabstop => 1, > -class => $BC, > #-icon => $I, > ); > > $W->AddButton( > -name=> "Close", > -left=> 50, > -top => 5, > -text=> "Exit", > -tabstop => 1, > -class => $BC, > #-icon => $I, > ); > > #$W->{-dialogui} = 0; > > my ($left, $top, $right, $bottom) = > Win32::GUI::GetDesktopWindow(); > > my $SysTrayICON = new Win32::GUI::Icon('icon.ICO'); > > my $SysTray = $W->AddNotifyIcon(-name => "SysTray", > -id => 1, > -icon => $SysTrayICON, > -tip => "UPTIME!", > ); > > > $W->Show(); > > Win32::GUI::Dialog(0); > > } > > sub Window_Terminate { > return -1; > } > > sub Close_Click { > > Window_Terminate(); > } > > sub Update_Click { > > > } > > __END__ > > > > --- > This SF.Net email is sponsored by: NEC IT Guy Games. > Get your fingers limbered up and give it your best > shot. 4 great events, 4 > opportunities to win big! Highest score wins.NEC IT > Guy Games. Play to > win an NEC 61 plasma display. Visit > http://www.necitguy.com/?r > ___ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >
RE: [perl-win32-gui-users] Simple Text
i'm not positive about the best way to do this, but labels can wrap text. if you just make a big label it will work. try this: use Win32::GUI; $win = new Win32::GUI::Window( -title => 'test', -name => 'mywin', -left => 100, -top => 100, -width => 400, -height => 400, ); $lbl = $win->AddLabel( -name => 'lbl1', -top => 50, -left => 10, -width => 380, -height => 340, -text => 'this is the starting text and it is a really really really really really really really really really really really really really really really really long line...' ); $win->AddButton( -name => 'btn1', -text => 'click me' ); $win->Show(); Win32::GUI::Dialog(); sub mywin_Terminate {-1}; sub btn1_Click { my $txt = $lbl->Text(); $txt .= "\nmore label text here"; $lbl->Text($txt); } --- MJG <[EMAIL PROTECTED]> wrote: > Ok, that's cool, but let's say I want to fill the > entire window with > text. Do I use a label for each row, or is there > something I can use to > just fill the window? > > Thanks > > -Original Message- > From: Ariel Serbin [mailto:[EMAIL PROTECTED] > Sent: Saturday, May 07, 2005 1:07 PM > To: MJG; perl-win32-gui-users@lists.sourceforge.net > Subject: Re: [perl-win32-gui-users] Simple Text > > To add plain text, you can use a label: > > $W->AddLabel( > -name => "mylabel1", > -left => 10, > -top => 150, > -width=> 100, > -height => 22, > -text => "Some Text Here" > ); > > > --- MJG <[EMAIL PROTECTED]> wrote: > > I have a simple window I've created. Usually, I > > just do windows with > > buttons, but I have a need for text with the > window. > > I have not found > > any examples of how to do this. Can someone > provide > > an example within > > my example of how to just add text to the main > > portion of the window? > > Thank you in advance > > > > > > Use Win32::GUI; > > use Win32 (); > > > > &Win32_GUI(); > > > > quit(0); > > > > sub Win32_GUI > > { > > > > my $I = new Win32::GUI::Icon('icon.ICO'); > > my $C = new Win32::GUI::Bitmap("./harrow.cur", 2); > > > > my $F = new Win32::GUI::Font( > > -name => "Comic Sans MS", > > -size => 10, > > -bold => 0, > > -underline=>0, > > ); > > > > # Register a BUTTON class with cursor > > my $BC = new Win32::GUI::Class( > > -name => 'Class_Button', > > -extends => 'BUTTON', > > -widget => 'Button', > > -cursor => $C, > > ); > > > > my $WC = new Win32::GUI::Class( > > -name => '_Button', > > -cursor => $C, > > -icon => $I, > > -color => 2, > > ); > > > > my $W = new Win32::GUI::Window( > > -title => "Uptime Monitor", > > -pos=> [100, 100], > > -size => [400, 400], > > -left => 300, > > -top=> 100, > > -width => 300, > > -height => 600, > > -name => "Main", > > -class => $WC, > > -topmost=> 1, > > -font => $F, > > -sysmenu=> 0, > > -resizable =>0, > > ); > > > > $W->AddButton( > >-text=> "Server List", > >-name=> "GroupBox_1", > >-left=> 2, > >-top => 40, > >-width => 290, > >-height => 530, > >-style => WS_CHILD | WS_VISIBLE | 7, # > GroupBox > > ); > > > > $W->AddButton( > > -name=> "Update", > > -left=> 150, > > -top => 5, > > -text=> "Update", > > -tabstop => 1, > > -class => $BC, > > #-icon => $I, > > ); > > > > $W->AddButton( > > -name=> "Close", > > -left=> 50, > > -top => 5, > > -text=> "Exit", > > -tabstop => 1, > > -class => $BC, > > #-icon => $I, > > ); > > > > #
Re: [perl-win32-gui-users] AxWindow Application Error
Interestingly, this code does not produce the error: use Win32::OLE; my $view = Win32::OLE->new("MiDocViewer.MiDocView") or die Win32::OLE::LastError(); It seems to be something relating to how AxWindow releases the control. Unfortunately, I have no idea how to debug that sort of thing. I did send an email to Laurent and also to two people who are listed in the Win32::OLE docs. If any of them reply to me with a solution, I will forward it to the list. -Ariel --- Jez White <[EMAIL PROTECTED]> wrote: > > > Thanks for the reply. I tried undefing the > window, > > ax-control and ole-control in various orders. All > of > > them still generated the error. I tried stepping > > through the script to see which undef was causing > the > > error, but it seems to be caused by something > under > > the hood that happens after all of that. > > Humm. Not to sure what to suggest now. > > > This error occurs on both my home computer and my > work > > computer, which are basically the same > configuration. > > > > FYI, this control will let you view/ocr/search > .tif > > and .mdi files. It just didn't do anything > because > > we're not asking it to. If you'd like to see it > in > > action, add this after the control is set up: > > > $v = $Control->GetOLE(); > > $v->{FileName} = 'test.TIF'; > > OK - adding the lines above, caused the script to > crash exactly as you > describe: > > Call stack: > 003E2683 OLE.dll:003E2683 CreatePerlObject > 003E6172 OLE.dll:003E6172 SetSVFromVariant > 0183B7A4 > > So - this could be an Win32::OLE problem - it might > be worth chasing it up > with a list/group that work with Win32::OLE. > > It might also be worth dropping a mail to Laurent > (the author of AxWindow) > to see if he can point you in any direction. > > > there's a decent description of the object model > here: > > > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mspauto/html/welcomemodi_hv01135783.asp > > Cheers, > > jez. > >
Re: [perl-win32-gui-users] Button and RichEdit issues
I had the same issue today with the richedit crashing. I found a post somewhere that said to call the richedit's DESTROY method before terminating. That worked for me. My code looks like this: sub Window_Terminate { $re->DESTROY; -1;} -Ariel --- [EMAIL PROTECTED] wrote: > Thank you everyone for the replies to my Right Click > problems, the issue > is now solved. However, I am having a couple more > issues that I can not > figure out how to get around. > > The first issue is a known one, and it concerns a > crash with RichEdit on > 1.0 when exiting the application. I have created > Global vars for the > RichEdit controls, but I still get a crash on exit, > so I'm not sure what > i'm doing wrong. > > The next issue concerns a couple buttons that I have > created and when I go > to click on them the program just hangs. I tried > adding a BusyTimer to > make sure that the program was hanging and the > BusyTimer stopped spewing > out information, so I know it hung. > > Anyway, I have included some code below in hopes > that someone can help me > fix these issues. Please let me know if you need > any more information and > I will gladly include it. > > Thanks. > > Len. > > --[ Begin Code > ]--- > > use strict; > > use Win32::GUI; > use Win32::GUI::TabFrame; > > my $mainwindow; > > my $richedit_1; > my $richedit_2; > > create_mainwindow(); > > $mainwindow -> Show; > > Win32::GUI::Dialog(); > > sub create_mainwindow { > my $windowheight = 400; > my $windowwidth = 700; > my $windowmenu; > > $windowmenu = Win32::GUI::MakeMenu ( > "Item &1" >=> "", > " > SubItem &1" >=> > "Item1SubItem1", > " > SubItem &2" >=> > "Item1SubItem2", > " > SubItem &3" >=> > "Item1SubItem3", > " > -" >=> 0, > " > E&xit" >=> "AppExit", > "Item &2" >=> "", > " > SubItem &1" >=> > "Item2SubItem1", > ); > > $mainwindow = Win32::GUI::Window -> new ( > -name => "Main", > -width => $windowwidth, > -height => $windowheight, > -title => "Main Window", > -menu => $windowmenu, > ); > > $mainwindow -> AddStatusBar ( > -name => "StatusBar" > ); > > $mainwindow -> AddTreeView ( > -text => "", > -name => "TreeView", > -left => -1, > -top=> -1, > -rootlines => 1, > -buttons=> 1, > ); > > $mainwindow -> AddTabFrame ( > -name => "TabFrame", > -panel => "TabPage", > -tabstop=> 1, > ); > > $mainwindow -> TabFrame -> InsertItem ( > -text => "Tab1", > -border => 1, > ); > > $mainwindow -> TabFrame -> InsertItem ( > -text => "Tab2", > -border => 1, > ); > > $mainwindow -> TabFrame -> InsertItem ( > -text => "Tab3", > -border => 1, > ); > > $mainwindow -> TabFrame -> InsertItem ( > -text => "Tab4", > -border => 1, > ); > > $richedit_1 = $mainwindow -> TabFrame -> > TabPage0 -> AddRichEdit ( > -name => "RichEdit1", > -multiline => 1, > -vscroll=> 1, > -hscroll=> 1, > -readonly => 1, > ); > > $richedit_2 = $mainwindow -> TabFrame -> > TabPage1 -> AddRichEdit ( > -name => "RichEdit2", > -multiline => 1, > -vscroll=> 1, > -readonly => 1, > ); > > $mainwindow -> TabFrame -> TabPage2 -> > AddListView ( > -name => "ListView1", > -style => WS_CHILD | > WS_VISIBLE | WS_VSCROLL | 1, > -fullrowselect => 1, > ); > > $mainwindow -> TabFrame -> TabPage2 -> > ListView1 -> InsertColumn ( > -index => 0, > -width => 220, > -text => "Column 1", > ); > > $mainwindow -> TabFrame -> TabPage2 -> > ListView1 -> InsertColumn ( > -index => 1, >
Re: [perl-win32-gui-users] Mixing OEM and NEM events [Was: working/not working timer]
While I'm an avid user fo Win32::GUI, I don't know much about the internals... That being said, it does seem more intuitive to be able to assign callbacks to specific timers (as opposed to setting up a switch type dispatcher based on the timer name.) Basically, it would be like having an -onclick type property for the timer... -Ariel --- Robert May <[EMAIL PROTECTED]> wrote: > Ñåðãåé ×åðíèåíêî wrote: > [ snipped timer-related stuff ] > > And does it mean that OEM > > and NEM can not be mixed? > > By default a window/control uses the Original/Old > Event Model (OEM), > where the sub that is called is the -name of the > window/control followed > by '_' followed by the event name itself. (So for a > control with -name > => 'ABC', the click event sub is ABC_Click. This > sub must be located in > package main (the default package). > > As soon as any New Event Model (NEM) option is given > to the constructor, > Win32::GUI turns off all OEM subroutine calls. > Using NEM allows us to > use any sub name we want, from any package. We can > event use anonymous > subs. > > If you really want to have both OEM and NEM > callbacks existing at the > same time, then you can pass -eventmodel => 'both' > to the > window/control's constructor (other allowed values > are 'byname' to force > OEM, and 'byref' to force NEM). If you have both > event models enabled, > then currently the NEM sub gets called first (but > don't rely on this > behaviour) > > Personally I find it very confusing having both > enabled, and I would > consider it 'best practice' to use one or the other. > The NEM is far > more powerful (and essential if you want to put > different bits of your > UI code into different packages), but I can see how > anyone coming from > VB would find the OEM more understandable. > > Hope this s useful. > > Rob. > > > --- > SF.Net email is Sponsored by the Better Software > Conference & EXPO > September 19-22, 2005 * San Francisco, CA * > Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects > & Teams * Testing & QA > Security * Process Improvement & Measurement * > http://www.sqe.com/bsce5sf > ___ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >
[perl-win32-gui-users] Listview subitem colors (and related issues)
I am working on a ListView subclass that will ease many (of my) common tasks. I've posted a more primitive version of this to this list before. I've been playing with the item coloring code that Rob posted a little while ago. I've been poking around msdn, trying to extract the subitem from the message (and handle it's custom redraw), but so far have failed miserably. My failure is mainly due to my not understanding what's going on with all of the hooking and packing and unpacking. If anyone is able to post some code that reveals the subitem, that would be extremely helpful. If that person has a little extra time on their hands, I'd very much like to hear about how one goes about translating the structs from the msdn site and where you found the values of the constants. FYI, my LV subclass will basically: 1. assign (or use predefined) ids to rows 2. be able to load data from a db, i.e.: $listview->populate_from_query($dbh, $sql, $primary_key_field); 3. provide custom sorting by column 4. hopefully, handle colors (fonts?) 5. a few other handy little functions i'll post a link to the code when it is ready... -ariel
RE: [perl-win32-gui-users] Centering Win32::GUI::GetOpenFileName Dialog Box
I actually have a very similar question to Rob's, though I'm pretty sure that it warrants the same response. I'm writing an app to automate some menial tasks for some photographer friends. Since the app only opens images, I have set the filter for GetOpenFileName accordingly. It would be very nice to be able to have that dialog default to the thumbnail view. Does anyone know if this sort of thing is possible? I found this: http://msdn.microsoft.com/msdnmag/issues/04/03/CQA/ though, I'm not sure that it's relevant to the Win32::GUI way of doing things and probably involves some of that magical hooking that I occasionally see on here... -ariel --- "Brian H. Oak" <[EMAIL PROTECTED]> wrote: > Rob, > > I thought I would hang back and let a real guru > answer your question, but no real gurus seem to be > stepping up to the plate so here I go: > > Win32::GUI::GetOpenFileName is a hook into a Windows > system resource, it is not a Win32::GUI object over > which you have control. You (the programmer) can't > size it or position it at all. The system will > position it every time and, to the best of my > knowledge, the system places it exactly where the > user left it the last time they called it up -- with > any program, not just your Win32::GUI application. > > Once again, I am not a guru... I've actually only > been using Win32::GUI for a few weeks, although I've > been programming Perl on Win32 for years now. If > someone more knowledgeable than I wants to > contradict anything I've said here, I hope they will > feel free to do so. YMMV, 'nuff said. > > Hope this helps, > > -Brian > > > -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > On Behalf Of Rob > Sent: Thursday, September 22, 2005 21:23 > To: perl-win32-gui-users@lists.sourceforge.net > Subject: [perl-win32-gui-users] Centering > Win32::GUI::GetOpenFileName Dialog Box > > Does anyone know how I could center my > Win32::GUI::GetOpenFileName dialog > box in my window say $window_main? > > $directory_and_file_name = > Win32::GUI::GetOpenFileName > ( > -owner => $window_main , > -size => [ 400, 400 ] , > -directory => $directory , > -file => $file , > -title => 'Open' , > -filter=> [ 'Text files' , '*.txt' , 'All > files' , '*.*' ] , > ) ; > > Rob > HµŠ²²uj¢z¢žjžÃâ¦zЦ®âÅ ÂymµvŠò¾¢zß=ââ¦Â¶k¶²q®zzÅ â ®ŸPzjž²®ŸPzвq®zÃm¶âº?þX¦Ã(º·~Å Ã zwÂþX¦ÃåŠÃbÂú?¥êåÃ)ֈ > ¢ºÃ« > > > > --- > SF.Net email is sponsored by: > Tame your development challenges with Apache's > Geronimo App Server. > Download it for free - -and be entered to win a 42" > plasma tv or your very > own Sony(tm)PSP. Click here to play: > http://sourceforge.net/geronimo.php > ___ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >
[perl-win32-gui-users] drag/drop treeview questions
I have two questions. I'm writing an app that helps people to assign files to categories and lets them order the files within those categories. I have set my app up to use a two-level treeview which shows the categories and the files within, like so: - Category 1 file1 file2 - Category 2 file3 file8 file50 Here are my questions: 1. Can I enable the user to re-order the files withing the categories by dragging them to a new location? (i.e. drag file50 so that it is between file3 and file8.) 2. Can I enable the user to drag an external file to a specific place in the treeview? At the very least, I'd like to allow the user to drag files into a specific category. If anyone has any thoughts on this, I would appreciate your input... -Ariel
Re: [perl-win32-gui-users] Re: Centering Win32::GUI::GetOpenFileName Dialog Box
Rob, Thanks for that email, which was very helpful. It seems like the callback method is the way to go with this one, at least for me. I just spent a long time trying to get the handle for the listview control in the file open dialog. Here are some things that I figured out while failing to change the view setting for that listview. 1. Win32::GUI::FindWindow only finds top level windows (which is what it says in the docs.) I had to install Win32::GuiTest to get the handle of the listview control in the Open dialog. 2. The event in that example is fired when the file open dialog opens, however GuiTest's FindWindowLike function doesn't seem to be finding the control at that point. When I click on the dialog, the event fires again and it finds the control. The SendMessage line that I used is the same as in the example, since I don't really get that part. Here is how I modified Rob's example: # at the top use Win32::GuiTest qw(FindWindowLike); #in the event handler my @lv_hwnd = FindWindowLike($hwndInsertAfter,undef,'SysListView32'); print "HWND: $lv_hwnd[0]\n"; Win32::GUI::SendMessage($lv_hwnd[0], WM_COMMAND, 0x702C, 0); anyone have thoughts on this? -ariel --- Robert May <[EMAIL PROTECTED]> wrote: > Rob wrote: > > Does anyone know how I could center my > > Win32::GUI::GetOpenFileName dialog > > box in my window > > Ariel Serbin wrote: > > It would be very nice to > > be able to have that dialog default to the > thumbnail > > view. > > > Brian wrote: > > Win32::GUI::GetOpenFileName is a hook into a > Windows > > system resource, it is not a Win32::GUI object > over > > which you have control. You (the programmer) > can't > > size it or position it at all. The system will > > position it every time and, to the best of my > > knowledge, the system places it exactly where the > > user left it the last time they called it up -- > with > > any program, not just your Win32::GUI > application. > > Close. GetOpenFileName() is a function that > displays a system dialog > (from comdlg32.dll). Other 'common' dialogs are > font choosers, color > pickers etc. - you know, all those 'standard' > dialogs. > > These dialogs are just windows, and if you can get > the windows handle to > them, you can manipulate them just like any other > window (OK, this is a > big generalisation, but is in, er, general, true). > > All the common dialogs also (at the Win32 api level) > provide > hooks(callbacks) just for this purpose (for example > see the > GetOpenFileName() documentation at > http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxfunctions/getopenfilename.asp > and look for the description of OFNHookProc). These > callbacks are not > supported by Win32::GUI (but could be), and would be > the 'correct' way > to do what you are trying to do. However, as with > most perl and Win32 > api things, TIMTOWTDI (There Is More Than One Way To > Do It). > > For example, in the code below I take advantage of > the fact that when > the dialog is shown, it deactivates the main window; > as a result of > this the main window is sent a WM_WINDOWPOSCHANGE > message (as it's > z-order changes), and one of the parameters passed > in this message is > the handle to the window that is becoming active: > the handle to the > dialog - we can then use that to get the size, and > set the position of > the dialog. There is one problem that I haven't > had the time to solve, > and that's how to modify the logic, so that the > dialog doesn't get > forced to be centered on the main window regardless > - try dragging it, > and see how it 'snaps' back with this code. > > > > > http://msdn.microsoft.com/msdnmag/issues/04/03/CQA/ > > I haven't tested this, but replacing the moving code > below with code to > find the handle to the lsitview (using > FindWindow()?), and then using a > SendMessage call, using the values from figure 5 in > the link above > should set the view to what you want. > > Hope this helps. Please post back if you > successfully solve any of the > remaining problems. > > Regards, > Rob. > > #!perl -w > use strict; > use warnings; > > use Win32::GUI; > > sub WM_WINDOWPOSCHANGING() {70} > sub SWP_NOACTIVATE() {16} > > my $mw = Win32::GUI::Window->new( > -title => "GetOpenFileName Test", > -pos => [100,100], > -size => [400,300]
Re: [perl-win32-gui-users] Attaching to a window created by some other application
My opinion is that GuiTest is a weird mix of functions that are not really specific to testing. For that reason, it seems that the meat of those functions should reside in more appropriate modules (like Win32::GUI) and GuiTest (or any module specific to testing) should call those functions. That being said, FindWindowLike in GuiTest can find childwindows, unlike the Win32::GUI counterpart. I do think that Win32::GUI could benefit from assimilating some parts of GuiTest. just my 2 cents... --- Jeremy White <[EMAIL PROTECTED]> wrote: > > >Or just merge their functionality, developer base, > and the technical > >prowess of the developers, to make both better, > less redundant, and more > >interoperative? > > Lots of interesting idea's. I've just had a quick > look at guitest.xs and > there does seem to be some over lap in functions > (such as > SetFocus,SendMessage, SetActiveWindow and many > others [there is the issue > about the AttachWin function that each of these > call]) so it would be > possible at the very least to have some sort of > common file that both > programmes can build from. > > Deeper integration, combining the strengths of both > tools and eliminating > some of the weaknesses would be a more work (I > think) - but conceptually, I > think it's a great idea. > > Cheers, > > jez. > > > > > --- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, > downloads, discussions, > and more. > http://solutions.newsforge.com/ibmarch.tmpl > ___ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ >
Re: [perl-win32-gui-users] Re: Centering Win32::GUI::GetOpenFileName Dialog Box
GUI users, i'd appreciate it if someone more knowlegable could please have a look at the following code. i adapted it from the example that rob sent, but i keep getting a usage error on the hook line (in open_thumbnails), which says that it needs to be passed (handle, msg, codref). you'll see that i have a commented hook command that passes the $win object. when i run that line, then i get a usage error that says only to pass the msg and the coderef. does anyone have any idea what's going on here? thanks, -ariel. use Win32::GUI; use Win32::API; use Win32::GUI::Loft::Design; sub WM_WINDOWPOSCHANGING() {70} sub WM_ENTERIDLE() {289} sub SWP_NOACTIVATE() {16} sub MSGF_DIALOGBOX() {0} my $win = Win32::GUI::Window->new( -name => 'win', -text => 'test', -left => 10, -top => 10, -width => 250, -height => 250, ); $win->AddButton( -name => 'button', -text => 'button', -left => 10, -top => 10, -onClick => \&open_thumbnails, ); $win->Center; $win->Show; Win32::GUI::Dialog(); sub open_thumbnails { #$win->Hook($win, WM_ENTERIDLE, \&Idle($win)); $win->Hook(WM_ENTERIDLE, \&Idle($win)); my $files = Win32::GUI::GetOpenFileName( -owner => $win, ); return $files; } sub Idle { $win->UnHook(WM_ENTERIDLE); # ensure this hook doesn't get called again my ($object, $wParam, $lParam, $type, $msgcode) = @_; return unless $type == 0; return unless $msgcode == WM_ENTERIDLE; # check the message came from a dialog box return unless $wParam == MSGF_DIALOGBOX; # check that the dialog window handle in $lParam is for the Open File dialog: # here I test the window caption, but you might need something more robust: return unless Win32::GUI::Text($lParam) eq "Open"; # modify the Dialog (center it on the main window): my $sx = $win->Left() + ($win->Width() - Win32::GUI::Width($lParam))/2; my $sy = $win->Top() + ($win->Height() - Win32::GUI::Height($lParam))/2; Win32::GUI::Move($lParam, $sx, $sy); # Walk the child windows of the open dialog to find the SHELLDLL_DefView window: my $phwnd = $lParam; my $mode = GW_CHILD; # Initially find the first child of the dialog window while(my $chwnd = Win32::GUI::GetWindow($phwnd, $mode)) { if (Win32::GUI::GetClassName($chwnd) eq "SHELLDLL_DefView") { # set the view: # from http://msdn.microsoft.com/msdnmag/issues/04/03/CQA/ # 0x7029Icons # 0x702BList # 0x702CDetails # 0x702DThumbnails # 0x702ETiles Win32::GUI::SendMessage($chwnd, WM_COMMAND, 0x702D, 0); last; # we found it } $mode = GW_HWNDNEXT; # and walk the rest of the dialog's children $phwnd = $chwnd; } return; } 1;
Re: [perl-win32-gui-users] Re: Centering Win32::GUI::GetOpenFileName Dialog Box
Thanks for the reply, but I'm still getting the usage errors with this script, no matter how I call Hook. With the attached file, I tried these 3 ways of calling it: #$win->Hook($win, WM_ENTERIDLE, \&Idle($win)); #$win->Hook(WM_ENTERIDLE, \&Idle($win)); Win32::GUI::Hook($win,WM_ENTERIDLE, \&Idle($win)); The strange thing is that the hook works in the example that Rob sent out (last week, I think). Am I missing something here? thanks, -ariel --- Jeremy White <[EMAIL PROTECTED]> wrote: > > >command that passes the $win object. when i run > that > >line, then i get a usage error that says only to > pass > >the msg and the coderef. does anyone have any idea > >what's going on here? > > > #$win->Hook($win, WM_ENTERIDLE, \&Idle($win)); > > Try: > > $win->Hook(WM_ENTERIDLE, \&Idle($win)); > > When called as a method the first paramater is the > window, ie: > > Win32::GUI::Hook($win,WM_ENTERIDLE, \&Idle($win)); > > As you are passing a win32::GUI object, Hook will > get the handle from the > object. > > Cheers, > > jez. > > > use Win32::GUI; use Win32::API; use Win32::GUI::Loft::Design; sub WM_WINDOWPOSCHANGING() {70} sub WM_ENTERIDLE() {289} sub SWP_NOACTIVATE() {16} sub MSGF_DIALOGBOX() {0} my $win = Win32::GUI::Window->new( -name => 'win', -text => 'test', -left => 10, -top => 10, -width => 250, -height => 250, ); $win->AddButton( -name => 'button', -text => 'button', -left => 10, -top => 10, -onClick => \&open_thumbnails, ); $win->Center; $win->Show; Win32::GUI::Dialog(); sub open_thumbnails { #$win->Hook($win, WM_ENTERIDLE, \&Idle($win)); #$win->Hook(WM_ENTERIDLE, \&Idle($win)); Win32::GUI::Hook($win,WM_ENTERIDLE, \&Idle($win)); my $files = Win32::GUI::GetOpenFileName( -owner => $win, ); return $files; } sub Idle { $win->UnHook(WM_ENTERIDLE); # ensure this hook doesn't get called again my ($object, $wParam, $lParam, $type, $msgcode) = @_; return unless $type == 0; return unless $msgcode == WM_ENTERIDLE; # check the message came from a dialog box return unless $wParam == MSGF_DIALOGBOX; # check that the dialog window handle in $lParam is for the Open File dialog: # here I test the window caption, but you might needsomething more robust: return unless Win32::GUI::Text($lParam) eq "Open"; # modify the Dialog (center it on the main window): my $sx = $win->Left() + ($win->Width() - Win32::GUI::Width($lParam))/2; my $sy = $win->Top() + ($win->Height() - Win32::GUI::Height($lParam))/2; Win32::GUI::Move($lParam, $sx, $sy); # Walk the child windows of the open dialog to find the SHELLDLL_DefView window: my $phwnd = $lParam; my $mode = GW_CHILD; # Initially find the first child of the dialog window while(my $chwnd = Win32::GUI::GetWindow($phwnd, $mode)) { if (Win32::GUI::GetClassName($chwnd) eq "SHELLDLL_DefView") { # set the view: # from http://msdn.microsoft.com/msdnmag/issues/04/03/CQA/ # 0x7029Icons # 0x702BList # 0x702CDetails # 0x702DThumbnails # 0x702ETiles Win32::GUI::SendMessage($chwnd, WM_COMMAND, 0x702D, 0); last; # we found it } $mode = GW_HWNDNEXT; # and walk the rest of the dialog's children $phwnd = $chwnd; } return; } 1;
[perl-win32-gui-users] GUI Programming Job
GUI Users, The law firm that I work for is expanding its tech department (i.e. me and the other guy) and has several large programming projects on the horizon. The most notable of these projects is a new case management system, which will be a large, complicated Windows program (or possibly a suite of programs) with a nice, friendly UI. I have written a number of smaller tools using Win32::GUI and would very much like to use it to build this next project. In short, I'm looking for a programmer that is capable of helping with these kinds of tasks. The ideal person would be haunting this list, which is why I wanted to post this here before I put it up on the job sites. If you're near Philadelphia and would like to get paid to work on/with Win32::GUI, please check out the post below. -ariel Full Time/Permanent On-Site Position: Senior Perl Developer The Philadelphia office of an internationally recognized premier law firm is seeking a Senior Level Perl Programmer with SQL database, Windows GUI, and Web development experience. Expert level Perl skills are a must. Fluency in SQL/DBI is required as well as a solid grasp of database design, maintenance and optimization. Experience with Windows, OOP, CGI, LWP and GUI programming is also necessary. VB/C++ skills are a plus. Strong communications skills, a professional demeanor, clean coding technique, and the generation of clear code documentation are mandatory for this position. Willingness to also assist with network and help desk issues. A Comprehensive background check will be performed. Please submit your resume including: 3 professional references Salary History Salary Requirement
[perl-win32-gui-users] Enhanced Listview Module
Hi all, I've (mostly) completed a listview subclass that helps simplify dealing with listview data. It's primarily designed for data that is keyed by ID. The main tasks of the subclass are importing data, handling sorting, and retrieving the IDs/data of the selected items. See the attached example for more details. I haven't completed the documentation, though most functions should be self-explanatory. This is the first time I've attempted to prepare a module for public distribution, so I've got a little homework to do in that respect. For those of you interested in this sort of thing, I'd appreciate your input on these issues: 1. Naming, both for the module and for the methods. 2. Error handling. Right now, it's just carping on errors. 3. Overriding regular ListView methods. Since the underlying data relies on having IDs, I should probably replace/disable the regular ListView->Add... 4. Any other opinions... EZ_LV_tester.pl Description: 1059067997-EZ_LV_tester.pl package Win32::GUI::EZ::ListView; use strict; use Win32::GUI; use Carp; our @ISA = ('Win32::GUI::ListView'); sub new { my ($package,%options) = @_; my $self = $package->SUPER::new($package,%options); bless $self, $package; $self->{_DISPLAY_COLUMNS} = []; $self->{_IDS} = []; $self->{_COLUMNS} = []; $self->{_DEFAULT_WIDTH} = $options{-default_width} || -2; $self->{_DATA} = {}; $self->{-can_sort} ||= 1; # if this listview can be sorted $self->{-sort_asc} ||= 1; $self->{-sort_col} = -1; # initially, no columns have been sorted # remap column click event $self->SetEvent("ColumnClick", sub {sort_lv(@_)}); return $self; } sub AUTOLOAD { my $func = our $AUTOLOAD; my $self = $_[0]; $func =~ s/.*:://; my $col = $self->get_column($func); unless ($col) { carp("can't find column '$func'"); return; } return $col; } sub get_selected { my $self = shift; my @sel = $self->SelectedItems(); return undef unless defined $sel[0]; print $self->SelectedItems() . "\n"; return @{$self->[EMAIL PROTECTED]; } sub get_data { my $self = shift; my @data; my @sel = $self->get_selected(); return undef unless defined $sel[0]; for (@sel) { push @data, $self->{_DATA}->{$_}; } return @data; } sub display_columns { my $self = shift; my @columns = @_; my @col_objects = (); my $index = 0; # clear columns $self->Clear(); $self->hide_all_columns; # add columns foreach my $col_name (@columns) { my $col = $self->get_column($col_name) or croak("Can't display column: $col_name"); push @col_objects, $col; # keep track of where the column's position in the list $col->{-visible} = 1; $col->{-index} = $index; # copy the attributes from the column object my @opts = grep { m/^-/ } keys %$col; my %options; foreach my $opt (@opts) { $options{$opt} = $col->{$opt}; } # just use the column object as the options hash $self->InsertColumn(%options); $index++; } # show data foreach my $id (@{$self->{_IDS}}) { my @toinsert = (); foreach my $cl (@col_objects) { push @toinsert, $self->{_DATA}->{$id}->{$cl->{-name}}; } $self->InsertItem(-text => [EMAIL PROTECTED]); } # size columns if needed if ($self->{set_width}) { my $i = 0; foreach my $cl (@col_objects) { $self->ColumnWidth($i,$cl->{-width}); $i++; } $self->{set_width} = 0; } @{$self->{_DISPLAY_COLUMNS}} = @columns; } sub hide_all_columns { my $self = shift; # remove column from listview # this does NOT destroy the EZ::ListView::Column object for my $col ( @{$self->{_COLUMNS} } ) { $col->hide; } } sub get_column { my ($self, $name) = @_; return (grep {($_->{-name} eq $name) || ($_->{-text} eq $name)} @{$self->{_COLUMNS}})[0]; } sub redraw { my $self = shift; $self->display_columns(@{$self->{_DISPLAY_COLUMNS}}); return 1; } sub import_hashref { # this function imports a hashref of hashrefs in the form returned by DBI's fetchall_hashref my ($self, $hashref) = @_; carp("can't import_hashref without a hashref") unless $hashref; ## ## first we need to create the columns if we don't have them already ## # these will be the IDs of the hash items my @keys = keys %{$hashref}; # these will be the field/column names of the individual entries my @column_names = keys %{ $hashref->{$keys[0]} }; foreach my $column (@column_names) { # call autoload to see if we already have that column unless ($self->get_column($column)) { $self->add_column(-name => $column); } } # create a handle to the data $self->{_DATA} = $hashref; $self->{_IDS} = [EMAIL PROTECTED]; # tell display to set width $self->{set_width} = 1; } sub sql_populate { my ($self, $dbh, $sql, $key) = @_; my $crs = $dbh->prepare($sql) or carp($dbh->errstr)
Re: [perl-win32-gui-users] DIBitmap odd resize behaviour with TIFFs?
hi, i cleaned up a DIBitmap app that i had to try showing how to "fit to screen". i wrote the app that i stole this from quite a while ago and i haven't looked into why the 'rotate' doesn't work. the "fitting" business seems to work, though... you can check it out at http://www.barrack.com/dibdemo.zip which will be there for a few days... -ariel --- Scott Spearman <[EMAIL PROTECTED]> wrote: > Hi. I'm working on a document scanning and archive > system. Documents come off the scanner as 1-bit > (black and white) 600 DPI TIFF files. Until > recently I was converting these to JPG. Then I > display the image to the user, to verify they didn't > include extra space or chop anything off, then the > user can upload it to the server. > > Previously I had a routine that would take the tiff > file, convert it to a JPG, then open it in a > DIBitmap, rescale it there to fit the screen > (leaving the original file intact) and then convert > to bitmap to display it. Now we'd like to keep the > image in TIFF format all the way to the server, for > quality reasons. However, when I try open and > resize the TIFF with DIBitmap I get a solid black > box where the image should be. I'm sure I'm doing > something wrong, but I'm not sure what. I'll > include the relevant code below. Please ignore the > part with Image::Magic doing the JPG conversion... I > left it in so you can see what I WAS doing, and what > I am now doing... > > I'm wondering if I am doing something wrong, or am > missing a piece of software. But the JPG resize was > working perfectly. I'd appreciate any insight into > this very much. > > # Log the event and convert to JPG > log_event("Verifying the Image"); > $image = Image::Magick->new; > $x = $image->Read("C:\\tmp.tiff"); > log_event("Return from ImageMagick->Read: $x"); > $p = $image->Append(stack=>true); > log_event("Return from ImageMagick->Append: $p"); > $imgmgkres = $scanquality."X".$scanquality; > $p->Set(density=>"$imgmgkres"); > $p->Set(quality=>$jpgquality); > $x = $p->Write("C:\\tmp.JPG"); > log_event("Return from ImageMagick->Write: > $x\tQuality: $jpgquality"); > > undef $image; > undef $p; > > # Open the file in a DIBitmap for display > $dib = newFromFile > Win32::GUI::DIBitmap('C:\\tmp.tiff'); > $heightimg = $dib->GetHeight(); > $widthimg = $dib->GetWidth(); > $wmax = 750; $hmax=700; > $hratio = $heightimg/$hmax; > $wratio = $widthimg/$wmax; > > # If image needs to be resized, resize it. > if( $hratio> $wratio && $hratio > 1) > { $dispdib = $dib -> Rescale($widthimg/$hratio, > $hmax); > $imgwid=$widthimg/$hratio; $imglen=$hmax;} > elsif( $wratio>=$hratio && $wratio > 1) > { $dispdib = $dib -> Rescale($wmax, > $heightimg/$wratio); > $imgwid=$wmax, $imglen=$heightimg/$wratio;} > else {$dispdib = $dib; $imgwid=$widthimg; > $imglen=$heightimg;} > > $hbitmap = $dispdib->ConvertToBitmap(); > undef $dib; > undef $dispdib; > > # Set the label and move it to center it in the > space allocated. > $imglbl->SetImage($hbitmap); > $imglbl->Move(($wmax-$imgwid)/2, > ($hmax-$imglen)/2); > > > > Scott Spearman > Programmer > Pikeville Medical Center > Phone: 606-218-4660 > Pager: 606-437-8542 > > Note: The information transmitted is intended only > for the person or entity to which it is addressed > and may contain confidential and/or privileged > material. Any review, retransmission, dissemination > or other use of, or taking any action in reliance > upon, this information by persons or entities other > than the intended recipient is prohibited. If you > received this in error, please contact the sender > and delete this material from any computer.
RE: [perl-win32-gui-users] Button bitmap and icons
there are programs that can extract the icons from the system dlls. check out this link: http://www.vbaccelerator.com/home/VB/Utilities/Icon_Extractor/article.asp and this link: http://www.vbaccelerator.com/home/VB/Utilities/Bitmap_Extractor/article.asp on a related note, i have always thought that it would be nice to have some built in functions to retrieve common icons (i.e. Save, Open, etc...) -ariel --- [EMAIL PROTECTED] wrote: > I figured out how to get the image when referencing > an actual '.ico' file, > just specify the path of the file in new > Win32::GUI::Icon. But how do you > get it from a dll or exe file? > > Joe > > > > Joseph Vieira > CIO IT Support > FUJITSU CONSULTING > Phone:(732) 549-4100 ext (8657) > Email: [EMAIL PROTECTED] > > > > > "Plum, Jason" <[EMAIL PROTECTED]> > Sent by: > [EMAIL PROTECTED] > 12/29/2005 04:29 PM > > To > > cc > > Subject > RE: [perl-win32-gui-users] Button bitmap and icons > > > > > > > > Give me a bit here and IâÂÂll whip up a full demo > for you, IâÂÂve got a > program at home thatâÂÂs running with like, 50 > icons. > > Jason P > > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > On Behalf Of > [EMAIL PROTECTED] > Sent: Thursday, December 29, 2005 4:22 PM > To: perl-win32-gui-users@lists.sourceforge.net > Subject: RE: [perl-win32-gui-users] Button bitmap > and icons > > > Jason, > > I got the same result > > Joe > > > > "Plum, Jason" <[EMAIL PROTECTED]> > Sent by: > [EMAIL PROTECTED] > 12/29/2005 03:34 PM > > > To > > cc > > Subject > RE: [perl-win32-gui-users] Button bitmap and icons > > > > > > > > > > > My $ico = new Win32::GUI::Icon( [EMAIL PROTECTED]); > then in the button, -icon => $ico > > Jason P > > > > > > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > On Behalf Of > [EMAIL PROTECTED] > Sent: Thursday, December 29, 2005 3:05 PM > To: perl-win32-gui-users@lists.sourceforge.net > Subject: [perl-win32-gui-users] Button bitmap and > icons > > > Hello, > > I'm a little confused about how to add a bitmap to a > button or create one > as an icon. I want to create a button with a > picture of a printer on it, > like you see in a word processing program. Also a > button with internet > explorer icon on it, or any other program's icon. I > can't find an example > on the web site on how to do this. > > I tried this out but the button was blank, you > couldn't see the word > "TEST". So I must have done something to block the > text, but the image > did not show up either. > > $MainWin->AddButton( > -name => "Button1", > -text => "TEST", > -bitmap => 1, > -picture => 'bliss.bmp', > -left => 350, > -top=> 10, > ); > > > Windows XP SP2, 5.8.7, GUI 1.02 > > Thanks, > Joe > >