Create C++ GUI project
Windows 11, VS Professional 2019, Version 16.11.44, C++ I want to create a project that starts up with a GUI. Select project template: Windows Desktop Application. The text states: A project for an application with a graphical user interface that runs…
![](https://techprofile.blob.core.windows.net/images/_5e-jRvlCkWlkMrV8cdbJg.png?8D8365)
C++, MFC loop until value is valid or timeout
I am looking for a good way to check a value within a period of time. In principle, the code below works. Are there possibilities with CTime, MFC functions? Why is this written? atlTraceGeneral Is that the TRACE macro? time\timedlg.cpp(186) :…
How to iterate through files on USB device with Visual C++
I'm trying to write a program that will open the root directory of a USB device that appears in Windows Explorer as a file system (specifically, an iPhone) and then iterate through the files on it. I have successfully used SetupDiGetClassDevs,…
fatal error C1069: cannot read compiler
Hi I'm getting this error: fatal error C1069: cannot read compiler what should I do to fix it?
In C++, are global objects guaranteed to exist throughout the execution of a SetConsoleCtrlHandler() callback function?
In C++, are global objects guaranteed to exist throughout the execution of a SetConsoleCtrlHandler() callback function? I'm wondering what would happen if both regular program execution (and the eventual destruction of global variables) and the…
After VS2022 version 17.12.0 update Address Sanitizer no longer works for my C++ project
I've just updated visual studio to the version in the topic and the project which worked ok 5 minutes ago with Asan on (/fsanitize=address) now throws this error when starting the debugger: The procedure entry point __sanitizer_ignore_free_hook____dll…
Adding dark mode to dynamically added sub-menus
I have a CMFCMenuButton on my dialog which is set to the DarkMode_Explorer theme. Therefore, when the dropdown menu part is display it is correctly showing with dark backgrounds. The only caveat is that there is one instance where I load another menu…
Unable to use NM_CUSTOMDRAW for radios / checkboxes in a child CMFCPropertySheet / CMFCPropertyPage
I am trying to add a dark mode theme to derived CMFCPropertySheet class. There are a couple of issues, but I will restrict this to one of them. The problem I have is related to the resolution provided here about rendering checkboxes and…
C++ Code coverage in Visual Studio Professional IDE
We are currently using Visual Studio Professional edition as an IDE for our organization. Recently we came to need to have code coverage for our C++ code base. And we found that there is none support (as far as I could find out) in the professional…
Unable to set my CStatusBar background colour
I am surprised that I can't do this because the File Explorer in Windows 11 has a dark statusbar. So initially I tried: SetWindowTheme(m_wndStatusBar.GetSafeHWnd(), L"DarkMode_Explorer", nullptr); And it did nothing. I then tried: // Set dark…
Drawing Check Box and Radio controls on a CDialogEx for Dark Mode (Win32)
If I switch off the theme for my checkbox / radio controls with: SetWindowTheme(hControl, L" ", L" "); I then get the text colours as I would like, but the actual check / radio symbols are drawn differently: If I don't switch off…
How to apply ROPs (Raster Operation) when drawing with GDI+ and do we need to use ROPs with GDI+?
I am doing drawing image to EMF file using GDI+ however I don't see any function of GDI+ related to ROPs. I understand that GDI+ is designed with object oriented thinking and supports high quality graphics. So do we need ROPs when using GDI+?
change MFC menu text at run-time
I have a MDI MFC project that was converted from VC6 to VS2010. It changes menu text at run-time with this code: CWnd* pMain = AfxGetMainWnd(); if (pMain != NULL) { CMenu* pMenu = pMain->GetMenu(); pMenu->ModifyMenuA(ID_MENU_ITEM,…
Making fmt/chrono.h work in a cuda runtime project
To avoid creating my own errors I copied the following code from fmt. My code only has the cuda runtime headers (which are included automatically whenever a cuda runtime project is created). #include "cuda_runtime.h" #include…
Why do I have problems when trying to import a header unit?
I used VS Developer PowerShell to create a header unit file from a header file. cl /std:c++20 /exportHeader /headerName:quote HeadersBase.h Not sure if that was the right thing to do. Then I created an empty project to see if I can import the header unit…
Unable to use CMFCButton::SelectFont in derived CMFCLinkCtrl class
I have an odd conundrum! The CMFCLinkCtrl class does not expose the font colour properties because it uses GetGlobalData information. That's not OK when using dark mode. Besides, it is a handicap and makes the class less useful. I delved into the source…
Why SetWindowCompositionAttribute makes text also transparent
When I called SetWindowCompositionAttribute to make the main window blurred, text of controls on it also became transparent and thus hard to read. I want to keep the text pure black without transparency while the main window is blurred and transparent.…
Unexpected AfxThrowFileException in CStdioFile::Read()
I am using CStdioFile::Read in an MFC application, and I noticed that an exception is thrown in the following condition: if ((nRead = (UINT)fread(lpBuf, sizeof(BYTE), nCount, m_pStream)) == 0 && !feof(m_pStream)) …
![](https://techprofile.blob.core.windows.net/images/_5e-jRvlCkWlkMrV8cdbJg.png?8D8365)
Custom drawing of a CTreeCtrl to support dark mode and text color properties
I have added a CTreeCtrl to my CDialogEx and mapped it to a CDarkModeTreeCtrl variable. In my dialogs OnInitInstance I set the background colour of the tree control: m_treeCtrl.SetBkColor(DarkModeTools::darkBkControlColor); I would ideally like to set…
Custom drawing of a Group Box in CDialog
I think that this is related to the answer here. I have derived from CFindReplaceDialog in an effort to render it in dark mode: All is well (event the check boxes / radio controls 🤣). But the group box needs attantion. In my own dialogs I was switching…