Ariane Soft PPL2 Pocket Programming DataMite
  #1  
Old 02-15-2010, 05:40 PM
veryalien veryalien is offline
Junior Member
 
Join Date: Feb 2010
Posts: 3
Default Sendmessage WM_COPYDATA problems

I am having problems trying to use PPL 1.6.2 to send some text to another wm5 application.

The application is smartwatchm and the api lets you send your own messages to a bluetooth watch by using Sendmessage with WM_COPYDATA.
See here: http://www.smartmadsoft.com/forum/in...rum=1&topic=61

I can get the SendMessage(hnd$,WM_USER,2,0) call to work - the watch displays an icon and vibrates as expected!

Unfortunately the WM_COPYDATA call to send text uses a structure COPYDATASTRUCT and needs pointers to be passed as parameters. I am not sure how to do this in PPL. Sorry but I am a newbie!

COPYDATASTRUCT needs to be something like:

struct COPYDATASTRUCT
{
public int dwData;
public int cbData;
public IntPtr lpData;
}

dwData is a value to pass to the application, I don't think this matters.
cbData is the length of the data to pass to the application.
lpData is a pointer to the data to pass to the application.

So in PPL I am using:

struct (a$, "dwData", tint, "cbData", tint, "lpData", tuint);

I am not sure how pointers translate into the PPL types. Should the IntPtr be a tlong or twide? Is this even possible?

The text that I am trying to send is something like:

txt$="Text2LinesNoScroll:my message";
txtw$=wide(txt$);

I set the fields of the structure as follows:

a.dwData$=0; // I don't think this is important
a.cbData$=(length(txt$)+1)*2; // Is this correct for the wide string length?
a.lpData$=&txtw$; // pointer to the wide string?

I am assuming that a pointer to a wide text string is needed, but I might be wrong.

Then I try to pass the pointer to the structure to the Sendmessage call:

SendMessage(hnd$, WM_COPYDATA, 0, &a$);


So far I have had no luck in making this work. Does the & or addr actually do what I need to pass the pointer in the struct? Do I need to use POKE? Maybe there are too many & and I don't need them, but I've tried different combinations. Can anyone help with any working example code? Perhaps from one PPL app to another PPL app?
Reply With Quote
  #2  
Old 02-15-2010, 10:13 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

you have luck I have found a working solution short time ago, it looks like this:
firstly the code for sending message
PHP Code:
#define COPYDATASTRUCT {"dwData","cbData","lpData"}

struct(cp$,COPYDATASTRUCT);
s$="yes?";
cp.dwData$=s$;
cp.cbData$=sizeof(s$);
cp.lpdata$=&s$;
SendMessage(f$,WM_COPYDATA,null,&cp$); 
and receiving in the target window proc
PHP Code:
WM_COPYDATA:
  
struct(cp$,COPYDATASTRUCT);
  &
cp$=lparam$;
  
a$=cp.lpData$+2;
  
string$="";
  while(
getbyte(a$)>0)
    
string$+=chr(getbyte(a$));
    
a$++;
 
end
I haven't tested this directly in current form maybe you have to tweak it a little here and there, but it should give you the general idea
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:46 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (c) ArianeSoft Inc.
Copyright © 2009 www.ppl-lang.com - All rights reserved
Web Design by BR Web Consulting Ltd