troubleshooting Question

Building a Popup Menu Array

Avatar of pwken
pwken asked on
Editors IDEs
16 Comments1 Solution750 ViewsLast Modified:
I have an array of TEdit boxes that are dynamically build at run time. I want to be able to right click in each edit box to assign two values to be associated with each edit box. I tried a popup menu but that was not specific to a particular edit box, so I decided to attempt to build an array of popup menus specific to each edit box. Not sure if this is the best way to do this and I can't get it to work. Any help would be appreciated.

TEdit* edtBlade[75];
TPopupMenu* PopupMenu[75];
TMenuItem* mnuPyroBlade;
TMenuItem* mnuMarkerBlade;
TMenuItem* mnuClose;


__fastcall TfrmWheelChartInput::TfrmWheelChartInput(TComponent* Owner)
    : TForm(Owner)
{
    for(int i = 0; i < 75; i++)
    {
        PopupMenu[i] = new TPopupMenu(grpBladeSet);
        PopupMenu[i]->Name = "PopMenu" + IntToStr(i);
        mnuPyroBlade = new TMenuItem(PopupMenu[i]);
        mnuMarkerBlade = new TMenuItem(PopupMenu[i]);
        mnuClose = new TMenuItem(PopupMenu[i]);
        PopupMenu[i]->Items->Add(mnuPyroBlade);
        PopupMenu[i]->Items->Add(mnuMarkerBlade);
        PopupMenu[i]->Items->Add(mnuClose);
    }
   
    int verticaloffset, horizontaloffset;
   
    //Create the blade input boxes dynamically and assign to an array

    for(int i = 0; i < 75; i++)
    {
        if (i < 15)//Create the first column
        {
            verticaloffset = 0;
            horizontaloffset = 0;
        }
        else if (i > 14 & i <30) //Create the second column
        {
            verticaloffset = 15;
            horizontaloffset = 120;
        }
        else if (i > 29 & i <45) //Create the third column
        {
            verticaloffset = 30;
            horizontaloffset = 240;
        }
        else if (i > 44 & i <60) //Create the fourth column
        {
            verticaloffset = 45;
            horizontaloffset = 360;
        }
        else if (i > 59 & i <75) //Create the 5th column
        {
            verticaloffset = 60;
            horizontaloffset = 480;
        }

        // Set the group box grpBladeSet as the owner of the Tedit boxes
        edtBlade[i] = new TEdit(grpBladeSet);
        edtBlade[i]->Name = "edtBld" + IntToStr(i);
        edtBlade[i]->Parent = grpBladeSet;
        edtBlade[i]->Top = 25 + ((i-verticaloffset) * verticalspace);
        edtBlade[i]->Left = 80 + horizontaloffset;
        edtBlade[i]->Width = 33;
        edtBlade[i]->MaxLength = 2;
        edtBlade[i]->Height = 24;
        edtBlade[i]->Font->Size = 10;
        edtBlade[i]->Text = IntToStr(i);
        edtBlade[i]->PopupMenu = PopupMenu[i];
    }
}
ASKER CERTIFIED SOLUTION
kodiakbear

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros