Re: Detect a form's window mode

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



To solve an unrelated need, I ended up creating SUBs which encapsulate the
DoCmd.OpenForm (or .OpenReport) statements. Instead of directly opening the
form/report, they are now opened using openFrmManifest, openRptLoadList, etc.
So basically, I can use the same technique to work around this.

"Dirk Goldgar" wrote:

"dch3" <dch3@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A9227DAB-D5D6-412C-8BC6-5C5340B43409@xxxxxxxxxxxxxxxx
I'm already passing in some .OpenArgs used for setting values in the
controls
- some of the forms are used with .NotInList events. Given that I'm trying
to
be consistent in how my data collection forms operate, I was hoping to
avoid
having to go back and modify the DoCmd that open the forms and the various
Loads.

I sympathize.

Hmm. By looking at the window classes of the form and of its parent window,
I can tell whether the form is popup or not. If it's opened in dialog mode,
it's also popup, so if I don't have to distinguish between dialog mode and
plain old popup, this can work:

'----- code for form -----
Private Declare Function apiGetParent Lib "user32" _
Alias "GetParent" (ByVal hwnd As Long) As Long
'Returns the handle of the parent window of the specified window.

Private Sub Form_Load()

Dim hWndParent As Long

Debug.Print "Me", Me.hwnd, fGetClassName(Me.hwnd)

hWndParent = apiGetParent(Me.hwnd)
Debug.Print "Parent", hWndParent, fGetClassName(hWndParent)

Debug.Print "Access", Application.hWndAccessApp, _
GetClassName(Application.hWndAccessApp)

' Note: fGetClassName comes from a module posted on the Access Web,
' but it looks like you don't really need it, so I won't post the link
now.

End Sub

'----- end code -----

In Immediate window:

DoCmd.OpenForm "frmDialog"
Me 5048118 OForm
Parent 60031730 MDIClient
Access 68158248 OMain

(close form between calls)

Docmd.OpenForm "frmDialog", WindowMode:=acDialog
Me 5310262 OFormPopup
Parent 68158248 OMain
Access 68158248 OMain

So it looks like, if the parent Hwnd is the same as hWndAccessApp, the form
is popup or dialog. I haven't tested this exhaustively, but it's a step in
the right direction.


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

.



Relevant Pages

  • Re: Detect a forms window mode
    ... By looking at the window classes of the form and of its parent window, I can tell whether the form is popup or not. ... Dim hWndParent As Long ...
    (microsoft.public.access.modulesdaovba)
  • Re: popup window: Return value to correct text box?
    ... On Nov 6, 1:21 pm, bruce barker ... popup window is placed in text box 1 on the parent form. ... PARENT WINDOW ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Showing a Form using a timer
    ... Me.ShowPopup to give the system time to actual paint the window. ... > outlook 2003 notify popup. ... > Private Sub ATU_RetrieveDone(ByVal e As ... > 2) Tick Handler creates a new AsyncUpdater and invokes the GetUpdate ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Showing a Form using a timer
    ... It appears that the only event that is fired by the PopUp Form is the ... >> Me.ShowPopup to give the system time to actual paint the window. ... >>> Private Sub UpdateTopicListView ... >>> both give the same result, a black box that appears and then disappears. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Modeless Popup Window - Controls have no functionality
    ... I'm having a bit of an issue with a popup toast window. ... Hourglass cursor. ... The timer elapses, then if I need to show the status window, I ... Public Shared Sub Main ...
    (microsoft.public.dotnet.framework.windowsforms)