FindWindow

FindWindow

Postby pawelu » Thu Dec 01, 2005 8:39 am

Hello,

I insert to startup program procedure this function:

Code: Select all  Expand view  RUN
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
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby Antonio Linares » Thu Dec 01, 2005 9:01 am

Pawel,

Have you tried this?

Code: Select all  Expand view  RUN
   if StillRun()
      Quit
   endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42112
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby pawelu » Thu Dec 01, 2005 9: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
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Re: FindWindow

Postby Enrico Maria Giordano » Thu Dec 01, 2005 11:06 am

The syntax is the other way around:

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby pawelu » Thu Dec 01, 2005 6:27 pm

Enrico,

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

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

Postby Enrico Maria Giordano » Thu Dec 01, 2005 6:58 pm

What is TEXT()?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby pawelu » Fri Dec 02, 2005 7:28 am

Enrico,

TEXT () is window title.

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

Postby Enrico Maria Giordano » Fri Dec 02, 2005 9:42 am

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby pawelu » Fri Dec 02, 2005 12:47 pm

Enrico,

TEXT is macro declared as:

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

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

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

i have new xcommand with command DEFINE WINDOW

Postby HATHAL » Mon Jul 10, 2006 2: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 <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
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

Postby Antonio Linares » Tue Jul 11, 2006 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42112
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 40 guests

cron