Página 1 de 1
Send xHarbour string through window message
Publicado: Vie May 23, 2008 2:06 pm
por Oleg
Dear developers!
Can you help me? I need to pass a xHarbour string from one Xailer
application to another through window message.
I send message with this code:
...
SendMessage(hAnotherAppWnd, WM_USER+55, 0, chr2ptr(cStr))
...
XA_FUNC( CHR2PTR )
{
hb_retnl( (long) hb_parc(1) );
}
I receive this message with this code:
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TSample
if nMsg==WM_USER+55
::oStatusBar:aItems[1]:cText:=chr2ptr(nLParam)
::oStatusBar:aItems[2]:cText:=str(nWParam,3,0)+'%'
return 1
endif
return NIL
.....
XA_FUNC( CHR2PTR )
{
char far * buf;
buf = (char *) hb_parnl(1);
hb_retcAdopt( hb_strdup(buf ) );
}
The message is catched by HandleEvent but chr2ptr returns garbage.
Regards, Oleg
Send xHarbour string through window message
Publicado: Vie May 23, 2008 2:39 pm
por jfgimenez
Oleg,
> Can you help me? I need to pass a xHarbour string from one Xailer
> application to another through window message.
There are some restrictions in sending messages from a process to another
one, and I'm not sure where the problem could be. Please, send me a little
sample to review it.
> hb_retcAdopt( hb_strdup(buf ) );
You can safety replace it by:
hb_retc( bug );
since hb_retc() gets a copy of the string.
--
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
Send xHarbour string through window message
Publicado: Vie May 23, 2008 2:39 pm
por jfgimenez
Oleg,
> Can you help me? I need to pass a xHarbour string from one Xailer
> application to another through window message.
There are some restrictions in sending messages from a process to another
one, and I'm not sure where the problem could be. Please, send me a little
sample to review it.
> hb_retcAdopt( hb_strdup(buf ) );
You can safety replace it by:
hb_retc( bug );
since hb_retc() gets a copy of the string.
--
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
Send xHarbour string through window message
Publicado: Vie May 23, 2008 8:19 pm
por Oleg
Jose,
> There are some restrictions in sending messages from a process to another
> one, and I'm not sure where the problem could be. Please, send me a little
> sample to review it.
Thank you for your help.
Send you 2 projects: test74.zip (send message) and install.zip (receive
message)
Compile project from test74.zip. Compile project from install.zip. Place
test74.exe to directory where install.exe placed.
Run install.exe and see the code in HandleEvent method (comment 'garbage
here').
Regards, Oleg
Attached files install.zip (2.5 KB)Â test74.zip (2.1 KB)Â
Send xHarbour string through window message
Publicado: Vie May 23, 2008 8:19 pm
por Oleg
Jose,
> There are some restrictions in sending messages from a process to another
> one, and I'm not sure where the problem could be. Please, send me a little
> sample to review it.
Thank you for your help.
Send you 2 projects: test74.zip (send message) and install.zip (receive
message)
Compile project from test74.zip. Compile project from install.zip. Place
test74.exe to directory where install.exe placed.
Run install.exe and see the code in HandleEvent method (comment 'garbage
here').
Regards, Oleg
Attached files install.zip (2.5 KB)Â test74.zip (2.1 KB)Â
Send xHarbour string through window message
Publicado: Vie May 23, 2008 8:44 pm
por Oleg
Jose,
I solved my problem using Windows API functions GlobalAddAtom,
GlobalGetAtomName and GlobalDeleteAtom
for string sending/receiving.
Regards, Oleg
Send xHarbour string through window message
Publicado: Vie May 23, 2008 8:44 pm
por Oleg
Jose,
I solved my problem using Windows API functions GlobalAddAtom,
GlobalGetAtomName and GlobalDeleteAtom
for string sending/receiving.
Regards, Oleg