FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Pocket PC FindWindow
Posts: 126
Joined: Thu Oct 06, 2005 10:18 PM
FindWindow
Posted: Thu Dec 01, 2005 08:39 AM
Hello,

I insert to startup program procedure this function:

HB_FUNC (STILLRUN)
{
   HWND hWnd;
   BOOL lRet = FALSE;

   hWnd = FindWindow (TEXT ("App Title"), NULL);
   if (hWnd) 
   {
   SetForegroundWindow ((HWND) ((ULONG) hWnd |0x01));
   lRet = TRUE;
   }  
   hb_retl (lRet);
}


but this dosn't work. User can run apps several times. This same routine in pure C++ works fine (app is show in foreground).

Regards
Pawel
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
FindWindow
Posted: Thu Dec 01, 2005 09:01 AM
Pawel,

Have you tried this?

   if StillRun()
      Quit
   endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 126
Joined: Thu Oct 06, 2005 10:18 PM
FindWindow
Posted: Thu Dec 01, 2005 09:19 AM

Antonio,

Yes I try use it in start program like your sample, function always return False. I try change parameters (first is the name of class, second is the name of window) but no success.

Pawel

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FindWindow
Posted: Thu Dec 01, 2005 11:06 AM

The syntax is the other way around:

hWnd = FindWindow (NULL, TEXT ("App Title"));

EMG

Posts: 126
Joined: Thu Oct 06, 2005 10:18 PM
FindWindow
Posted: Thu Dec 01, 2005 06:27 PM

Enrico,

I try this, but function still desn't work.

Pawel

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 126
Joined: Thu Oct 06, 2005 10:18 PM
FindWindow
Posted: Fri Dec 02, 2005 07:28 AM

Enrico,

TEXT () is window title.

Paweł

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
FindWindow
Posted: Fri Dec 02, 2005 09:42 AM

No, I did mean, what is function TEXT()?

EMG

Posts: 126
Joined: Thu Oct 06, 2005 10:18 PM
FindWindow
Posted: Fri Dec 02, 2005 12:47 PM

Enrico,

TEXT is macro declared as:

"#define TEXT(quote) L##quote"

Pawel

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
FindWindow
Posted: Fri Dec 02, 2005 12:54 PM

Yes, it is the equivalent to write L"hello". The C compiler generates a hello in unicode.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 80
Joined: Tue Nov 15, 2005 03:38 PM
i have new xcommand with command DEFINE WINDOW
Posted: Mon Jul 10, 2006 02:03 PM

Welcome Antonio
i have new xcommand
with command DEFINE WINDOW
Please view


view full source


#include "FWCE.ch"
// new

xcommand DEFINE WINDOW <oWnd> ;

         [ TITLE &lt;cTitle&gt; ] ;
         [ MENU &lt;oMenu&gt; ] ;
         [ STYLE &lt;nStyle&gt; ] ;
         [ MULTE &lt;LStop&gt; ];
   =&gt; ;
      &lt;oWnd&gt; := ISRUN_OK( [&lt;cTitle&gt;], [&lt;oMenu&gt;], [&lt;nStyle&gt;] ,[&lt;LStop&gt;])

// *********
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "test is run " ;
MULTE .F.
// .F. TO RUN ONE COPY FROM PROGRAM UP SYSTEM OR .T. TO RUN ANY copy PROGRAM
ACTIVATE WINDOW oWnd
return nil
//
********
FUNC ISRUN_OK(cTitle,oMenu,nStyle,LStop)
LOCAL OWND_R
if STILLRUN(cTitle)=.t.
IF LStop<>NIL
IF LStop=.F.
QUIT
RETURN NIL
ENDIF
ENDIF
ENDIF
OWND_R:=TWindow():New(cTitle,oMenu,nStyle)
RETURN OWND_R

pragma BEGINDUMP

include <hbapi.h>

include <Windows.h>

include <mmsystem.h>

include <uniqueid.h>

LPWSTR AnsiToWide( LPSTR );

HB_FUNC (STILLRUN)
{
HWND hWnd;
BOOL lRet = FALSE;
LPWSTR pW = AnsiToWide( hb_parc( 1 ) );
hWnd = FindWindow ( NULL,pW);
if (hWnd)
{
SetForegroundWindow ((HWND) ((ULONG) hWnd |0x01));
lRet = TRUE;
}
hb_retl (lRet);
}

#pragma ENDDUMP


Please put all source with fwppc the library.

good work !

hathal

:lol:

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
FindWindow
Posted: Tue Jul 11, 2006 05:47 PM

Hathal,

We do appreciate your contribution, but in order to keep FiveWin PC compatibility we should use a SET MULTIPLE ON|OFF xbase command.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion