Link to home
Start Free TrialLog in
Avatar of Franus
Franus

asked on

Create Buttons, Labels, Forms and other objects in ANOTHER Application

I would like to do somethinig like this :

  h := findwindow(nil, 'Calculator');

  b := tbutton.Create(nil);
  b.ParentWindow := h;
  b.left := 200;
  b.Top := 75;
  b.caption := 'test';
  b.Width := 75;
  b.height := 25;
  b.OnClick := clt; // <-- This procedure doesn't work, it is supposed to do showmessage('blah');
  b.Show;


This doesn't work of course, because button isn't visible, only when i click it it becomes visible but it disapears after i move the mouse over other buttons. I would like to create or should i say inject some control, in this example TButton and put it into another application like Calculator. What i want to do is add an Extra button to some other application like an ADD ON. Please help. I can't get this to work correctly, it keeps dissapearing so please give me some code, i am sure somebody has already done similar thing.....like making holes in other windows :)) ...Thanks in advance..
Avatar of Wim ten Brink
Wim ten Brink
Flag of Netherlands image

In general, this is considered a very bad practice. Besides, you don't have any control over your buttons in the other process. It won't be easy either since you'll have to inject a DLL (that will manage those controls for you) into the address space of the other process, and this DLL must also capture any messages that are sent through the application and capture those that apply to it.
Furthermore, you will need to know very specific information about the windows that you want to modify. You need to know the (Windows) classname to find the correct window that you want to modify. Since these are Windows classes and not Delphi classes (even for Delphi applications!) you would have to dig deep into the Windows API to create the controls that you like to add. Just adding a TButton or TLabel isn't as easy as it seems...

I don't know if anyone here has a good solution here for you but it's definitely not an easy thing...
Avatar of Franus
Franus

ASKER

Thank you for your kind answer. I know this is not a piece of cake as i woudl say :) but to be exact i must create an ADDON for existing application. Imagine for example Calculator window and for example i would like to remove the BACKSPACE Button and put my Button there. So far i can do it but as you said, i cannot attach event handler to my Button OnClick event since it is parented by Calculator and not my Application. Btw Winsight32 is a gift from god application for this. If anyone can just give me a solution for this problem please. You can use the Calculator for example. Here is the task i would like. Create my Button on the calculator window and execute some code when i press it. My application would be invisible, just an icon in system tray and when user clicks on that Button, my application Form would then become visible. I think you understand what i would like to do. I don't need to go deeper into this, this is enough. Just one button.


Thanks
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Franus

ASKER

Thank you for your answer. I solved my problem...well..almost...working in another process is really painful :) but i have a project which requires this so i had to it like this. Once again thanks very much!!!