Solved

How the hell!?!?!

Posted on 1998-11-13
5
131 Views
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??

Stu.
0
Comment
Question by:Stuart_Johnson
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
This sounds like an MDI app to me. Why do you want the menu on each form?

Cheers,
Raymond.
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
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.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
Comment Utility
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;

begin
   Inc(WindowTag);
   ImgForm := TForm.Create(Application);
   With TImage.Create(Application) do begin
      Parent := ImgForm;
      Picture.LoadFromFile(ImgList[Sender.Tag]);
      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;
      End;
      Windows1.Add(Mnu);
   End;
End;

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.

Thanks

Stu.
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
Comment Utility
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.

Cheers,

Raymond.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
Comment Utility
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);
MMenu.Merge(ImageViewerMenu);

Thanks to all for you help.

Stuart.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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