From: Piske, H. <Har...@bo...> - 2001-05-23 20:27:24
|
$_ = Win32::GUI::FindWindow ("Shell_TrayWnd", ""); @_ = Win32::GUI::GetWindowRect ($_); $width = $_[2] - $_[0]; $height = $_[3] - $_[1]; tested on Win2k and Win98. Interestingly, the position of the taskbar is slightly off the screen (-2). Note that the taskbar can be moved to each of the four window edges (eight on dual-screen, which would look like off the desktop), so don't put your program fixed at (0,0). I have mine upright at the left side instead of flat at the bottom. If it takes up less of the vertical extend, which programs use for status bars, tool bars, menu bars and so on. Take web browsers for instance. Web pages are usually longer than the screen height but less wide than the screen width. Have fun, Harald | -----Original Message----- | From: Webmaster CZ [mailto:web...@cy...] | Sent: Wednesday, May 23, 2001 12:51 | To: per...@li... | Subject: [perl-win32-gui-users] Taskbar & perl2exe -gui crash | | | Hi ! | | I have two problems: | | a) | My program start in maximal width & height with this code: | | ---------Code---------------- | $screensize = Win32::GUI::GetDesktopWindow(); | $screensize_width = Win32::GUI::Width($screensize); | $screensize_height = Win32::GUI::Height($screensize); | ---------Code---------------- | | The problem is, that i must subtract the size of the Taskbar... | so how can i read the size (height) of it ???? | | | b) | If i compile my program with perl2exe and "-gui", then the | program crash on exit.... ever: the "exit code" are: | | -----------Code----------- | sub Window_Terminate { | return -1; | } | | sub Exit_Click { | return -1; | } | ------------Code--------- | | Any idea ??? | | | | cu | Thorsten Sommer | | | _______________________________________________ | Perl-Win32-GUI-Users mailing list | Per...@li... | http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users | |
From: Piske, H. <Har...@bo...> - 2001-05-27 03:39:32
|
More general ... hm. What do you mean? All the topmost windows? I think the problem is too varied for a general solution. If you don't know the class names of the windows you want to find the coordinates of, how do you know which ones to choose? Well, you might go and take all the windows that are topmost, but that includes error messages and the task manager and who knows what else, so you might not find any space on the desktop for yourself. Maybe you want to have an ini-file stating the names of windows that may be present and if they are, consider their boundaries. See below for a small loop to display all the classnames. $_ = $Main->GetWindow (GW_HWNDLAST); do { print Win32::GUI::GetClassName ($_), "\n" if Win32::GUI::IsVisible ($_); } while $_ = Win32::GUI::GetWindow ($_, GW_HWNDPREV); I have a demo-script at www.fairymails.com/perl/, alone.pl, which uses a loop like this not to get the names of windows, but simply hide them - including the task bar - to claim 100% of the desktop. -----Original Message----- From: Glenn Linderman [mailto:Gle...@ne...] Sent: Samstag, 26. Mai 2001 13:54 To: per...@li... Subject: Re: [perl-win32-gui-users] Taskbar & perl2exe -gui crash Indeed, this works. I've long wondered about a way to do it, and I've now incorporated this into my (only) Win32::GUI program. I am planning to write some more Win32::GUI programs soon. It seems, though, that this solution isn't completely general. While I don't personally use it anymore, I recall MS Office had an optional taskbar that could be docked similarly to the Windows taskbar. And some laptops have "power management toolbars". etc. Does anyone know of a more general technique for avoiding all the toolbars/taskbars that might nibble away at the edges of the desktop? |
From: Glenn L. <Gle...@ne...> - 2001-05-28 19:37:40
|
By "more general", I was looking for "all toolbars that are docked to the edge of the screen". I'm pretty much a Windows-idiot, although pretty good at programming generic Perl, so I'm still stumbling over the Windows terminology. So how do you tell if a windows is "topmost"? Maybe "all toolbars that are docked to the edge of the screen" is somewhat equivalent to "all topmost windows that abut an edge of the screen and are really long and thin" ??? Maybe "abut an edge" means within "0 to -5 pixels" of the edge ??? Maybe "really long" in that means at least 90% of the dimension of the srceen" ??? I'm not sure how some of those toolbars interact in the corners, to know if 90% is right, or if maybe one should find all the "topmost" windows that "abut an edge" and then iterate several times looking for those that "cover 100% of the remaining space" ??? How do non-perl programs do it? How does "maximize" know how to leave the toolbars visible? Is there a Windows call to figure that out? "Piske, Harald" wrote: > More general ... hm. What do you mean? All the topmost windows? I think the > problem is too varied for a general solution. If you don't know the class > names of the windows you want to find the coordinates of, how do you know > which ones to choose? Well, you might go and take all the windows that are > topmost, but that includes error messages and the task manager and who knows > what else, so you might not find any space on the desktop for yourself. > > Maybe you want to have an ini-file stating the names of windows that may be > present and if they are, consider their boundaries. See below for a small > loop to display all the classnames. > > $_ = $Main->GetWindow (GW_HWNDLAST); > do { > print Win32::GUI::GetClassName ($_), "\n" > if Win32::GUI::IsVisible ($_); > } while $_ = Win32::GUI::GetWindow ($_, GW_HWNDPREV); > > I have a demo-script at www.fairymails.com/perl/, alone.pl, which uses a > loop like this not to get the names of windows, but simply hide them - > including the task bar - to claim 100% of the desktop. > > -----Original Message----- > From: Glenn Linderman [mailto:Gle...@ne...] > Sent: Samstag, 26. Mai 2001 13:54 > To: per...@li... > Subject: Re: [perl-win32-gui-users] Taskbar & perl2exe -gui crash > > Indeed, this works. I've long wondered about a way to do it, and I've now > incorporated this into my (only) Win32::GUI program. I am planning to write > some more Win32::GUI programs soon. It seems, though, that this solution > isn't > completely general. While I don't personally use it anymore, I recall MS > Office > had an optional taskbar that could be docked similarly to the Windows > taskbar. > And some laptops have "power management toolbars". etc. > > Does anyone know of a more general technique for avoiding all the > toolbars/taskbars that might nibble away at the edges of the desktop? > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice. |
From: Piske, H. <Har...@bo...> - 2001-05-28 19:55:14
|
I'm impressed - here's somebody who knows how to translate general ideas into formal terminology. I don't have a solution at hand but with what you say, you should be able to figure it out. I'm not aware of any ready-made windoze function to give you the "effective desktop client area after accounting for taskbars", but that does not mean there is none. I'm not really at home in the win ref manuals. Just one more note: my wife has a toolbar on her computer that is nothing but a small collection of buttons. Looks like it was invented before Win98 came along with it's quick-launch thingy. That is only around 10% of the screen width and just one row of icons high. Have fun, Harald -----Original Message----- From: Glenn Linderman [mailto:Gle...@ne...] Sent: Montag, 28. Mai 2001 12:40 To: per...@li... Subject: Re: [perl-win32-gui-users] Taskbar & perl2exe -gui crash By "more general", I was looking for "all toolbars that are docked to the edge of the screen". I'm pretty much a Windows-idiot, although pretty good at programming generic Perl, so I'm still stumbling over the Windows terminology. So how do you tell if a windows is "topmost"? Maybe "all toolbars that are docked to the edge of the screen" is somewhat equivalent to "all topmost windows that abut an edge of the screen and are really long and thin" ??? Maybe "abut an edge" means within "0 to -5 pixels" of the edge ??? Maybe "really long" in that means at least 90% of the dimension of the srceen" ??? I'm not sure how some of those toolbars interact in the corners, to know if 90% is right, or if maybe one should find all the "topmost" windows that "abut an edge" and then iterate several times looking for those that "cover 100% of the remaining space" ??? How do non-perl programs do it? How does "maximize" know how to leave the toolbars visible? Is there a Windows call to figure that out? "Piske, Harald" wrote: > More general ... hm. What do you mean? All the topmost windows? I think the > problem is too varied for a general solution. If you don't know the class > names of the windows you want to find the coordinates of, how do you know > which ones to choose? Well, you might go and take all the windows that are > topmost, but that includes error messages and the task manager and who knows > what else, so you might not find any space on the desktop for yourself. > > Maybe you want to have an ini-file stating the names of windows that may be > present and if they are, consider their boundaries. See below for a small > loop to display all the classnames. > > $_ = $Main->GetWindow (GW_HWNDLAST); > do { > print Win32::GUI::GetClassName ($_), "\n" > if Win32::GUI::IsVisible ($_); > } while $_ = Win32::GUI::GetWindow ($_, GW_HWNDPREV); > > I have a demo-script at www.fairymails.com/perl/, alone.pl, which uses a > loop like this not to get the names of windows, but simply hide them - > including the task bar - to claim 100% of the desktop. > > -----Original Message----- > From: Glenn Linderman [mailto:Gle...@ne...] > Sent: Samstag, 26. Mai 2001 13:54 > To: per...@li... > Subject: Re: [perl-win32-gui-users] Taskbar & perl2exe -gui crash > > Indeed, this works. I've long wondered about a way to do it, and I've now > incorporated this into my (only) Win32::GUI program. I am planning to write > some more Win32::GUI programs soon. It seems, though, that this solution > isn't > completely general. While I don't personally use it anymore, I recall MS > Office > had an optional taskbar that could be docked similarly to the Windows > taskbar. > And some laptops have "power management toolbars". etc. > > Does anyone know of a more general technique for avoiding all the > toolbars/taskbars that might nibble away at the edges of the desktop? > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice. _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users |
From: Glenn L. <Gle...@ne...> - 2001-05-28 21:27:03
|
"Piske, Harald" wrote: > I'm impressed - here's somebody who knows how to translate general ideas > into formal terminology. Thanks for the attaboy. It was just what I needed to inspire further research... > I don't have a solution at hand but with what you > say, you should be able to figure it out. I'm not aware of any ready-made > windoze function to give you the "effective desktop client area after > accounting for taskbars", but that does not mean there is none. I'm not > really at home in the win ref manuals. I am. Now. Post research :) Research is below for the interested. Next research project is to figure out how to use Win32::API well enough to benefit from the research... > Just one more note: my wife has a toolbar on her computer that is nothing > but a small collection of buttons. Looks like it was invented before Win98 > came along with it's quick-launch thingy. That is only around 10% of the > screen width and just one row of icons high. I've seen some of those. Not too concerned about them, either. Here's the relevant pieces of the results of the research through MSDN: BOOL SystemParametersInfo( UINT uiAction, // system parameter to query or set UINT uiParam, // depends on action to be taken PVOID pvParam, // depends on action to be taken UINT fWinIni // user profile update flag ); when uiAction == SPI_GETWORKAREA Retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars. The pvParam parameter must point to a RECT structure that receives the coordinates of the work area, expressed in virtual screen coordinates. To get the work area of a monitor other than the primary display monitor, call the GetMonitorInfo function. RECT The RECT structure defines the coordinates of the upper-left and lower-right corners of a rectangle. typedef struct _RECT { LONG left; LONG top; LONG right; LONG bottom; } RECT; Members left Specifies the x-coordinate of the upper-left corner of the rectangle. top Specifies the y-coordinate of the upper-left corner of the rectangle. right Specifies the x-coordinate of the lower-right corner of the rectangle. bottom Specifies the y-coordinate of the lower-right corner of the rectangle. Remarks When RECT is passed to the FillRect function, the rectangle is filled up to, but not including, the right column and bottom row of pixels. This structure is identical to the RECTL structure. So it looks like the C/C++ code for this would go approximately like: RECT workarea; BOOL ret; ret = SystemParametersInfo ( SPI_GETWORKAREA, 0, & workarea, 0 ); if ( ! ret ) { ... GetLastError ... } // workarea can be determined from workarea.left, workarea.top, etc. -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice. |
From: Glenn L. <Gle...@ne...> - 2001-05-29 00:04:47
|
OK, here's sample Perl/Win32::GUI/Win32::API code for positioning windows on the desktop while avoiding any/all Windows "appbars" and the Windows "taskbar" (which was the first appbar, and still seems to be a bit special among appbars). If you don't like my "negative number means right or bottom" stuff, just take it out :) Thanks to Harald for the kernel knowledge that got me started, and the attaboy along the way. This code attempts to keep the full window visible, so if/when you want to allow part of the windows to float off-screen, or under the taskbars, well, don't use this code, or modify it appropriately. ##################################### sub make_get_work_area { my $spi; $spi = new Win32::API ( 'user32', 'SystemParametersInfo', [ 'I', 'I', 'P', 'I' ], 'I' ); return $spi; } ##################################### sub call_get_work_area { my ( $spi ) = @_; my ( $rect ) = pack ( "LLLL", 0, 0, 0, 0 ); my ( $ret ) = $spi -> Call ( 48, 0, $rect, 0 ); unless ( $ret ) { } return unpack ( "LLLL", $rect ); } ##################################### { my $spi; sub working_area { my ( $winx, $winy, $winw, $winh ) = @_; # proposed position, actual size # If no parameters are passed in, this function returns the working area # of the desktop, ( left, top, right, bottom ). If parameters are passed # in, it returns the "best" ( left, top, width, height ) position for the # specified window, starting with the proposed position, adjusting it so # that as much as possible of the window will be visible, and further # adjusting it so that the top left corner of the window will be visible. # Negative positions are interpreted as "bottom" or "right", as appropriate. # first, obtain the non-toolbar area of the desktop. $spi = & make_get_work_area () unless $spi; print "$spi\n"; my ( @limits ); @limits = & call_get_work_area ( $spi ); print "limits: @limits\n"; # limits returned unless all parameters supplied return @limits unless defined $winx && defined $winy && defined $winw && defined $winh; print "before adjustments: x=$winx y=$winy w=$winw h=$winh\n"; $winy = $limits [ 3 ] - $winh if $winy < 0 || $winy + $winh > $limits [ 3 ]; $winx = $limits [ 2 ] - $winw if $winx < 0 || $winx + $winw > $limits [ 2 ]; $winy = $limits [ 1 ] if $winy < $limits [ 1 ]; $winx = $limits [ 0 ] if $winx < $limits [ 0 ]; print "x=$winx y=$winy w=$winw h=$winh\n"; return ( $winx, $winy, $winw, $winh ); } } ##################################### Glenn Linderman wrote: > "Piske, Harald" wrote: > > > I'm impressed - here's somebody who knows how to translate general ideas > > into formal terminology. > > Thanks for the attaboy. It was just what I needed to inspire further > research... > > > I don't have a solution at hand but with what you > > say, you should be able to figure it out. I'm not aware of any ready-made > > windoze function to give you the "effective desktop client area after > > accounting for taskbars", but that does not mean there is none. I'm not > > really at home in the win ref manuals. > > I am. Now. Post research :) Research is below for the interested. Next > research project is to figure out how to use Win32::API well enough to benefit > from the research... > > > Just one more note: my wife has a toolbar on her computer that is nothing > > but a small collection of buttons. Looks like it was invented before Win98 > > came along with it's quick-launch thingy. That is only around 10% of the > > screen width and just one row of icons high. > > I've seen some of those. Not too concerned about them, either. > > Here's the relevant pieces of the results of the research through MSDN: > > BOOL SystemParametersInfo( > UINT uiAction, // system parameter to query or set > UINT uiParam, // depends on action to be taken > PVOID pvParam, // depends on action to be taken > UINT fWinIni // user profile update flag > ); > > when uiAction == SPI_GETWORKAREA > > Retrieves the size of the work area on the primary display monitor. The work > area is the portion of the screen not obscured by the system taskbar or by > application desktop toolbars. The pvParam parameter must point to a RECT > structure that receives the coordinates of the work area, expressed in virtual > screen coordinates. > > To get the work area of a monitor other than the primary display monitor, call > the GetMonitorInfo function. > > RECT > > The RECT structure defines the coordinates of the upper-left and lower-right > corners of a rectangle. > > typedef struct _RECT { > LONG left; > LONG top; > LONG right; > LONG bottom; > } RECT; > > Members > left Specifies the x-coordinate of the upper-left corner of the rectangle. > top Specifies the y-coordinate of the upper-left corner of the rectangle. > right Specifies the x-coordinate of the lower-right corner of the rectangle. > bottom Specifies the y-coordinate of the lower-right corner of the rectangle. > > Remarks > > When RECT is passed to the FillRect function, the rectangle is filled up to, but > not including, the right column and bottom row of pixels. This structure is > identical to the RECTL structure. > > So it looks like the C/C++ code for this would go approximately like: > > RECT workarea; > BOOL ret; > > ret = SystemParametersInfo ( SPI_GETWORKAREA, 0, & workarea, 0 ); > if ( ! ret ) > { ... GetLastError ... > } > // workarea can be determined from workarea.left, workarea.top, etc. > > -- > Glenn > ===== > Due to the current economic situation, the light at the > end of the tunnel will be turned off until further notice. > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice. |
From: Webmaster C. <web...@cy...> - 2001-05-26 08:59:51
|
Hi ! > $_ = Win32::GUI::FindWindow ("Shell_TrayWnd", ""); > @_ = Win32::GUI::GetWindowRect ($_); > > $width = $_[2] - $_[0]; > $height = $_[3] - $_[1]; ok - thx ... works fine !!!! cu Thorsten S. |
From: Glenn L. <Gle...@ne...> - 2001-05-26 20:51:23
|
Indeed, this works. I've long wondered about a way to do it, and I've now incorporated this into my (only) Win32::GUI program. I am planning to write some more Win32::GUI programs soon. It seems, though, that this solution isn't completely general. While I don't personally use it anymore, I recall MS Office had an optional taskbar that could be docked similarly to the Windows taskbar. And some laptops have "power management toolbars". etc. Does anyone know of a more general technique for avoiding all the toolbars/taskbars that might nibble away at the edges of the desktop? "Piske, Harald" wrote: > $_ = Win32::GUI::FindWindow ("Shell_TrayWnd", ""); > @_ = Win32::GUI::GetWindowRect ($_); > > $width = $_[2] - $_[0]; > $height = $_[3] - $_[1]; > > tested on Win2k and Win98. Interestingly, the position of the taskbar is > slightly off the screen (-2). > > Note that the taskbar can be moved to each of the four window edges (eight > on dual-screen, which would look like off the desktop), so don't put your > program fixed at (0,0). I have mine upright at the left side instead of flat > at the bottom. If it takes up less of the vertical extend, which programs > use for status bars, tool bars, menu bars and so on. Take web browsers for > instance. Web pages are usually longer than the screen height but less wide > than the screen width. > > Have fun, > Harald > > | -----Original Message----- > | From: Webmaster CZ [mailto:web...@cy...] > | Sent: Wednesday, May 23, 2001 12:51 > | To: per...@li... > | Subject: [perl-win32-gui-users] Taskbar & perl2exe -gui crash > | > | > | Hi ! > | > | I have two problems: > | > | a) > | My program start in maximal width & height with this code: > | > | ---------Code---------------- > | $screensize = Win32::GUI::GetDesktopWindow(); > | $screensize_width = Win32::GUI::Width($screensize); > | $screensize_height = Win32::GUI::Height($screensize); > | ---------Code---------------- > | > | The problem is, that i must subtract the size of the Taskbar... > | so how can i read the size (height) of it ???? > | > | > | b) > | If i compile my program with perl2exe and "-gui", then the > | program crash on exit.... ever: the "exit code" are: > | > | -----------Code----------- > | sub Window_Terminate { > | return -1; > | } > | > | sub Exit_Click { > | return -1; > | } > | ------------Code--------- > | > | Any idea ??? > | > | > | > | cu > | Thorsten Sommer > | > | > | _______________________________________________ > | Perl-Win32-GUI-Users mailing list > | Per...@li... > | http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > | > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice. |
From: Dave <da...@sk...> - 2001-05-27 00:43:08
|
I have had the same problem you mentioned about perl2exe compiled apps crashing on exit. If you come across a solution please let me know. Thanks, Dave > -----Original Message----- > From: per...@li... [mailto:perl-win32- > gui...@li...] On Behalf Of Glenn Linderman > Sent: Saturday, May 26, 2001 4:54 PM > To: per...@li... > Subject: Re: [perl-win32-gui-users] Taskbar & perl2exe -gui crash > > Indeed, this works. I've long wondered about a way to do it, and I've now > incorporated this into my (only) Win32::GUI program. I am planning to > write > some more Win32::GUI programs soon. It seems, though, that this solution > isn't > completely general. While I don't personally use it anymore, I recall MS > Office > had an optional taskbar that could be docked similarly to the Windows > taskbar. > And some laptops have "power management toolbars". etc. > > Does anyone know of a more general technique for avoiding all the > toolbars/taskbars that might nibble away at the edges of the desktop? > > > "Piske, Harald" wrote: > > > $_ = Win32::GUI::FindWindow ("Shell_TrayWnd", ""); > > @_ = Win32::GUI::GetWindowRect ($_); > > > > $width = $_[2] - $_[0]; > > $height = $_[3] - $_[1]; > > > > tested on Win2k and Win98. Interestingly, the position of the taskbar is > > slightly off the screen (-2). > > > > Note that the taskbar can be moved to each of the four window edges > (eight > > on dual-screen, which would look like off the desktop), so don't put > your > > program fixed at (0,0). I have mine upright at the left side instead of > flat > > at the bottom. If it takes up less of the vertical extend, which > programs > > use for status bars, tool bars, menu bars and so on. Take web browsers > for > > instance. Web pages are usually longer than the screen height but less > wide > > than the screen width. > > > > Have fun, > > Harald > > > > | -----Original Message----- > > | From: Webmaster CZ [mailto:web...@cy...] > > | Sent: Wednesday, May 23, 2001 12:51 > > | To: per...@li... > > | Subject: [perl-win32-gui-users] Taskbar & perl2exe -gui crash > > | > > | > > | Hi ! > > | > > | I have two problems: > > | > > | a) > > | My program start in maximal width & height with this code: > > | > > | ---------Code---------------- > > | $screensize = Win32::GUI::GetDesktopWindow(); > > | $screensize_width = Win32::GUI::Width($screensize); > > | $screensize_height = Win32::GUI::Height($screensize); > > | ---------Code---------------- > > | > > | The problem is, that i must subtract the size of the Taskbar... > > | so how can i read the size (height) of it ???? > > | > > | > > | b) > > | If i compile my program with perl2exe and "-gui", then the > > | program crash on exit.... ever: the "exit code" are: > > | > > | -----------Code----------- > > | sub Window_Terminate { > > | return -1; > > | } > > | > > | sub Exit_Click { > > | return -1; > > | } > > | ------------Code--------- > > | > > | Any idea ??? > > | > > | > > | > > | cu > > | Thorsten Sommer > > | > > | > > | _______________________________________________ > > | Perl-Win32-GUI-Users mailing list > > | Per...@li... > > | http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > > | > > > > _______________________________________________ > > Perl-Win32-GUI-Users mailing list > > Per...@li... > > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > > -- > Glenn > ===== > Due to the current economic situation, the light at the > end of the tunnel will be turned off until further notice. > > > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users |