469,354 Members | 2,035 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,354 developers. It's quick & easy.

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 8717
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by mykidisgollum | last post: by
2 posts views Thread by pmclinn | last post: by
6 posts views Thread by arun.hallan | last post: by
1 post views Thread by SetonSoftware | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.