How to check style BS_AUTORADIOBUTTON of button - c++

I want to save properties of controls in a window such as text or checked or etc in WinAPI.
How can i test the button controls that has BS_AUTORADIOBUTTON style (Is it CheckBox or RadioButton )?

You can use GetWindowLong() to get the style of a window:
LONG style = GetWindowLong(hWnd, GWL_STYLE);
if(0 != (style & BS_AUTORADIOBUTTON))
{
// radio button logic here
}

Related

Foregrounding a modeless dialog after it's been backgrounded or minimized (MFC)

I have some code which creates a modeless dialog:
m_ReminderDialog = new CReminderDialog();
m_ReminderDialog->Create(CReminderDialog::IDD, GetDesktopWindow());
m_ReminderDialog->SetForegroundWindow();
Using a dialog template with this style:
STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_APPWINDOW | WS_EX_NOACTIVATE
This works; the dialog window is foregrounded (or flashed).
However, if the dialog window is minimized or put into the background,
m_ReminderDialog->ShowWindow(SW_SHOWNORMAL);
m_ReminderDialog->SetForegroundWindow();
doesn't work to foreground it, unless the main window has been minimized or disabled.
Why, and how to fix it?

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);
})();

MFC: TAB order programmatically for controls

I am using the default CButton and created 3 buttons programmatically..
BOOL CTestDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
CRect rect;
GetClientRect(&rect);
CRect btnRect = CRect(rect.left+50,100,rect.left+150,150);
button1.Create(_T("ONE"),BS_FLAT | WS_VISIBLE,btnRect,this,1);
btnRect.MoveToX(200);
button2.Create(_T("TWO"),BS_FLAT | WS_VISIBLE,btnRect,this,2);
btnRect.MoveToX(350);
button3.Create(_T("THREE"),BS_FLAT | WS_VISIBLE,btnRect,this,3);
return TRUE;
}
If i see the O/P, always the Buton ONE is highlighted and no TAB is working.
How to support TAB order and how to change the focus. Can someone please help.
Thanks
You've created the buttons without the necessary windows styles.
From MSDN:
Apply the following window styles to a button control:
WS_CHILD Always
WS_VISIBLE Usually
WS_DISABLED Rarely
WS_GROUP To group controls
WS_TABSTOP To include the button in the tabbing order

Dialog boxes and event handling in 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);
}

Select element which is extended popup menu (submenu)

Since couple weeks I'm trying to figure out how can I select (choose) item on popup menu which is extended to another popup submenu. For example:
HMENU hMenu,hSubMenu;
hMenu = CreatePopupMenu();
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu , MF_POPUP | MF_STRING | MF_ENABLED, (UINT_PTR) hSubMenu, name.c_str()); // this one i want to select and choose on callback
AppendMenu(hMenu , MF_POPUP | MF_STRING, (UINT_PTR) count, name.c_str());
Than I'm trying to get Callback with: WM_MENUSELECT to catch the name of hover element.
But when I click on this hSubMenu element - menu don't want disappear, but is still active and extends submenu elements.
WM_INITMENUPOPUP will not help.
I just want to close this popup menu when i get message back from WM_MENUSELECT.
WM_LBUTTONUP doesn't work on popup menu...
Could You give me some advice? I'm coding with pure winapi.