BBC BASIC for Windows
« WM_COPYDATA »

Welcome Guest. Please Login or Register.
Apr 6th, 2018, 12:06am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: WM_COPYDATA  (Read 2818 times)
admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: WM_COPYDATA
« Reply #5 on: Sep 8th, 2011, 1:13pm »

on Sep 8th, 2011, 12:15pm, Nick wrote:
How do I pass the 'pointer' contained in the lparam to my structure?

You have to use this piece of BB4W 'magic':

Code:
      !(^cds{}+4) = lparam% 

What this does is to change the structure's data pointer so that it points to the data in the received message.

Richard.
User IP Logged

Nick
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 33
xx Re: WM_COPYDATA
« Reply #6 on: Sep 8th, 2011, 1:37pm »

on Sep 8th, 2011, 1:13pm, Richard Russell wrote:
You have to use this piece of BB4W 'magic':


That makes a lot of sense now. - thank you.

So like this?:

DEF FN_copydata(m%,w%,l%)
REM This has to be fast - just get the data and return
REM m% is the WM_COPYDATA value (74)
REM w% is sender handle
REM l% points to COPYDATASTRUCT
DIM RECEIVED_COPYDATA{dw%,cb%,lpdata%}
!(^RECEIVED_COPYDATA{}+4) = l%
return_value%=97 REM arbitrary choice!
= return_value%


(this is my FN that handles the subclassed COPYDATA message)

And: will it need similar 'magic' on the sending function?

SYS "SendMessage", target_hwnd%, WM_COPYDATA, @hwnd%, COPYDATASTRUCT {} ?

Nick
« Last Edit: Sep 8th, 2011, 3:09pm by Nick » User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: WM_COPYDATA
« Reply #7 on: Sep 8th, 2011, 4:07pm »

on Sep 8th, 2011, 1:37pm, Nick wrote:
So like this?

Bear in mind that, as a rule, any pointers sent in a message are only valid until the receiving end returns. So make sure you do everything you need with the values contained in the COPYDATASTRUCT before the '= return_value%'. Arguably you would be better off making it a LOCAL structure rather than a Global structure, to guarantee this.

Quote:
return_value%=97 REM arbitrary choice!
= return_value%

MSDN says you should return TRUE (=1), so it's not really an "arbitrary choice".

Richard.
User IP Logged

Nick
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 33
xx Re: WM_COPYDATA
« Reply #8 on: Sep 8th, 2011, 4:33pm »

on Sep 8th, 2011, 4:07pm, Richard Russell wrote:
Bear in mind that, as a rule, any pointers sent in a message are only valid until the receiving end returns.


Yes, I was going to add that once the IPC bit of it was working properly.

Unfortunately mine still doesn't work. Does the COPYDATA statement at the sending end need similar 'magic'?

At present:

SYS "SendMessage", target_hwnd%, WM_COPYDATA, @hwnd%, COPYDATASTRUCT {}

Thanks Nick


User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: WM_COPYDATA
« Reply #9 on: Sep 8th, 2011, 9:34pm »

on Sep 8th, 2011, 4:33pm, Nick wrote:
At present:
SYS "SendMessage", target_hwnd%, WM_COPYDATA, @hwnd%, COPYDATASTRUCT {}

That looks OK to me (except that there's a space between COPYDATASTRUCT and the opening brace, which isn't allowed). Anyway, you said your receiving application was seeing the message successfully so it must be working.

Incidentally, I presume you realise that COPYDATASTRUCT is the name of the generic structure; typically not of a particular instantiation (of which there could be several in a program). Although there's nothing stopping you calling your structure that, I would normally use a more succinct name such as cds{}.

Richard.
User IP Logged

Nick
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 33
xx Re: WM_COPYDATA
« Reply #10 on: Sep 10th, 2011, 05:30am »

on Sep 8th, 2011, 9:34pm, Richard Russell wrote:
That looks OK to me (except that there's a space between COPYDATASTRUCT and the opening brace, which isn't allowed). Anyway, you said your receiving application was seeing the message successfully so it must be working.


Yes, after some tidying up, it works nicely.

Quote:
Incidentally, I presume you realise that COPYDATASTRUCT is the name of the generic structure; typically not of a particular instantiation


Yes, I did. I have it like this while authoring - it helps me to see more clearly which variable is what.

Thanks again - your help is much appreciated.

Nick
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls