How the hell!?!?!

Posted on 1998-11-13
Last Modified: 2010-04-04
I have created a form at run time and want to place a main menu on it.  There could be quite a few copies of this same form (the app is an image viewer, and the form contains a large image depicting the image selected by the user).  

The problem is, when the user selects one of the menu items, its not returning the correct form as the owner, but always the main form (where the TMainMenu component was created).

Any ideas??

Question by:Stuart_Johnson
  • 2
  • 2
LVL 12

Expert Comment

ID: 1346773
This sounds like an MDI app to me. Why do you want the menu on each form?

LVL 20

Expert Comment

ID: 1346774
How do you create the copies of your form? Do you create the main menu in your form.Create function?
Perhaps you could give each form a number and write it to the main menus tag property?
If this doesn't help, please give us some code or at least some more informations about your creating logic.

Regards, Madshi.

Author Comment

ID: 1346775
Hi guys,

Its not an MDI application.  Its one main window, and when you double click on a thumb nail, it creates a window with the full image inside it.  

The reason I want a menu on each window is so the user can copy, delete, print or rename the image.

The way I create the form is like this:
procedure TMain.ViewImageInForm(Sender: TImage);
var ImgForm: TForm;
    Mnu: TMenuItem;

   ImgForm := TForm.Create(Application);
   With TImage.Create(Application) do begin
      Parent := ImgForm;
      AutoSize := True;
      ImgForm.Width := Width+8;
      ImgForm.Height := Height+60;
      OnClose := CloseViewWindow;
      Tag := WindowTag;
      Mnu := TMenuItem.Create(Application);
      With Mnu do begin
         Caption := ImgList[Sender.Tag];
         Tag := WindowTag;
         OnClick := SelectWindow;

I can post you the rest of the procedure if you like, but thats how I create it.  The only problem is when I try to add the main menu.


LVL 12

Accepted Solution

rwilson032697 earned 50 total points
ID: 1346776
When the user selects an item from a menu disregard the owner as the indicator of which window the operation should relate to. Instead look at Screen.ActiveForm as this will be the form containing the actual menu that was accessed.



Author Comment

ID: 1346777
Thanks to rwilson.  I now have the active forms name!  Cool.

The way I ended up making the menus work is using this:

MMenu := TMainMenu.Create(ImgForm);

Thanks to all for you help.


Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
calling procedure inside activexForm from secondform 1 248
ddeman not working in activex 3 103
delphi exception 7 64
how to center only a line in richedit? 4 56
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

10 Experts available now in Live!

Get 1:1 Help Now