Solved

Handle to Object or pointer convertion

Posted on 2004-09-16
4
2,285 Views
Last Modified: 2008-01-09
Hi there,


    Does any one know how to cast a windows handle to an object type (or get the valid pointer)
    of an existing handle. i.e. Say Delphi is open and one wants to get the menu object then access the object in memory to enable or disable menu items via code.
 
   For example the bug that Delphi has with web deployment ?? I want to write a small app to re-activate the object once it's deactivated

 cheerio
0
Comment
Question by:zeroimpact
[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
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 50 total points
ID: 12080137
in the specific case of the Delphi, there's an interface you can use in the ToolsAPI (search for that in your hard Drive)

then, the code to get a handle (actually a MainMenu component) is simple:

var
    FMainMenu: TMainMenu;
begin
  // find Delphi's main menu
  if not (Supports(BorlandIDEServices, INTAServices)) then
    Exit;
  FMainMenu := (BorlandIDEServices as INTAServices).MainMenu;
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12080162
...and I'm not sure, but this probably needs to be inside a (delphi) package
0
 

Expert Comment

by:carlp42
ID: 12612295
If you have the windows handle of a VCL control then you can get a pointer to the control by using FindControl() in the Controls unit.

If you have a window handle for an object that isn't part of a delphi program then I don't think this will work.  Also I don't think this will work to access a control in another process - even if you did get a valid pointer back it would access violate.

Carl
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

631 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