Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How the hell!?!?!

Posted on 1998-11-13
5
Medium Priority
?
140 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
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

885 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