Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Send message to the external application control

Posted on 2000-03-16
9
Medium Priority
?
519 Views
Last Modified: 2013-12-03
I have tried to send message to the TreeView control to the some external application control. It works fine for messages like TVM_GETNEXTITEM, TVM_SELECTITEM, but it failed for TVM_GETITEM call! The difference is, as I can see it, the TVM_GETITEM need to fill some structure which address I pass as LPARAM SendMessage() call. I get the FALSE as SendMessage(hTV, TVM_GETITEM, 0, &TVItem). Any suggesions? Thanks.
0
Comment
Question by:abondar
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 800 total points
ID: 2625799
The problem is that treeview is in the different address space.

3 ways possible:

1)If another application is written by you, send WM_COPYDATA message with the item text from that app to your first application where you need the item text.

2)Install the windows hook (SetWindowHookEx, for example WH_GETMESSAGE) on the treeview thread (use GetWindowThreadProcessId). You must get an item text inside the hook proc (which resides in a hook dll). It  works because the hook procedure is in the address space of another process.

3) No documented way for 95/98.
For NT/2000:
Alloc memory in the another process's address space using pMem=VirtualAllocEx. Place TVITEM inside pMem using WriteProcessMemory.
Then call SendMessage(hTV,TVM_GETITEM,hTv, pMem). Then use ReadProcessMemory to get result.

Choose the way and ask about details.



0
 
LVL 20

Expert Comment

by:Madshi
ID: 2626905
Good answer, Nick...  :-)

abondar, if you choose (3), then you might be interested in the following (undocumented) functions which allocate memory in another process under all win9x systems (well, the functions in reality allocate memory in shared memory, but that doesn't matter):

function SharedMem9x_Alloc   (              size: cardinal) : pointer;  stdcall; external 'comCtl32.dll' index 71;
function SharedMem9x_ReAlloc (ptr: pointer; size: cardinal) : pointer;  stdcall; external 'comCtl32.dll' index 72;
function SharedMem9x_Free    (ptr: pointer                ) : bool;     stdcall; external 'comCtl32.dll' index 73;
function SharedMem9x_GetSize (ptr: pointer                ) : cardinal; stdcall; external 'comCtl32.dll' index 74;

These functions are also exported from the winNT comCtl32.dll, but there they just point to LocalAlloc or something like that. So under winNT you have to use VirtualAllocEx, like Nick suggested.

Regards, Madshi.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2627364
Useful info, Madshi.
Will save it to use in future answers :)
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 20

Expert Comment

by:Madshi
ID: 2627393
:-)  Got it from this good site:

http://www.geocities.com/SiliconValley/4942/index.html
0
 

Author Comment

by:abondar
ID: 2627403
Hi Madshi!
I have not found these undocumented functions in comctl32.dll... Where they are??

Thanks,
 Anton.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2627409
It seems that they are exported by ordinal number.

For example, for SharedMem9x_Alloc:
GetProcAddress(hLib,LPCTSTR(71));
0
 

Author Comment

by:abondar
ID: 2627439
Hi Madshi!
I have not found these undocumented functions in comctl32.dll... Where they are??

Thanks,
 Anton.
0
 

Author Comment

by:abondar
ID: 2627441
Ahh... Ok, thanks!

Anton
0
 

Author Comment

by:abondar
ID: 2627481
Ahh... Ok, thanks!

Anton
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

604 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