Solved

Handle to Object or pointer convertion

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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