Page 1 of 1

FindWindow

Posted: Thu Dec 01, 2005 8:39 am
by pawelu
Hello,

I insert to startup program procedure this function:

Code: Select all

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

Posted: Thu Dec 01, 2005 9:01 am
by Antonio Linares
Pawel,

Have you tried this?

Code: Select all

   if StillRun()
      Quit
   endif

Posted: Thu Dec 01, 2005 9:19 am
by pawelu
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

Re: FindWindow

Posted: Thu Dec 01, 2005 11:06 am
by Enrico Maria Giordano
The syntax is the other way around:

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

EMG

Posted: Thu Dec 01, 2005 6:27 pm
by pawelu
Enrico,

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

Pawel

Posted: Thu Dec 01, 2005 6:58 pm
by Enrico Maria Giordano
What is TEXT()?

EMG

Posted: Fri Dec 02, 2005 7:28 am
by pawelu
Enrico,

TEXT () is window title.

Paweł

Posted: Fri Dec 02, 2005 9:42 am
by Enrico Maria Giordano
No, I did mean, what is function TEXT()?

EMG

Posted: Fri Dec 02, 2005 12:47 pm
by pawelu
Enrico,

TEXT is macro declared as:

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

Pawel

Posted: Fri Dec 02, 2005 12:54 pm
by Antonio Linares
Yes, it is the equivalent to write L"hello". The C compiler generates a hello in unicode.

i have new xcommand with command DEFINE WINDOW

Posted: Mon Jul 10, 2006 2:03 pm
by HATHAL
Welcome Antonio
i have new xcommand
with command DEFINE WINDOW
Please view
*************************************
view full source
*******************************************
#include "FWCE.ch"
// new
#xcommand DEFINE WINDOW <oWnd> ;
[ TITLE <cTitle> ] ;
[ MENU <oMenu> ] ;
[ STYLE <nStyle> ] ;
[ MULTE <LStop> ];
=> ;
<oWnd> := ISRUN_OK( [<cTitle>], [<oMenu>], [<nStyle>] ,[<LStop>])
// *******************************************************
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.
:lol:
good work !

hathal

Posted: Tue Jul 11, 2006 5:47 pm
by Antonio Linares
Hathal,

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