Resizing the Main Access Window without repositioning it (1 Viewer)

Danick

Registered User.
Local time
Today, 05:42
Joined
Sep 23, 2008
Messages
366
There are a lot of examples of resizing the Main Access window using the Application object, Application.hWndAccessApp
But I can not find a way to use this property without repositioning it. It would be great if it could be made to work like DoCmd.MoveSize for a form.
Basically, I'm trying to resize the main access window around a form without repositioning the access window.

Is there any way to do that?

Thanks
 
Your request sounds a little bit odd. Given that in Windows, everything relates to the upper left corner, if you resize a window, if it is both a change of height and of width, then you can only keep one corner (or one interior point) in the same place it was before you started.

Therefore, can you be a bit more specific? Are you looking to pin a particular corner? If so, which one. OR are you looking to pin the center and shrink the corners? These changes are possible but your choices ARE constrained here.
 
Hello Doc

I'm trying to do exactly what the DoCmd.MoveSize for a form does, but for the Access Window.
If you use DoCmd.MoveSize , , 800, 1000

The form will not reposition itself from the top LH corner but just change its size to 800 by 1000. So I'd like to be able to do that same thing to the Access Main window. Basically, keep the top LH corner of where the user positioned it and just adjust the RH bottom corner to the size of the form.
If a user has 2 screens and positions the main window on the 2nd screen, I don't want it to jump to the 1st screen (or anywhere else) when all I want to do is resize the Access Window.

Hope this helps clear up what I'm trying to do.
 
Sorry but that's as clear as mud to me. Perhaps you can find something useful in one of these articles:

 
Sorry but that's as clear as mud to me. Perhaps you can find something useful in one of these articles:

Hello Doc

I'm trying to do exactly what the DoCmd.MoveSize for a form does, but for the Access Window.
If you use DoCmd.MoveSize , , 800, 1000

The form will not reposition itself from the top LH corner but just change its size to 800 by 1000. So I'd like to be able to do that same thing to the Access Main window. Basically, keep the top LH corner of where the user positioned it and just adjust the RH bottom corner to the size of the form.
If a user has 2 screens and positions the main window on the 2nd screen, I don't want it to jump to the 1st screen (or anywhere else) when all I want to do is resize the Access Window.

Hope this helps clear up what I'm trying to do.
Sometimes a picture is worth 1,000 words. Can you add some screenshots to show us what you require?
 
Look at this thread:


This might require you to follow a couple of links internal to the linked thread, but it seems to be direct and to the point.
 
What I'm trying to do is very well explained in all the post links in this thread regarding "Access Main Window Resize" and "Hiding access window faster". In fact govuser1 never received a response to the question on modifying the code to "...the access window size but allow the window to open up in the position it was last opened in" . Check out post #9 in this thread.

https://www.access-programmers.co.uk/forums/threads/hiding-access-window-faster.81228/

Is what I'm trying to do any clearer now?
 
Not really.
Screenshots would be useful

I've never seen that thread in your link until now and most of it seems unrelated to your request

Perhaps post #9 wasn't answered because it wasn't understood at the time
The example app from Peter's Software in post #8 has lots of info but is any of that what you want?
The code in post #7 is almost identical to code I use in my example apps linked above in post #4.
Did you look at either of my example apps to see if what you need was included?
 
Not really.
Screenshots would be useful

I've never seen that thread in your link until now and most of it seems unrelated to your request

Perhaps post #9 wasn't answered because it wasn't understood at the time
The example app from Peter's Software in post #8 has lots of info but is any of that what you want?
The code in post #7 is almost identical to code I use in my example apps linked above in post #4.
Did you look at either of my example apps to see if what you need was included?
Yes - I'm actually using the SizeAccess() code in post #7 to resize the access window and it's working very well. But this code requires that the access window be set to some location (cx and cy). It can't be set to wherever the access window is currently located.

1710787385397.png


I thought maybe of finding the access window's cx and cy position, storing it somewhere and then using that position in the code when opening a form to resize the access window accordingly, but I can't get that to work either.
 
To repeat:
1. A screenshot would be useful
2. You didn't answer either of my questions
 
Yes I looked at the examples provided and found the one in post #7 to do just about everything that I want. But, it's not "exactly" what I'd like it to do. I also looked at your Control Application Interface, but I'm not using pop up forms. So rather than a screenshot, I made a simple database to illustrate what the problem is.

The idea here is if a user has two monitors and wants to keep the application on the 2nd monitor, I do not want to reposition it back to the first monitor when all I want to do is resize the Main Access Window.
 

Attachments

Is that really what you've been trying to say throughout this thread?

If so, you don't need the button or any other code to do this.
Resize the Access window and/or move it anywhere you want e.g. monitor 2.
Close Access. When you reopen it will automatically be in the same position and the same size as before
 
That was an example. I'd like to press the button to resize without it moving.
 
I suppose the answer to that question is esthetics - trying to make it look better. Using a button in this example was an attempt in simplifying my request. In any case and regardless of the reasons, the real question is, can it be done.
 
What's the problem with what I wrote in post #12?
 
Hi isladogs,

There isn’t anything wrong with what you wrote in post #12. But that only gets me halfway. More importantly, I’m trying to wrap the access window around the form (not the other way around) to make it appear like a popup. Plus, there are quite a few web sites where users have asked for this exact same capability. And lastly, I just watched your video on Controlling the Application Interface where you mention that one of the reasons you do this is to, “Challenge what you can do with Access” and “stretch as much as you can do with it”. Your module has almost 20 buttons manipulating the application interface, so why is this any different.
 
The issue I have is that after 17 posts, its still unclear to me what the purpose of doing this actually is.
It seems to have shifted since the start but is still not clear (at least to me)
As everybody else has dropped out, I suspect others are of the same opinion.
If not, perhaps someone else will step in.

there are quite a few web sites where users have asked for this exact same capability.

Really? Perhaps you could provide a link where someone has asked for this. It might be clearer

OTOH, perhaps you just mean this? See posts #64/65 in How to hide the Main Acces UI | Page 4 | Access World Forums (access-programmers.co.uk)
1710868672832.png
 
Using tabbed documents display wouldn't work for me as there are multiple forms and sub-forms being displayed. And the request hadn't really shifted, I just tried using different examples in order to try to provide a better picture of what I was trying to do. But that obviously didn't work either. In any case, I think I'm going to give this up for now and just allow the user to move and resize the window as they see fit. Seems to be more work than I originally thought.

Here are a few links to similar requests.

https://www.pcreview.co.uk/threads/access-main-window-size.2437567/
https://www.office-forums.com/threads/vba-code-to-resize-main-access-window.373522/
https://www.vbforums.com/showthread.php?360099-In-Access-resize-size-application-to-size-form/
https://www.access-programmers.co.uk/forums/threads/hiding-access-window-faster.81228/

Thanks for your help.
 
I've modified your example from post #12 and I believe it now does what you want
1. Added module modWindowPosition with function GetAccessWindowPosition
2. When your button is clicked it first runs the above function & stores the top & left position of the Access window as variables AccWindowLeft & AccWindowTop

Code:
Option Compare Database
Option Explicit

Declare PtrSafe Function GetWindowRect Lib "user32" _
    (ByVal hwnd As LongPtr, lpRect As RECT) As Long

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

Public AccWindowLeft As Long
Public AccWindowTop As Long

Sub GetAccessWindowPosition()
    Dim accessHwnd As LongPtr
    Dim accessRect As RECT

    ' Get the handle to the Access window
    accessHwnd = Application.hWndAccessApp
    
    ' Get the position of the Access window
    If GetWindowRect(accessHwnd, accessRect) <> 0 Then
        AccWindowLeft = accessRect.Left
        AccWindowTop = accessRect.Top
    Else
        Debug.Print "Failed to get window position."
    End If
End Sub

3. It then uses those values as the first 2 arguments of the SizeAccess code

Code:
Private Sub cmdAccessSizePosition_Click()

    GetAccessWindowPosition

    SizeAccess AccWindowLeft, AccWindowTop, 600, 700
    DoCmd.MoveSize 0, 0, 7000, 5000
End Sub
 

Attachments

Users who are viewing this thread

Back
Top Bottom