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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IExtractImage Delphi 14 201
Strange code, can use it, but i cant figure out what it does. 3 54
Delphi cmd execution 6 55
find a node in VST 2 63
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

25 Experts available now in Live!

Get 1:1 Help Now