In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Send xHarbour string through window message

Xailer professional forum in English
Responder
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

Send xHarbour string through window message

Mensaje 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
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Send xHarbour string through window message

Mensaje 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
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Send xHarbour string through window message

Mensaje 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
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

Send xHarbour string through window message

Mensaje 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)Â
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

Send xHarbour string through window message

Mensaje 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)Â
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

Send xHarbour string through window message

Mensaje por Oleg »

Jose,
I solved my problem using Windows API functions GlobalAddAtom,
GlobalGetAtomName and GlobalDeleteAtom
for string sending/receiving.
Regards, Oleg
Oleg
Mensajes: 474
Registrado: Mié Jun 07, 2006 3:45 pm

Send xHarbour string through window message

Mensaje por Oleg »

Jose,
I solved my problem using Windows API functions GlobalAddAtom,
GlobalGetAtomName and GlobalDeleteAtom
for string sending/receiving.
Regards, Oleg
Responder