Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Handle to Object or pointer convertion

Posted on 2004-09-16
4
Medium Priority
?
2,315 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 100 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
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…
Suggested Courses

730 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