?
Solved

Sending text to program.

Posted on 2003-11-11
7
Medium Priority
?
306 Views
Last Modified: 2010-04-05
Hey.

I use this line to send a char to a program.

PostMessage(hApp, WM_USER + 1678, Ord(AryChar[0]), 0);

Any idea how you send text to a program, since I can only use integers with this.

Thanks.
0
Comment
Question by:JuiciJJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9724558
To interprocess communications you can use:
1. Memory mapped files
2. Pipes
3. TCP/IP, UDP
4. Dll with shared segment
0
 
LVL 6

Expert Comment

by:DaFox
ID: 9724567
Hi,

PostMessage(..., Integer(PChar(str)), 0);

Markus
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 9724575
.... send lots of chars, one after another?

You can't directly send a string, since the memory for that string would be in the wrong application. The message passing mechanism only has space for a couple of integers or pointers, so you just can't. Alternative is to use some other inter-process mechanism like pipes, or shared memory, or RPC or COM or something.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:andrewjb
ID: 9724580
DaFox - don't think that'll work.
0
 
LVL 6

Expert Comment

by:DaFox
ID: 9724632
You're right - passing pointers does only work inside your own process. Silly me... Sorry!!
0
 
LVL 8

Accepted Solution

by:
gmayo earned 500 total points
ID: 9724635
One way is to use a hidden edit box on the other app and use that to send the text. You can even "press" a button to indicate to the other app that the text is there!

procedure SetWindowTextEx(win : HWND; text : string);
var
      res : DWORD;
begin
      SendMessageTimeout(win, WM_SETTEXT, 0, Integer(@text[1]), 0, 1000, res);
end;

Get the handle of the edit box (using FindWindow and/or EnumChildWindows) and pass that to the above function along with the text you wish to pass.

Geoff M.
0
 
LVL 3

Expert Comment

by:BJThomsen
ID: 9725181
type

TCopyDataStruct = record
  dwData: LongInt; // User Defined Data Param
  cbData: LongInt; // Length of data pointed to by lpData
  lpData: Pointer;
end;

TRecToPass = packed record
  s: string[255];
end;

procedure SendAString;
var
  Msg: TCopyDataStruct;
  Rec: TRecToPass;
Begin
  Rec.s := 'Hi There I'm a String';


  Msg.dwData := 0; // User Defined
  Msg.cbData :=  sizeof(Rec) // Size of data pointed to
  Msg.lpData := @Rec
  SendMessage (hApp, WM_COPYDATA,  WPARAM (Application.Handle), LPARAM (@Msg));

end;
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question