FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour MessageBox with Timeout ?
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
MessageBox with Timeout ?
Posted: Thu Dec 15, 2022 04:53 PM
hi,

does Fivewin have a MessageBox with Timeout :?:


how to "translate" this HMG CODE
Code (fw): Select all Collapse
#define ID_TIMEDOUT 32000

int WINAPI MessageBoxTimeout (HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType, WORD wLanguageId, DWORD dwMilliseconds) 
{
   typedef BOOL (WINAPI *PMessageBoxTimeout)(HWND,LPCTSTR,LPCTSTR,UINT,WORD,DWORD);
_THREAD_LOCK();
   static PMessageBoxTimeout pMessageBoxTimeout = NULL;
   if (pMessageBoxTimeout == NULL) 
   {
      HMODULE hLib = LoadLibrary (_TEXT("User32.dll"));
      #ifdef UNICODE
         pMessageBoxTimeout = (PMessageBoxTimeout)GetProcAddress(hLib, "MessageBoxTimeoutW");
      #else
         pMessageBoxTimeout = (PMessageBoxTimeout)GetProcAddress(hLib, "MessageBoxTimeoutA");
      #endif
   }
_THREAD_UNLOCK();
   if(pMessageBoxTimeout == NULL)
      return FALSE;
   return pMessageBoxTimeout(hWnd, lpText, lpCaption, uType, wLanguageId, dwMilliseconds);
}

//       HMG_MessageBoxTimeout (cText, cCaption, nTypeIconButton, nMilliseconds) ---> Return nRetValue
HB_FUNC (HMG_MESSAGEBOXTIMEOUT)
{
   HWND  hWnd           = GetActiveWindow();
   TCHAR *lpText        = (TCHAR *) HMG_parc (1);
   TCHAR *lpCaption     = (TCHAR *) HMG_parc (2);
   UINT  uType          = HB_ISNIL(3) ? MB_OK : (UINT) hb_parnl (3);
   WORD  wLanguageId    = MAKELANGID (LANG_NEUTRAL, SUBLANG_NEUTRAL);
   DWORD dwMilliseconds = HB_ISNIL(4) ? (DWORD)0xFFFFFFFF  : (DWORD) hb_parnl (4);
   int iRet = MessageBoxTimeout (hWnd, lpText, lpCaption, uType, wLanguageId, dwMilliseconds);
   hb_retni ((int) iRet);
}
greeting,

Jimmy
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: MessageBox with Timeout ?
Posted: Thu Dec 15, 2022 05:18 PM
Like this?
Code (fw): Select all Collapse
Shows a DialogBox with a msg and waits some time 
Syntax: 
 MsgWait( <cMsg> [,<cTitle>], [<nSeconds>] ) --> nil  
 
Parameters: 

 <cMsg> The message to display  
  <cTitle> The title of the dialogbox. By default "Please, wait..."  
  <nSeconds> The time in seconds to wait. By default just waits 4 seconds. MsgWait() will automatically end the DialogBox that appears.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: MessageBox with Timeout ?
Posted: Thu Dec 15, 2022 05:29 PM
hi,
Horizon wrote:Like this?
Code (fw): Select all Collapse
 MsgWait( <cMsg> [,<cTitle>], [<nSeconds>] ) --> nil
Yes, this will do the Job, thx
greeting,

Jimmy

Continue the discussion