Create dynamic menu Windev with buttons - desktop

I'm working in windev and I made a dynamic Menu using the menu control from information in my anylisis, now I'm trying to achieve the same using buttons in a ribbon, or just buttons but got stuck when creating the submenus for these buttons.

In the description of a button you can attach a menu to it. You can always edit the menu dynamically. Is it what you're looking for ?
Attach a menu to a button

Related

How to insert more dialogs in MFC Dialog application?

I am trying to build an MFC application Dialog based application. It runs ok. But I need to insert another Dialog. So how can I for example, pressing on a button from the first dialog to open the new added dialog?.
I am using Microsoft Visual Studio 2015.
I right clicked on the resources folder and insert a dialog.
It is inserted, but how to create it?.
Thank you.
The easiest way is: I consider you are creating a Dialog based application so you get a main Dialog box and an About Dialog box when Selecting menu->About.
To add Another Dialog to your application:
1- Right click on the solution explorer on the resources files and select Add->Resource->Dialog->New
You get a new Dialog right front of you. Right click on this Dialog and select Add Class. give it for example a name like "MyDlg2" and click ok.
You'll see two files added: MyDlg2.h and MyDlg2.cpp.
Now How to Popup this second dialog (MyDlg2)? Let's create a button on the main Dialog:
Drag a button onto Main Dialog.
Give it a caption "Gong to Dialog2..."
Double-click this button to add a handler for it.
In this handler enter:
MyDlg2 dlg;
dlg.DoModal();
Scroll to the top of this file and add:
#include "MyDlg2.h"
This is important so that main Dialog knows How to create dialog 2.
Build and run.
You need to derive a class from CDialog.
For more information check this MSDN example.

Embedding dialogs in main dialog and switching them with button click in MFC

I have a design like below:
So basically, I want to embed three dialogs in the application main dialog and switch between them, for each button click i.e., button 1 will show dialog one , button 2 will hide dialog 1 and show dialog 2 .. and so on.
Each dialog will be having a different design and functions.
I tried using CPropertySheet class to Add pages but its GUI is different. It has either option for navigating the dialogs using next / back button , or from a tab control.
None of which is as per my requirement.
So I want to know is it possible to have a design like this in MFC ? If yes how? Which Class/ control should I use.
Any help will be appreciated.
What you can do is use a normal CDialog class, add your buttons to it and also create a frame/rect as a placeholder for where your embedded dialogs are to appear. The following piece of code will create and position your embedded dialog.
CRect rect;
CWnd *pHost = GetDlgItem(ID_OF_YOUR_FRAME_RECT);
pHost->GetWindowRect(&rect);
ScreenToClient(&rect);
pDialog->Create(ID_OF_YOUR_DIALOG, this);
pDialog->MoveWindow(&rect);
pDialog->ShowWindow(SW_SHOW);
On button clicks, you hide the previously shown dialog (SW_HIDE) and show your selected dialog(SW_SHOW) with ShowWindow(...).
If you create your embedded dialogs with IDD_FORMVIEW style in the add resource editor it'll have the proper styles for embedding.
Another option is probably to use an embedded PropertySheet and hide the tab row and programatically change the tabs on the button clicks. I just find it to be too much fuzz with borders, positioning, validation and such for my liking.
If you have the MFC Feature Pack, that first came with VS2008 SP1 and is in all later versions, you might like to consider CMFCPropertySheet. There are a number of examples on the linked page, that are very similar to your design.
For example, this:
What worked for me just using dialog based application is SetParent() method. Dont know why nobody mentioned it. It seems to work fine.
I am doing like below:
VERIFY(pDlg1.Create(PanelDlg::IDD, this));
VERIFY(pDlg2.Create(PanelDlg2::IDD, this));
VERIFY(pDlg3.Create(PanelDlg2::IDD, this));
::SetParent(pDlg1.GetSafeHwnd(), this->m_hWnd);
::SetParent(pDlg2.GetSafeHwnd(), this->m_hWnd);
::SetParent(pDlg3.GetSafeHwnd(), this->m_hWnd);
Now I can show or hide a child dialog at will (button clicks) as below:
pDlg1.ShowWindow(SW_SHOW);
pDlg2.ShowWindow(SW_HIDE);
pDlg3.ShowWindow(SW_HIDE);

System Tray Menu error MFC

I am Making an Application which will make a dialog as system tray icon after some button press. it is working fine but also i need to open the menu same as dialog contains on Right Click and have written following Code:
CMenu pMenu;
pMenu.LoadMenu(IDR_MENU1);
POINT pointCursor;
::GetCursorPos( &pointCursor );
pMenu.TrackPopupMenu(TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, pointCursor.x, pointCursor.y, this);
It is Creating the menu but the width of the menu is very thin as shown following:(Yellow highlighted area is menu)
if I add only first submenu of main menu then it works well as following code:
CMenu *pMenu = GetMenu();
POINT pointCursor;
CMenu *pMenu = GetMenu();
::GetCursorPos( &pointCursor );
pMenu->GetSubMenu(0)->TrackPopupMenu(TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,pointCursor.x,pointCursor.y,this);
On applying this code i get following output
Actually I need the Following menu:
Kindly Suggest Where i am doing it wrong
TrackPopupMenu cannot display the menu bar as part of it's work. The menu bar itself is not displayed because TrackPopupMenu requires a handle to a menu, submenu, or shortcut menu. So, given that, if you really want the same menu structure including the menu bar you've shown, you'll need to create that structure dynamically using CMenu methods. Or, simply create a new menu resource with a different name that includes the menu bar items as submenus.

How to add a menu item dynamically with an image in MFC featurepack

In MFC featurepack i create a standard menu and set the ID of sub menu to the same command of toolbar button to take that button's image that toolbar is the one sent to this method
CMFCToolBar::AddToolBarForImageCollection
and also I use the
GetContextMenuManager()->AddMenu(L"Mymenu", IDR_ContextMenu1);
in the application and
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_ContextMenu1,rect.left,rect.top,button);
in the show menu event
I need to know how to add a menu item with a specified icon at the run-time dynamically
See the documentation about OnInitMenuPopup of your CMainFrame.

Creating popup menu in Qt for QTableView

I have a QTableView in the main UI of my program. I'd like to show popup menu when user right clicks on the cells of the table and take appropriate action when an option is selected from the menu.
I am using Qt Creator 1 (Qt version 4.5). How can I do that?
Check out the customContextMenuRequested signal to get the event, and use a QMenu for the menu itself. Use QTableView::indexAt to find out what, if any, cell was clicked based on the coordinates given to the signal and take the appropriate action when a menu item is clicked.