mfc CScrollView deactivate - mfc

i wanna make a notepad(windows8)
the notepad`s scrollbar is deactivate(When not needed)
but CScrollView is hide scrollbar(When not needed)
how to change CScrollView's scrollBar like notepad's scrollBar?

Style for multi-line edit control where vertical scroll bar is hidden unless there there is overflow:
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL
For Notepad style:
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN | ES_VSCROLL
When using dialog editor, set the values for Auto VScroll and Vertical Scrollbar, corresponding to ES_AUTOVSCROLL and WS_VSCROLL

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?

css - how to change grid layout without using media query

I'm creating a header for a site, which has several individual items. I'm using css grid and want to avoid using media query for changing the layout when contents don't fit. Having trouble getting the grid setup.
My html structure looks like this:
<header class="container">
<div id="brand">...</div>
<div id="hamburger-menu>...</div>
<nav id="nav1">...</nav>
<nav id="nav2">...</nav>
</header>
Below is my current css code:
#brand { grid-area: brand; }
#hamburger-icon { grid-area: hamburgerIcon; }
#nav1 { grid-area: nav1; }
#nav2 { grid-area: siteNav; }
.container {
display: grid;
grid-template-columns: 450px auto ;
grid-template-rows: auto;
grid-row-gap: 16px;
grid-template-areas:
"brand nav1"
"brand nav2";
}
The above CSS gives me a layout that looks like this:
| brand | nav1 |
| | ---- |
| | nav2 |
This is fine on a larger screen. In my case nav2 is expected to be much longer. So, in smaller screens (not mobile/tablet), the current layout overflows to the right side.
I'd like to have the nav1 and nav2 just flow "under" the brand, but only when necessary. For example, move nav2 to the second row when it doesn't fit anymore.
| brand | nav1 |
| ----- | ---- |
| nav2 |
I know I can probably set the media query and based on screen size change the grid-template-areas but I'm wondering if that's the only way.
This article is really good that shows media query is not necessary, but I'm having trouble applying it in my case.
https://css-tricks.com/look-ma-no-media-queries-responsive-layouts-using-css-grid/
Any suggestions?

How to check style BS_AUTORADIOBUTTON of button

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
}

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

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.