?
Solved

How the hell!?!?!

Posted on 1998-11-13
5
Medium Priority
?
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1346773
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
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.
0
 
LVL 6

Author Comment

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

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 150 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.

Cheers,

Raymond.
0
 
LVL 6

Author Comment

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

Thanks to all for you help.

Stuart.
0

Featured Post

Independent Software Vendors: 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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

752 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