Delphi to Xharbour

This is a discussion on Delphi to Xharbour within the xharbour forums in Programming Languages category; Hello, I am trying to rewrite this Delphi code for Xharbour var h2:Thandle; ms:integer; begin h2:=findwindow('TForm2', nil); ms:=1024; if h2 <> 0 then begin postmessage(h2, ms, 0, 0); end; end; I use FindWindow API function to check whether an application is running or not and Postmessage to comunicate a message to this Delphi application . API Function's syntax is as following: HWND FindWindow( LPCTSTR lpClassName, // pointer to class name LPCTSTR lpWindowName // pointer to window name ); ------------------------------------------------------ BOOL PostMessage( HWND hWnd, // handle of destination window UINT Msg, // message to post WPARAM wParam, // first message parameter ...

Go Back   Application Development Forum > Programming Languages > xharbour

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-29-2008, 04:31 AM
Eugenio Belli
Guest
 
Default Delphi to Xharbour

Hello,

I am trying to rewrite this Delphi code for Xharbour

var
h2:Thandle;
ms:integer;
begin
h2:=findwindow('TForm2', nil);
ms:=1024;
if h2 <> 0 then begin
postmessage(h2, ms, 0, 0);
end;
end;


I use FindWindow API function to check whether an
application is running or not and Postmessage to comunicate
a message to this Delphi application .


API Function's syntax is as following:

HWND FindWindow(

LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);

------------------------------------------------------
BOOL PostMessage(

HWND hWnd, // handle of destination window
UINT Msg, // message to post
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);


where i can find support or examples to implement this
function with xharbour ?

thanks,

Eugenio.

Reply With Quote
  #2  
Old 08-29-2008, 05:37 AM
J_Rudnicki@wp.pl
Guest
 
Default Re: Delphi to Xharbour

Eugenio Belli napisał(a):

> Hello,
>
> I am trying to rewrite this Delphi code for Xharbour
>
> var
> h2:Thandle;
> ms:integer;
> begin
> h2:=findwindow('TForm2', nil);
> ms:=1024;
> if h2 <> 0 then begin
> postmessage(h2, ms, 0, 0);
> end;
> end;
>
>
> I use FindWindow API function to check whether an
> application is running or not and Postmessage to comunicate
> a message to this Delphi application .
>
>
> API Function's syntax is as following:
>
> HWND FindWindow(
>
> LPCTSTR lpClassName, // pointer to class name
> LPCTSTR lpWindowName // pointer to window name
> );
>
> ------------------------------------------------------
> BOOL PostMessage(
>
> HWND hWnd, // handle of destination window
> UINT Msg, // message to post
> WPARAM wParam, // first message parameter
> LPARAM lParam // second message parameter
> );
>
>
> where i can find support or examples to implement this
> function with xharbour ?


Hi,

Included in what32.lib . Sources in \contrib\what32 :

_winwnd.c :

(...)
HB_FUNC( FINDWINDOW )
{
hb_retnl((ULONG) FindWindow( (LPCSTR) hb_parcx(1), ISCHAR(2) ?
hb_parcx(2):NULL ) ) ;
}
(...)

_winmsg.c :

(...)
HB_FUNC( POSTMESSAGE )
{
char *cText = NULL;

if (ISBYREF(4))
{
cText = (char*) hb_xgrab( hb_parcsiz(4) );
hb_xmemcpy( cText, hb_parcx(4), hb_parcsiz(4) );
}
hb_retnl( (LONG) PostMessage( (HWND) hb_parnl( 1 ), (UINT)
hb_parni( 2 ),
(ISNIL(3) ? 0 : (WPARAM)
hb_parnl( 3 )) ,
(ISNIL(4) ? 0 : ( ISBYREF(4)? (LPARAM)
(LPSTR) cText : ( ISCHAR(4) ? (LPARAM)(LPSTR) hb_parcx(4) : (LPARAM)
hb_parnl( 4 ))))
)
);
if( ISBYREF( 4 ) )
{
hb_storclen( cText, hb_parcsiz(4), 4 ) ;
hb_xfree( cText );
}
}
(...)

Regards
JoteR
Reply With Quote
  #3  
Old 08-29-2008, 05:39 AM
Eugenio Belli
Guest
 
Default Re: Delphi to Xharbour

Il Fri, 29 Aug 2008 10:31:29 +0200, Eugenio Belli <no@spam.it> ha
scritto:

I am trying this :

procedure winmsg

FINDWIN( "TFORM2", 0 )

RETURN


#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"

HB_FUNC( FINDWIN )
{
hb_retnl( (LONG) FINDWINDOW( hb_parnl(1), hb_parc(2) ) );
}
#pragma ENDDUMP


I obtain this compiler message:

Warning W8065 winmsg.prg 16:Call to function 'FINDWINDOS' with non
prototype in function HB_FUN_FINDWIN
Reply With Quote
  #4  
Old 08-29-2008, 05:41 AM
Eugenio Belli
Guest
 
Default Re: Re: Delphi to Xharbour

Il Fri, 29 Aug 2008 02:37:32 -0700 (PDT), J_Rudnicki@wp.pl ha scritto:

I read now your message,
please ignore my previous reply


eugenio.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 10:19 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.