473,378 Members | 1,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Determine the size of the Windows screen MINUS the task bar?

Is there a way to determine the size of the user's screen minus the
Windows task bar?
I am trying to maximize an Access popup form that is also resizeable
and it is causing me problems since it maximizes to full screen size
(with a portion under the toolbar.)

If I had the measurements of the screen minus the toolbar I could just
use docmd.movesize...

Thanks,
lq

(I am currently using a workaround where I maximize the Access window,
maximize the form, then restore the access window but it's a very messy
solution.)

Nov 13 '05 #1
9 9269
lauren quantrell wrote:
Is there a way to determine the size of the user's screen minus the
Windows task bar?
I am trying to maximize an Access popup form that is also resizeable
and it is causing me problems since it maximizes to full screen size
(with a portion under the toolbar.)

If I had the measurements of the screen minus the toolbar I could just
use docmd.movesize...

Thanks,
lq

(I am currently using a workaround where I maximize the Access window,
maximize the form, then restore the access window but it's a very messy
solution.)


<---
Option Compare Database
Option Explicit
Global Const gclngSM_CXMAXIMIZED = 61
Global Const gclngSM_CYMAXIMIZED = 62
Declare Function WinAPI_GetSystemMetrics Lib "user32" Alias
"GetSystemMetrics" (ByVal nIndex As Long) As Long

Sub ScreenSize()
Debug.Print "Width: " & WinAPI_GetSystemMetrics(gclngSM_CXMAXIMIZED)
Debug.Print "Height: " & WinAPI_GetSystemMetrics(gclngSM_CYMAXIMIZED)
End Sub
--->

--
This sig left intentionally blank
Nov 13 '05 #2
lauren quantrell wrote:
Is there a way to determine the size of the user's screen minus the
Windows task bar?


In a standard module:

Private Const HWND_TOP As Long = 0
Private Const HWND_TOPMOST As Long = -1
Private Const SWP_NOZORDER As Long = &H4
Private Const SWP_NOOWNERZORDER As Long = &H2

Private Declare Function GetClientRect Lib "user32" _
(ByVal hwnd As Long, lpRect As Rect) As Long

Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function BringWindowToTop Lib "user32" _
(ByVal hwnd As Long) As Long

Public Sub MaximizeToClientRect(ByRef Form As Form)
Dim ClientRect As Rect
GetClientRect Application.hWndAccessApp, ClientRect
With ClientRect
SetWindowPos _
Form.hwnd, _
HWND_TOP, _
.Left, _
.Top, _
.Right - .Left, _
.Bottom - .Top, _
SWP_NOZORDER
End With
End Sub

In the form module:

Private Sub Form_Open(Cancel As Integer)
MaximizeToClientRect Me
End Sub

--
--
Lyle
--
From ADO28.chm

Deprecated Components
Each of the following components is considered obsolete. While these
components are still supported in this release of the Microsoft® Data
Access Components (MDAC), they may be removed in the future. When
writing new applications, you should avoid using these deprecated
components. When modifying existing applications, you are strongly
encouraged to remove any dependency on these components.

ODBC Provider (MSDASQL)
You are strongly encouraged to use one of the native OLE DB Providers
instead of the Microsoft Open Database Connectivity (ODBC) Provider.
Native OLE DB Providers provide better application stability and
performance. Furthermore, native OLE DB Providers will be supported in
the future, whereas MSDASQL will not have any new features added to it,
will not be available on 64-bit, and will not be accessible from the OLE
DB NET Data Provider.

Remote Data Services (RDS)
Remote Data Services (RDS) is a proprietary Microsoft mechanism for
accessing remote data across the Internet or intranet. Microsoft is now
shipping the Microsoft Simple Object Access Protocol (SOAP) Toolkit 2.0
that enables you to access remote data using an open, XML-based
standard. Given the availability of the SOAP Toolkit 2.0, you should
migrate from RDS to SOAP. The SOAP 2.0 Toolkit 2.0 also includes sample
code for remotely accessing Microsoft ActiveX® Data Objects (ADO)
Recordsets.

Jet and Replication Objects (JRO)
The Microsoft Jet OLE DB Provider and other related components were
removed from MDAC 2.6. Microsoft has deprecated the Microsoft Jet
Engine, and plans no new releases or service packs for this component.
As a result, the Jet and Replication Objects (JRO) is being deprecated
in this release and will not be available in any future MDAC releases.

.....
Nov 13 '05 #3
On Mar 09 2005, 04:30 pm, "lauren quantrell" <la*************@hotmail.com>
wrote in news:11**********************@g14g2000cwa.googlegr oups.com:
Is there a way to determine the size of the user's screen minus the
Windows task bar?


Another way, which has the advantage of taking into account any toolbars
that might be visible on the desktop (Office, etc.), not just Windows
taskbar:

Private Declare Function apiSystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As RECT, ByVal fuWinIni As Long) As Long

Private Const SPI_GETWORKAREA = 48

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Public Sub T

Dim r As RECT

apiSystemParametersInfo SPI_GETWORKAREA, 0&, r, 0&

Debug.Print r.Top, r.Left, r.Bottom, r.Right

End Sub

--
remove a 9 to reply by email
Nov 13 '05 #4
Lyle,
Thanks for the reply. Your code only works to maximize the form within
the Access window frame, whatever shape and position that might be in.
But it did get me pointed in the right direction, and using a
complation of code I came up with the following solution:

Global Const gclngSM_CXMAXIMIZED = 61
Global Const gclngSM_CYMAXIMIZED = 62

Declare Function WinAPI_GetSystemMetrics Lib "user32" Alias
"GetSystemMetrics" (ByVal nIndex As Long) As Long

Private Const HWND_TOP As Long = 0
Private Const SWP_NOZORDER As Long = &H4

Function MaximizeToWindowsRect(ByRef Form As Form)

Dim ScreenWidth As Long, ScreenHeight As Long

ScreenWidth = WinAPI_GetSystemMetrics(gclngSM_CXMAXIMIZED)
ScreenHeight = WinAPI_GetSystemMetrics(gclngSM_CYMAXIMIZED)

SetWindowPos Form.hwnd, HWND_TOP, 0, 0, ScreenWidth, ScreenHeight -
3, SWP_NOZORDER

End Function


Lyle Fairfield wrote:
lauren quantrell wrote:
Is there a way to determine the size of the user's screen minus the
Windows task bar?
In a standard module:

Private Const HWND_TOP As Long = 0
Private Const HWND_TOPMOST As Long = -1
Private Const SWP_NOZORDER As Long = &H4
Private Const SWP_NOOWNERZORDER As Long = &H2

Private Declare Function GetClientRect Lib "user32" _
(ByVal hwnd As Long, lpRect As Rect) As Long

Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function BringWindowToTop Lib "user32" _
(ByVal hwnd As Long) As Long

Public Sub MaximizeToClientRect(ByRef Form As Form)
Dim ClientRect As Rect
GetClientRect Application.hWndAccessApp, ClientRect
With ClientRect
SetWindowPos _
Form.hwnd, _
HWND_TOP, _
.Left, _
.Top, _
.Right - .Left, _
.Bottom - .Top, _
SWP_NOZORDER
End With
End Sub

In the form module:

Private Sub Form_Open(Cancel As Integer)
MaximizeToClientRect Me
End Sub

--
--
Lyle
--
From ADO28.chm

Deprecated Components
Each of the following components is considered obsolete. While these
components are still supported in this release of the Microsoft®

Data Access Components (MDAC), they may be removed in the future. When
writing new applications, you should avoid using these deprecated
components. When modifying existing applications, you are strongly
encouraged to remove any dependency on these components.

ODBC Provider (MSDASQL)
You are strongly encouraged to use one of the native OLE DB Providers instead of the Microsoft Open Database Connectivity (ODBC) Provider.
Native OLE DB Providers provide better application stability and
performance. Furthermore, native OLE DB Providers will be supported in the future, whereas MSDASQL will not have any new features added to it, will not be available on 64-bit, and will not be accessible from the OLE DB NET Data Provider.

Remote Data Services (RDS)
Remote Data Services (RDS) is a proprietary Microsoft mechanism for
accessing remote data across the Internet or intranet. Microsoft is now shipping the Microsoft Simple Object Access Protocol (SOAP) Toolkit 2.0 that enables you to access remote data using an open, XML-based
standard. Given the availability of the SOAP Toolkit 2.0, you should
migrate from RDS to SOAP. The SOAP 2.0 Toolkit 2.0 also includes sample code for remotely accessing Microsoft ActiveX® Data Objects (ADO)
Recordsets.

Jet and Replication Objects (JRO)
The Microsoft Jet OLE DB Provider and other related components were
removed from MDAC 2.6. Microsoft has deprecated the Microsoft Jet
Engine, and plans no new releases or service packs for this component. As a result, the Jet and Replication Objects (JRO) is being deprecated in this release and will not be available in any future MDAC releases.
....


Nov 13 '05 #5
Dimitri,
You have provided the perfect solution!
My earlier solution did not take into account the toolbar position
problem, which you have provided me a solution for.
This code maximizes an Access form to the usable Windows screen area
and takes into account the size and position of toolbars and taskbar.
Thanks to everyone for giving me the pieces and concept.

So here is my finished code:

'***CODE START:

Private Declare Function apiSystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As RECT, ByVal fuWinIni As Long) As Long

Private Const SPI_GETWORKAREA = 48

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Const HWND_TOP As Long = 0
Private Const SWP_NOZORDER As Long = &H4

Function MaxForm(ByRef Form As Form)

Dim r As RECT

apiSystemParametersInfo SPI_GETWORKAREA, 0&, r, 0&

SetWindowPos Form.hwnd, HWND_TOP, r.Left, r.Top, r.Right - r.Left,
r.Bottom - r.Top, SWP_NOZORDER

