Access window sizing with visual basic.net

A

Antinsh

Ok, has anyone ever done it? For real! I mean i know you are supposed to use
this API function. But it doesnt work - width is set to height, height is set
as height of open database window- it just doesnt work!

If anyone has ever made a piece of code that resizes access window and does
it the way it supposed to, please share it with me, cuz I'm just loosing my
faith here.

P.S. By the way i'm working with Visual Studio 2005 vb.net (framework 2.0)
and Access 2003.
 
B

BeWyched

Hi
Ok, has anyone ever done it?

Done what - you haven't told us what you are trying to do.
For real! I mean i know you are supposed to use
this API function.

What API function - there are loads of them.
But it doesnt work - width is set to height, height is set
as height of open database window- it just doesnt work!

If anyone has ever made a piece of code that resizes access window and does
it the way it supposed to, please share it with me, cuz I'm just loosing my
faith here.

If you let us know what you are trying to do, we can suggest how you do it.
P.S. By the way i'm working with Visual Studio 2005 vb.net (framework 2.0)
and Access 2003.

Are you sure? You would normally work directly with Access. Opening Access
from within VS doesn't do anything - it just launches Access as normal. Do
you mean you are using Access data tables perhaps with a VB front-end -
please clarify.
I couldn't agree more!!
 
A

Antinsh

Too much talking too little sense from my mouth, again.

Ok let's try again, shall we :)
Done what - you haven't told us what you are trying to do.
Made a function in visual basic.net that resizes access application.Declare Function apiMoveWindow Lib "user32" Alias "MoveWindow" _
(ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal _
nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) _
As Long

Sub AccessMoveSize(ByVal iX As Integer, ByVal iY As Integer, ByVal
iWidth As _
Integer, ByVal iHeight As Integer)
apiMoveWindow(appAccess.hWndAccessApp, iX, iY, iWidth, iHeight, True)
End Sub

This is what I have come up with so far. AccessMoveSize should do the sizing
but it doesnt work. Well it works it just doesnt do what It supposed to.
(change sizes, moving windows)
If you let us know what you are trying to do, we can suggest how you do it.

Did my best.
Are you sure? You would normally work directly with Access. Opening Access
from within VS doesn't do anything - it just launches Access as normal. Do
you mean you are using Access data tables perhaps with a VB front-end -
please clarify.

Yes I'm sure that I'm using VS2005 and I'm also sure that I user VB.NET. The
application that i'm co-creating works with access applications - opens them,
lets you work with it, closes it, checks what you have done etc. But it still
cant change that freakin' windowsize of access when it is needed.
 
A

Antinsh

Too much talking too little sense from my mouth, again.

Ok let's try again, shall we :)
Done what - you haven't told us what you are trying to do.
Made a function in visual basic.net that resizes access application.Declare Function apiMoveWindow Lib "user32" Alias "MoveWindow" _
(ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal _
nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) _
As Long

Sub AccessMoveSize(ByVal iX As Integer, ByVal iY As Integer, ByVal
iWidth As _
Integer, ByVal iHeight As Integer)
apiMoveWindow(appAccess.hWndAccessApp, iX, iY, iWidth, iHeight, True)
End Sub

This is what I have come up with so far. AccessMoveSize should do the sizing
but it doesnt work. Well it works it just doesnt do what It supposed to.
(change sizes, moving windows)
If you let us know what you are trying to do, we can suggest how you do it.

Did my best.
Are you sure? You would normally work directly with Access. Opening Access
from within VS doesn't do anything - it just launches Access as normal. Do
you mean you are using Access data tables perhaps with a VB front-end -
please clarify.

Yes I'm sure that I'm using VS2005 and I'm also sure that I user VB.NET. The
application that i'm co-creating works with access applications - opens them,
lets you work with it, closes it, checks what you have done etc. But it still
cant change that freakin' windowsize of access when it is needed.
 
G

Guest

this API function. But it doesn't work - width is set to height,

Bet you've coded a coding error :~)

What version of Access are you using? Does it work with 'some
other' version? Have you got rid of all the pop-up and model
forms? Did you realise that some form windows don't have the
application as parent? You know it might not work in 'some
other' version?

Last time I tried anything like that, I found that the application window
was not exactly the window I was expecting -- it was AN application
window, not THE application window. Worse, the dimensions that I
read from he application window were not the same as the dimensions
I wrote -- that is, if I sized to the dimensions I read, I got it wrong,
because of the way the menu bars were handled.

I'm not aware of anyone ever trying to size the application window
other than hidden/window/max/min. Most people size an application
form, sometimes after hiding the application window. You know
that sizing the application window won't size forms? It hides child
forms, and has no effect on forms which have the desktop as parents.
Ok, has anyone ever done it? For real! I mean I know you are

Nope, doing reports are you? We let the customer view the reports
in normal window mode.

(david)
 
A

Antinsh

To David:

The purpose of this for me is to set Access window in lower half of desktop
and put my application in upper half so that they both could be seen at the
same time.
 
S

Stuart McCall

Antinsh said:
To David:

The purpose of this for me is to set Access window in lower half of
desktop
and put my application in upper half so that they both could be seen at
the
same time.

Here's a (standard) module I use to see how apps look at lower screen rez.
It sizes the Access window and centers it on screen. I realize you want to
locate it differently, but it shouldn't be too hard to figure out. Just how
you handle this from the .net side of things is up to you. I don't do .net

''' BEGIN CODE '''
Option Compare Database
Option Explicit
'
Private Type Rect
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
'
Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function GetWindowRect Lib "user32" _
(ByVal hWnd As Long, r As Rect) As Long

Private Declare Function IsZoomed Lib "user32" _
(ByVal hWnd As Long) As Long

Private Declare Function MoveWindow Lib "user32" _
(ByVal hWnd As Long, ByVal X As Long, ByVal Y As Long, _
ByVal dx As Long, ByVal dy As Long, ByVal fRepaint As Long) As Long

Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Sub SizeAccess(ByVal dx As Long, ByVal dy As Long)
'Set size of Access and center on Desktop

Const SW_RESTORE As Long = 9
Dim h As Long
Dim r As Rect
'
On Error Resume Next
'
h = Application.hWndAccessApp
'If maximised, restore
If (IsZoomed(h)) Then ShowWindow h, SW_RESTORE
'
'Get available Desktop size
GetWindowRect GetDesktopWindow(), r
If ((r.x2 - r.x1) - dx) < 0 Or ((r.y2 - r.y1) - dy) < 0 Then
'Desktop smaller than requested size
'so size to Desktop
MoveWindow h, r.x1, r.y1, r.x2, r.y2, True
Else
'Adjust to requested size and center
MoveWindow h, _
r.x1 + ((r.x2 - r.x1) - dx) \ 2, _
r.y1 + ((r.y2 - r.y1) - dy) \ 2, _
dx, dy, True
End If

End Sub
''' END CODE '''

As usual, watch out for line-wrap...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top