Determine WindowMode?

L

Larry

I have an Access 2002 form I open in Normal and Dialog modes, depending
on the situation.

If the form opens in normal mode, I want the caption to say one thing
and in dialog mode, it should say something else.

I would think there is a way in the Load event of the form to determine
how the form is opened so I could set the caption, but I can't figure
it out.

Anyone know how I can determine the WindowMode?

Thanks,
Larry
 
A

Albert D.Kallal

This came out a few months ago, and there is not a built in way of knowing
this.

Do note, that often people need a model form, and not a dialog form (they
are very very different)

One code approach is to put the following code in a public module:

Private Declare Function apiGetParent _
Lib "User32" Alias "GetParent" (ByVal hWnd As Long) As Long


Public Function IsDialog(f As Form) As Boolean


Dim lngParentHWnd As Long

lngParentHWnd = apiGetParent(f.hWnd)

If lngParentHWnd = hWndAccessApp Then
IsDialog = True
Else
IsDialog = False
End If


End Function


You can then in your forms on-load event use:

if isDialog(me) = true then
' this is dialog...

else
' this not dialog
end if


Note that the above works, but if your form is set to a popup form, then
isDialog returns true regardless if you actually opened the form in dialog
mode.

As mentioned, you might want to be sure that you actually want a dialog form
in place of a popup, or model form. I explain the difference between model
and dialog here:

http://www.members.shaw.ca/AlbertKallal/Dialog/Index.html
 
W

Wayne Morgan

Another option if your are opening the form via code, would be to pass how
it was called (standard or dialog) in the OpenArgs argument. You could check
the value of this argument in the form's Open event and change its caption
based on that value.
 
L

Larry

I had thought of the OpenArgs as a work around, but the API code worked
fine. Thanks for the suggestion though.
 

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