I develop custom widget set from scratch in windows.This widget set controls (except Form control) doesn't have window handle.
Now, I have show default TextBox Context Menu when user right click over TextBox control but I can't find any solution to get default context menu from windows API.
1- Is there way to get default Context Menu of windows TextBox ?
2- Where can I see some example around windows Context Menus ?
Related
I'm working on a personal project where I need to invoke my function after an menu item in another process is clicked.
I'm using
BOOL enumeratingWindowsSucceeded = ::EnumWindows(enumWindowsProc, NULL);
to retrieve the handles to all of the currently open windows on my computer and using
GetSystemMenu(...)
and
AppendMenu(...)
to add an item into all the window's title bar context menu.
Now the problem is when the menu item is clicked in the other window's context menu, my program does not know about it.
Is there a way to override the WindowsProc of another window so that my process can execute some piece of code? Or is there a better way to make the menu item communicate with my program?
Thanks!
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);
I was trying to find an example of creating a settings/configuration windows. The settings window is launched by clicking "Options" action in the menu item. I wanted to figure out how to open up a 2nd window from the main window. As well how the new window return the settings information back to main window. Tried to play around with the QDialog or some inherited dialog classes, but those are for limited uses, not for general setting window. Is there any example/documentation about this?
Have you seen this property browser. Similar to property editor in Qt Designer. qtpropertybrowser Image
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.
Hi I am new to Mac using wxWidget.
I need to add a sub menu and some menu items under the Window Menu on MAC.
I am able to do same for Window menu on PC but not on MAC.
Also, I am not getting event for click on Window Menu to the function attached with EVT_MENU_OPEN event.
Please help.
I don't really understand the question clearly. However you may have to do something like this for a menu on mac.
m_menuBar = new wxMenuBar();
#if defined(__WXMAC__)
m_menuBar->SetAppleMenuItemLabel(wxApp::s_macAboutMenuItemId, wxT("About"));
m_menuBar->SetAppleMenuItemLabel(wxApp::s_macWindowMenuItemId, wxT("Window"));
m_menuBar->SetAppleMenuItemLabel(wxApp::s_macExitMenuItemId, wxT("Quit"));
#endif
where s_macAboutMenuItemId, s_macWindowMenuItemId, s_macExitMenuItemId are your respective menu ids defined.
and regarding not getting event for click on Window Menu to the function attached with EVT_MENU_OPEN event, check if you have correct entries(Menu id, corresponding function name) in the declared event table.