Checkboxes in MFC listbox are appearing differently in VS2015 - c++

I have a simple MFC application in VS2010 and I am trying to move this app to VS2015 environment.
I am able to build the project successfully in VS2015. But the checkboxes in the application are appearing different than the VS2010.
I am using CCheckListBox class and create method of CCheckListBox to create the checkboxes. Window style and List Box style used as below while creating checkboxes: { WS_CHILD | WS_BORDER | LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_NOINTEGRALHEIGHT } Also I am using SetCheckStyle method with BS_AUTOCHECKBOX option.
MFC app built with VS2015:
MFC app built with VS2010:
What am I doing wrong here? The code is exactly same.
Is MFC supported in VS2015?

It might not be a "state of the art" fix but I patched this bug with the following line :
SetWindowTheme(m_boards.GetSafeHwnd(), L"Explorer", "L");
In my dialog's OnInitDialog() method where m_board is a member CheckListBox binded to my list box control in the DoDataExchange() method.
You might want to use another theme than Explorer though.

Related

set styles of a CRichEditView

It's been a while since I've done any work with MFC's and I just got handed a project where I need to add a simple console to show logging messages received by the application. I decided to use a RichEditView because I want to be able to format and color the received messages.
I have been banging my head all day trying to set ES_AUTOHSCROLL and ES_AUTOVSCROLL in my CRichEditView and I just can't get it to work...
I derived a class from CRichEditView called CConsoleView and in CConsolesView::PreCreateWindows I set the style to
- ES_READONLY | ES_MULTILINE | ES_WANTRETURN | ES_AUTOHSCROLL | ES_AUTOVSCROLL
but this didn't work as expected.
OK... nothing wrong with going back to basics so I've tried this in a simple MFC wizard and it worked and I was expecting this to work in my app as well.
From http://msdn.microsoft.com/en-us/library/windows/desktop/bb775464(v=vs.85).aspx I know that autoscroll can't be changed after the object creation so I guess my object is being created before I call get the call to PreCreateWindow...
Can I force the style in my CConsoleView constructor?
When/where is (generic question) the CRichEditView::Create() method being called? shouldn't it be called after PreCreateWindow?
Besides attaching a new object is there any way to get around this?
Any help would be appreciated!
Cheers
If you're using the control in a dialog template, just add the create flags to the resource file that's declaring the control in dialog. If you're dynamically creating the control, you'd be doing the Create... unless you're doing MDI (which doesn't seem to fit based on your description).

Implementing notification dialogs that don't steal focus from full-screen apps?

I want to implement a notification window by subclassing QDialog. It should be on top of other windows, but I don't want it to steal focus from other windows for obvious reasons. I'm also concerned that it would interfere with full-screen applications like videos and games.
How do I go about implementing this? Are there any common programming and UX practices I might want to know about?
It appears quite an old topic. However, I did not see anyone posting a proper answer that just works, so I am posting my solution to the same problem I have been facing recently.
First of all, if you want your dialog not to steal focus from other dialogs or input fields, you should set the following property: Qt::WA_ShowWithoutActivating. Using this property, window (dialog is also a window) will be shown without being activated. Then, probably you will want to customize your dialog to your needs, and you will want this dialog to be shown on top. So, the following Window flags can be set in order to achieve such a result in a cross-platform manner: Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::X11BypassWindowManagerHint | Qt::Tool | Qt::WindowStaysOnTopHint | Qt::WindowTransparentForInput | Qt::WindowDoesNotAcceptFocus.
The code below is one of the examples to achieve a dialog that is modeless, and does not steal focus from anyone (assuming dialog is a variable pointing to the valid instance of QDialog):
dialog->setAttribute(Qt::WA_ShowWithoutActivating, true);
dialog->setWindowFlags(dialog.windowFlags() | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::X11BypassWindowManagerHint | Qt::Tool | Qt::WindowStaysOnTopHint | Qt::WindowTransparentForInput | Qt::WindowDoesNotAcceptFocus);
Haven't tried it but it looks like
my_dialog->setWindowFlags(Qt::CustomizeWindowFlags | ... | Qt::WindowStaysOnTopHint);
should work, in conjunction with making it modeless.
First of all you need to create a non modal dialog:
A modeless dialog is a dialog that operates independently of other
windows in the same application. Find and replace dialogs in
word-processors are often modeless to allow the user to interact with
both the application's main window and with the dialog.
In order to achive that you need to call the show function and not the exec one.

