Solved

Handle to Object or pointer convertion

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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