Dialog boxes and event handling in MFC - mfc

I have created a dialog box containing a textbox and a button.
And when the button is pressed , a message box with the textbox content should appear.....but it is not getting displayed.
void dilg::OnBnClickedButton1()
{
CString str;
tx1.GetWindowText(str);
MessageBox(str);
}

Related

Retrieve QMenu of a submenu [duplicate]

I have a list of QActions, some are added to the top level menu and few are added to submenus of top level.
Is there any way to know parent menu name of each actions?
QAction *act;
I'm trying act->parentWidget(). But how can I get menu name from this?
You can check if the result of act->parentWidget() if it is a valid pointer, if so you can manipulate as a normal widget.
To get the menu name, it depends on which widget you are using.
If is QMenu, you can retrieve the menu title via the title function.
QAction *act;
...
QWidget *widget = act->parentWidget();
if (widget) {
QMenu *menu = dynamic_cast<QMenu*>(widget);
menu->title();
}

how to scroll modal window in imacros (slack.com)?

I have the task: get all names members of (myworkspace).slack.com/messages/****/details/ in #general channel.
On this page I click "Members" -> "See all members".
Modal window appears, and Imacros has to scroll this modal window while all members not visible.
(js) But this code dont work:
var modal = window.content.document.getElementById("generic_dialog"); // Modal window with all members
iimPlayCode("URL GOTO=javascript:modal.scrollBy(0, 1000)"); // Scrolling
In case somebody prefers using a bookmarklet to scroll that list:
javascript:(function() {
var scrInt = setInterval(() => {try {document.querySelector("#channel_membership_dialog_scroller").scrollTop += 5000} catch(e) {clearInterval(scrInt)}}, 1500);
})();

Widget focusOutEvent event is called before button press inside widget

I have a class(MyWidget) inherited from QWidget and inside it I created a button and other widget (say W1), Both kept inside QVBoxLayout
On focusOutEvent widget(MyWidget) should hide and it works fine, but when I click the button inside the widget its getting hide but on clicking the widget (W1) inside the layout its not hiding
m_layout = new QVBoxLayout(widget);
m_clearButton = new QPushButton(widget);
m_layout->addWidget(m_clearButton,0,Qt::AlignRight)
// this widget on click main widget is not hiding
m_layout->insertWidget(m_layout->count() -1,item);
Why button click hides MyWidget

Clicking a menu item that contains submenu items makes the submenu items to hide in QML

So my problem is pretty much that when I click on the menu, and then quickly click on the menuItem2 (that contains submenu items), the submenu items will appear for 0.5 seconds and then hide. I have to click again or hover again on the menuItem2 to make the submenu items appear correctly.
The only way to clearly make the submenu items appear is by hovering over menuItem2 without clicking at all.
This is a problem if I want to release my program on a touch screen, since clicking will make the submenu items to hide (the concept of hovering doesn't really work...).
Menu {
id: menu
MenuItem {
text: "menuItem1"
}
Menu{
title: "menuItem2"
MenuItem {
id: subMenuItem1
objectName: "subMenuItem1"
text: "subMenuItem1"
}
MenuItem {
id: subMenuItem2
objectName: "subMenuItem2"
text: "subMenuItem2"
}
}
}
Thank you for any solution to this problem.

SDI-display a dialog via a seleted popup menu item

I have a SDI application and I would like to display a dialog after selecting a popup menu item to call it
My dialog class is defined as:
class Dialog:public CDialogEx
{};
and an added function to view class named OnCallDlg does something as simple as:
void CAppView::OnCallDlg()
{
Dialog d;
d.DoModal();
}
But there is nothing shown up after I choose an item in the popup menu when rightmouse clicking the view.
You have to attach the ID to your dialog using following pattern:
Dialog d(ID_DIG);
d.doModal();