End Function
'***CODE END
Dimitri Furman wrote:
On Mar 09 2005, 04:30 pm, "lauren quantrell" <la*************@hotmail.com> wrote in news:11**********************@g14g2000cwa.googlegr oups.com:
Is there a way to determine the size of the user's screen minus the
Windows task bar?
Another way, which has the advantage of taking into account any

toolbars that might be visible on the desktop (Office, etc.), not just Windows taskbar:

Private Declare Function apiSystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As RECT, ByVal fuWinIni As Long) As Long
Private Const SPI_GETWORKAREA = 48

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Public Sub T

Dim r As RECT

apiSystemParametersInfo SPI_GETWORKAREA, 0&, r, 0&

Debug.Print r.Top, r.Left, r.Bottom, r.Right

End Sub

--
remove a 9 to reply by email


Nov 13 '05 #6
Dimitri. Thanks very much for helping me solve this. Now I just need to
know how to make my floating Access toolbar appear on top of the
maximized form window.
lq

Nov 13 '05 #7
On Mar 12 2005, 02:51 am, "lauren quantrell" <la*************@hotmail.com>
wrote in news:11**********************@z14g2000cwz.googlegr oups.com:
Dimitri. Thanks very much for helping me solve this. Now I just need to
know how to make my floating Access toolbar appear on top of the
maximized form window.


If I remember correctly, you can't do this with a maximized popup form. Is
there a particular reason you have to open the form as popup? Another
option may be to dock the toolbar.

Now, if I don't remember correctly and it is actually possible, then you
can try to hide and show the toolbar. Perhaps it will show on top of the
form after doing that.

--
remove a 9 to reply by email
Nov 13 '05 #8
Dimitri Furman <df*****@cloud99.net> wrote in
news:Xn****************************@127.0.0.1:
On Mar 12 2005, 02:51 am, "lauren quantrell"
<la*************@hotmail.com> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
Dimitri. Thanks very much for helping me solve this. Now I just
need to know how to make my floating Access toolbar appear on top
of the maximized form window.


If I remember correctly, you can't do this with a maximized popup
form. Is there a particular reason you have to open the form as
popup? Another option may be to dock the toolbar.

Now, if I don't remember correctly and it is actually possible,
then you can try to hide and show the toolbar. Perhaps it will
show on top of the form after doing that.


I'm coming into this thread late, but I once solved this problem by
creating a common "toolbar" as a subform that was embedded in all my
main forms. That kept it exactly where I wanted it, while also
allowing easy contextual modifications.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9
David,
I also thought of that solution a little too late for this application
I'm afraid since I have maybe 100 forms. But the next project I will do
just that.

BTW I did discover that toolbar vbShowNo follwed by vbSHowYes brings
the toolbar to the top of a popup form. I had only tried vbShowYes.

lq

David W. Fenton wrote:
Dimitri Furman <df*****@cloud99.net> wrote in
news:Xn****************************@127.0.0.1:
On Mar 12 2005, 02:51 am, "lauren quantrell"
<la*************@hotmail.com> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
Dimitri. Thanks very much for helping me solve this. Now I just
need to know how to make my floating Access toolbar appear on top
of the maximized form window.


If I remember correctly, you can't do this with a maximized popup
form. Is there a particular reason you have to open the form as
popup? Another option may be to dock the toolbar.

Now, if I don't remember correctly and it is actually possible,
then you can try to hide and show the toolbar. Perhaps it will
show on top of the form after doing that.


I'm coming into this thread late, but I once solved this problem by
creating a common "toolbar" as a subform that was embedded in all my
main forms. That kept it exactly where I wanted it, while also
allowing easy contextual modifications.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mh | last post by:
Hi Folks- I'm trying to do a simple emulation of unix "locate" functionality in python for windows. Problem is I don't want to crawl/index optical drives. Do any of the windows people out...
2
by: mykidisgollum | last post by:
Greetings, We've recently been working with our site pages' viewstate, turning off unnecessesary viestate items to reduce page size for faster loading. We are also experimenting with using less...
2
by: pmclinn | last post by:
What is the easiest way to find the viewable space on a EU's monitor, minus the taskbar space.....
6
by: arun.hallan | last post by:
Hi, I want to run a webservice method every night at a specified time, say 10pm. The current way i thought of doing this is to have a windows service and a timer which checks the time every...
12
by: garyusenet | last post by:
I want to write a program that lists all folders on my local hard drive in order of size, any ideas for how I might do this? Thankyou, Gary.
1
by: SetonSoftware | last post by:
I'm developing a VB.NET 2005 WinForms application that will run on a tablet PC. I want to build a screen resizer method that will position the forms and controls properly depending on whether the...
3
by: Mufasa | last post by:
I have customers who install our product and then set the screen resolution to a crappy resolution so things don't display on the screen correctly. I'd like to know what the default monitor setting...
4
by: dipalipatel | last post by:
Hi, I have one c# smart device application created in .net 2005. I have fixed size form for my one device. Now i have another device and screen size is chaged menas it is more wider and short...
6
by: davidson1 | last post by:
If I am using UNIX,suppose if I need to see the Windows Screen,Is it is Possible,Which Command can be used for that.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.