Application Child Windows

Started by Richard Kelly, March 29, 2010, 11:05:24 PM

Previous topic - Next topic

Richard Kelly

In my first FF app (non-MDI), I have numerous forms that are opened from the main form menu. Some are modal and some are not. For those that are not modal I also want to be able to determine if a particular form is already running. I put together:


Function FormActive (ByRef szClassName As Asciiz * %MAX_PATH) As Long

' Determine if a form is already running

Local nWndChild         As Dword
Local nReturn           As Long

   nReturn = %FALSE

   nWndChild = FindWindowEx (0, 0, szClassName, ByVal(%Null))
   
   Select Case nWndChild
   
      Case = %Null
     
      Case Else
     
         ShowWindow (nWndChild, %SW_RESTORE)
         
         nReturn = %TRUE
     
   End Select
   
   Function = nReturn
   
End Function


Does anybody have a better way?

Paul Squires

If I understand what you need then maybe the following would work:


If IsWindow( hWndForm ) Then
   If IsWindowVisible( hWndForm ) = 0 Then
      ShowWindow hWndForm, %SW_SHOW
   End If
End If

Paul Squires
PlanetSquires Software

Richard Kelly

Thanks for your suggestion. I found that minimized forms stayed minimized. I took your example and built:


Function FormActive (ByVal hWndForm As Dword) As Long

Local nReturn           As Long

   nReturn = %FALSE

   If IsWindow( hWndForm ) Then
   
      nReturn = %TRUE
     
      ShowWindow (hWndForm, %SW_RESTORE)
         
   End If

   Function = nReturn

End Function



It works as I want and is better than my original class search method.