Solved

Handle to Object or pointer convertion

Posted on 2004-09-16
4
2,241 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
  • 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now