Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Popup command bars
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Popup command bars

 Post Reply Post Reply
Author
Message Reverse Sort Order
AndyLUK View Drop Down
Newbie
Newbie
Avatar

Joined: 14 February 2022
Location: UK
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndyLUK Quote  Post ReplyReply Direct Link To This Post Topic: Popup command bars
    Posted: 23 February 2022 at 12:04pm
Hi.
I was trying to get a popup menu to appear when clicking on a ReportControl column header.
After much experimenting and reverse engineering of the Codejock Samples I eventually got it to work.
It would be great if there was an introduction document to the use of these controls or a You tube video showing the basics for newbies but hey ho.
Anyway the code below is what I ended up with. I have documented the best I can and maybe it will be of some use to another newbie.
cheers
Andy

 private void wndReportControl_ColumnClick(object sender, AxXtremeReportControl._DReportControlEvents_ColumnClickEvent e)
        {
            //this is if you right click on a column head - see SendContextMenuForWholeHeaderArea property if you want
            //all columns to have the same ColumnClick event
            //MessageBox.Show("col click");
            LaunchPopup();
        }

        private void LaunchPopup()
        {
            //the following "using" statements are required
            //using XtremeReportControl;
            //using XtremeCommandBars;


            CommandBar popupbar;
            CommandBarPopup popup2;
            CommandBarControl control, pu_andy1, pu_andy2;

            //N.B. you can't "new up" a command bar you need a command bar object on your form otherwise you
            //get a "Catastrophic COM failure ..." error when you run it.

            //create the base command bar and add some buttons - the ID class defines a unique number for each button
            //see Codejock samples
            popupbar = axCommandBars1.Add("andy", XTPBarPosition.xtpBarPopup);
            popupbar.Controls.Add(XTPControlType.xtpControlButton, ID.FILE_NEW_FILE, "&New", -1, false);
            popupbar.Controls.Add(XTPControlType.xtpControlButton, ID.FILE_OPEN_FILE, "&Open", -1, false);
            popupbar.Controls.Add(XTPControlType.xtpControlButton, ID.FILE_SAVE, "&Save", -1, false);

            //need to define popup2 as a command bar and cast the control so we can add more controls to it.
            popup2 = (CommandBarPopup)popupbar.Controls.Add(XTPControlType.xtpControlPopup, 9, "sub menu");

            //add controls to the sub menu
            pu_andy1 = popup2.CommandBar.Controls.Add(XTPControlType.xtpControlButton, 901, "andy1", -1, false);
            pu_andy2 = popup2.CommandBar.Controls.Add(XTPControlType.xtpControlButton, 902, "andy2", -1, false);

            //add divider and last control to main menu
            control = popupbar.Controls.Add(XTPControlType.xtpControlButton, ID.FILE_PRINT, "&Print", -1, false);
            control.BeginGroup = true;


            //now setup the icons to use in the commandbar
            //you need an image control on the form
            popupbar.CommandBars.Icons = axImageManager1.Icons;  //using default name of axImageManager1

            //build an array to hold ID values
            int[] CommandBarIconArray = new int[20];

            //load array (ID values are defined in another class and are used to identify each control uniquely)
            CommandBarIconArray[0] = ID.FILE_NEW_FILE;
            CommandBarIconArray[2] = ID.FILE_OPEN_FILE;
            CommandBarIconArray[3] = ID.FILE_SAVE;
            CommandBarIconArray[4] = ID.FILE_SAVE_ALL;
            CommandBarIconArray[5] = ID.FILE_PRINT;

            //load the icons from the Toolbar.png file - see icons folder in codejock samples
            popupbar.CommandBars.Icons.LoadBitmap(ID.IconsPath() + "Toolbar.png", CommandBarIconArray, XtremeCommandBars.XTPImageState.xtpImageNormal);

            //display the popup - by default this is in the middle of the screen but there are coordinate parameters to "ShowPopup()
            popupbar.ShowPopup();
        }

Back to Top
AndyLUK View Drop Down
Newbie
Newbie
Avatar

Joined: 14 February 2022
Location: UK
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndyLUK Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2022 at 3:45pm
Hi.
I am new to codejock and have been struggling to get Popup Command Bars to work in C#.

It compiles OK but when I run the code I get a "Catastrophic COM failure ..."
I've clearly not understood the nuances of calling a Popup.
Can anyone help?
Cheers
Andy

My code is as follows.

private void LaunchPopup()
        {
            CommandBars cmdbars;
            CommandBar popupbar;
            CommandBarControl control;

            cmdbars = new CommandBars();   //This doesn't work and the subsequent line throws the error
            popupbar = cmdbars.Add("Popup", XTPBarPosition.xtpBarPopup);
            popupbar.Controls.Add(XTPControlType.xtpControlButton, 1, "&New", -1, false);
            popupbar.Controls.Add(XTPControlType.xtpControlButton, 2, "&Open", -1, false);
            popupbar.Controls.Add(XTPControlType.xtpControlButton, 3, "&Save", -1, false);

            control = popupbar.Controls.Add(XTPControlType.xtpControlButton, 4, "&Print", -1, false);
            control.BeginGroup = true;

            popupbar.ShowPopup();
        }
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.