Subject Re: prevent program opening twice
From Bernard Mouille <bernardmouille16@gmail.com>
Date Sat, 21 Sep 2024 11:30:02 -0400
Newsgroups dbase.getting-started

Hello Charlie,

Look some code.

// Returns true if the window is running ( _Lib1 ).
function bd_IsWindowRun( cWindow, lMsgbox )
   if argcount() < 2
      lMsgbox = true
   endif
   if bd_FindWindow( null, cWindow ) <> 0
      if lMsgbox // Message if this function is used for not run 2 times the form.
         msgbox( "Window [ " + cWindow + " ] is running, Abort", "Find window", 48 )
      endif
      return true
   endif
   return false

// Find the handle of a window( _lib1.cc ).
function bd_FindWindow( cClass, cWindow )
   local hHandle
   if type( "FindWindowA" ) <> "FP"
      extern CHANDLE FindWindowA( CSTRING, CSTRING ) user32.dll
   endif
   hHandle = FindWindowA( cClass, cWindow )
   return hHandle

Regards,
Bernard.





Charlie Wrote:

> There was a post here a couple of years with instructions of preventing a form (i think) from opening twice.  I can't seem to find it when searching.  Can anyone point me to it?  Thanks much.