Scrollbar Appearance Control in Windows 7

I have an application that has a ListView control with scrollbars, and it has the cool looking scrollbars in it automatically:
CreateWindowExW(WS_EX_WINDOWEDGE,L"SysListView32",L"MyList",
WS_CHILD|WS_VISIBLE|LVS_NOSCROLL|LVS_REPORT|LVS_NOCOLUMNHEADER|WS_VSCROLL|LVS_SHOWSELALWAYS| LVS_SINGLESEL,
0,0,500,290,ownerhWnd, (HMENU)0,hInst,NULL);
However, when I create a Scrollbar control manually for another part of the application, it has the older 3d-style look:
CreateWindow(TEXT("SCROLLBAR"), TEXT("MyScrollBar"),
WS_CHILD | WS_VISIBLE | SBS_VERT,0,0, CW_USEDEFAULT,
100, ownerhWnd, (HMENU)10 , NULL, NULL);
How do I get it to have the new look? Is there another control I use, or a style that I can apply to the standard control? I looked into the Flat Scroll Bar, however it says that it is not supported from XP onwards?
Thanks
First, you need to create a manifest for your program that indicates it uses Common Controls version 6. Then you have to call InitCommonControls at program startup.
Details are found on this Microsoft page:
http://msdn.microsoft.com/en-us/library/bb773175%28v=vs.85%29.aspx
Maybe an open door, but you have added a Windows XP/Vista/7 manifest to your application's resources?

MFC Wizard Appearance

I have a MFC wizard based application (CPropertySheet, CPropertyPage) created with vS2008. I am trying to give my app which is nearly completed a more modern look. I looked into CDHTMLDIalog but it looks like a lot of work and not too well documented. Next I thought I could use some of the features of the Feature Pack. I found a thread about this link text but have added the code mentioned in the thread to various places in my app but the appearance never changes.
CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver);
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));
CDockingManager::SetDockingMode(DT_SMART);
RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE);
Have also replaced CPropertySheet with CMFCPropertySheet & CPropertyPage with CMFCPropertyPage
Thanks...
Define 'give my app more modern look'. I'm assuming you're not talking XP-style common controls here, but a different wizard layout. Do you want a header/banner graphic at the top or left side of your wizard? Look at the configuration parameters for the property sheet in m_psh.dwFlags : PSH_WIZARD97, PSH_WATERMARK, PSH_HEADER, ...
If you're talking about using the modern Office-style 'skins' for your wizard (Feature Pack style), you're out of luck. Can't do that for dialogs with the Feature Pack. Look into BCG Controls - it'll cost money but it's more up to date and you get extra features.
If it's something completely different what you want, please post mockups of what it should look like, and/or a screenshot of what it looks like now and what you don't like about it.
You should have:
CWinApp replaced with CWinAppEx in your main program file;
The Windows Common Controls 6.0 manifest implemented (either a RT_MANIFEST resource or a #pragma entry in your stdafx.h)
The code below at the beginning of the InitInstance() method (this code should have been added in the New Project wizard):
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);

CComboBox automatically selects text after call to MoveWindow

I'm currently experiencing a very strange problem with a CComboBox used within a CFormView.
After adding strings to the combobox (created with WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_SORT | CBS_AUTOHSCROLL), I'm selecting an entry via CComboBox::SetCurSel and resize the combobox via MoveWindow in the OnSize() handler of the CFormView derived class.
As soon as I include the call to MoveWindow, the whole text in the edit part of the combobox gets selected. If I remove the call to MoveWindow, the text doesn't get selected. This happens not only for one, but for all comboboxes used.
I'm somehow lost at this point. Any hint is much appreciated!
Selecting all the text is standard Windows behavior when a combo box gets focus. I guess the MoveWindow is resetting the focus on the control.
Try using CComboBox::SetEditSel to remove the selection after MoveWindow.