News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Send one or more datas

Started by jsz, June 11, 2010, 11:40:58 AM

Previous topic - Next topic

jsz

I wanna send one or more datas in Dialog to another one.
So I have considered about that. (Even when I'm in my school!)

One day I thought of using a return value of DialogBoxParam.
However, some data that I wanna send is one or more values.
a return value of DialogBoxParam can't have one or more values.

Please tell me an idea which can solve this question. :thumbu

clive

Not sure I follow the question totally, but for a Dialog :

You fill your fields/parameters during WM_INITDIALOG, with functions like SetDlgItemInt(), SetDlgItemText(), SendDlgItemMessage(), etc

And you recover the user settings during WM_COMMAND/IDOK, with functions like GetDlgItemInt(), GetDlgItemText(), IsDlgButtonChecked(), etc. And store them away (Registry/Globals/whatever) before calling EndDialog() with the TRUE/FALSE return value from the dialog.
It could be a random act of randomness. Those happen a lot as well.

dedndave

sounds like you could create a variable-sized structure, then pass a pointer to the structure

Slugsnack

you can make a structure and dynamically allocate a block of memory of structure size. fill it in then send a custom message to that other dialog. handling that custom message on the other client reads from that structure ( pointer can be passed in wparam or something ). make sure to use sendmessage so you know when it returns it has used/copied all the data. then you can free that memory. you could also use named pipes which is a nice solution for passing things all the time. for other methods just google interprocess communication

the reason i suggest these methods instead of globals or the method you suggest is because it reduces dependencies and coupling and makes your code a lot more generic, which is a good thing

donkey

Quote from: Slugsnack on June 11, 2010, 11:57:17 PM
you can make a structure and dynamically allocate a block of memory of structure size. fill it in then send a custom message to that other dialog. handling that custom message on the other client reads from that structure ( pointer can be passed in wparam or something ). make sure to use sendmessage so you know when it returns it has used/copied all the data. then you can free that memory. you could also use named pipes which is a nice solution for passing things all the time. for other methods just google interprocess communication

the reason i suggest these methods instead of globals or the method you suggest is because it reduces dependencies and coupling and makes your code a lot more generic, which is a good thing

Kind of a round about way, why not use WM_COPYDATA ? It will marshal the data for you.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hutch--

Unless you need to code to be re-entrant, do yourself a favour and use a GLOBAL, it saves you a collection of messy stack parameters to do something that is basically simple.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: donkey on June 12, 2010, 12:11:56 AM
Kind of a round about way, why not use WM_COPYDATA ? It will marshal the data for you.

Yep. Simple example is in this thread.

If you are interested to see how hilariously complicated that is in "high level languages", see here.

Slugsnack

LOL that message is exactly what i was describing hahahahaha

jj2007

Quote from: Slugsnack on June 12, 2010, 11:23:53 AM
LOL that message is exactly what i was describing hahahahaha

Well, kind of...

Quoteyou can make a structure and dynamically allocate a block of memory of structure size. fill it in
Any pointer to any memory block will do, e.g. chr$("This is the message I want to send") is perfectly valid.

Quotethen send a custom message to that other dialog.
Yes, WM_COPYDATA

Quotehandling that custom message on the other client reads from that structure ( pointer can be passed in wparam or something ).
mov eax, lParam
   mov eax, [eax.COPYDATASTRUCT.lpData]

Quotemake sure to use sendmessage so you know when it returns it has used/copied all the data.
Yes.

Quotethen you can free that memory.
On the server side yes (although you can't "free" a chr$(), obviously), on the client side no:
QuoteThe receiving application should consider the data read-only. The lParam parameter is valid only during the processing of the message. The receiving application should not free the memory referenced by lParam. If the receiving application must access the data after SendMessage returns, it must copy the data into a local buffer.