FindWindow

Post Reply
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

FindWindow

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Pawel,

Have you tried this?

Code: Select all

   if StillRun()
      Quit
   endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FindWindow

Post by Enrico Maria Giordano »

The syntax is the other way around:

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

EMG
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Enrico,

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

Pawel
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Enrico,

TEXT () is window title.

Paweł
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Enrico,

TEXT is macro declared as:

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

Pawel
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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

Antonio Linares
www.fivetechsoft.com
User avatar
HATHAL
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh
Contact:

i have new xcommand with command DEFINE WINDOW

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply