Am I in Dialog mode? Am I Maximized

Hello experts!

How can I know, while in an open form in Access, if that form is -
1. maximized?
2. in dialog mode?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Well, Maximized is determined by You ... either in code in the Form Load or Open event, or in a Macro.

Again, Dialog mode is also determined by you, either in the FormOpen command, or the Popup and Modal properties on the Form property sheet.

Is this what you are asking ?

1. maximized?
I don't know of any setting but microsoft has a webpage which tells you how to determine it by using api calls. You need to use the IsZoomed api call.

2. in dialog mode?
Only option I know if is Modal but that is not the same as dialog. I am not aware of anything. You may need to hold an indicator yourself somehow (maybe global variable or form arguments) to tell the form it is opened as dialog.
NNOAM1Author Commented:
No. The Form is now open. It can be opened from various "places" in the application. Some of them open it in dialog mode, some of them not. In some of them it is maximized, in some of them not. I would like it to be that while the opened form is running, it would be possible to know in what "situation" I am. Something like:
If Me.Maximized then
End if

If Me.Dialog
     ...... etc.

But there aren't such properties. And when in dialog mode, the properties Popup and Modal are False.
Is there a way?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

with maximized you can try this. Add this code into a module

Declare Function IsZoomed Lib "User32" (ByVal hWnd As Long) As _
Public Function AmIMaxed(lHwnd As Long) As Boolean
    If IsZoomed(lHwnd) = 0 Then AmIMaxed = False Else AmIMaxed = True
End Function

Open in new window

then in your form, call AmIMaxed passig in the form handle

if AmIMaxed(me.hwnd)=true then
    msgbox "maxed"
end if

However with Dialog, I have not come across any property or api call. I will take a deeper look.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Overall, just say NO to Maximizing. WindowS is plural for a reason ... as in multiple windows.  ONLY in Access do developers for Maximizing on users ... because you 'can'.  Most of the time, it only generate a lot of gray/white space.

Imagine that if in Quickbooks Pro, every window/register that you opened was forced max. It would be maddening!

NNOAM1Author Commented:
Concerning Declare Function IsZoomed Lib "User32"  etc.:
Is it completely "safe" to use it in all Windows versions (XP, Vista, 7)?
(In "safe" I mean - will it work regardless of Win ver.)
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
32 bit API's will most likely need to be revamped / changed on Win x64, like Win7 x64 ...

Otherwise ... should not be an issue.

NNOAM1Author Commented:
In Win7 x64 how would I declare that function?
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
I believe you have to use the ptrSafe parameter ... Google that and you will get a million hits.  Or, maybe Rocki knows ...

as MX says, should not be an issue. MS support site has info on what api calls are okay to use. IsZoomed is one of them. Here is an example of how to define it to make it work for both 32bit and 64bit platforms.

Declare PtrSafe Function IsZoomed Lib "user32" Alias "IsZoomed" (ByVal hwnd As LongPtr) As Long

Read this here to help you get a better understanding.

I had a look. I went thru the properties. Only one's I can find are modal and popup. I went thru the list of api calls and could not find anything that tells you if it has been opened in dialog mode or not.
If you really need it, I think you will need to control it. Are you familiar with form arguments? you can maybe pass in something that way.
Wow, Im slow typing, last comment I saw "otherwise not an issue" by mx lol.
NNOAM1Author Commented:
Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.