3,854 questions with C++-related tags

Sort by: Updated
3 answers

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,…

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,435 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-12T15:45:43.4933333+00:00
Nigel Hoult 0 Reputation points
commented 2025-02-13T21:55:27.8866667+00:00
Nigel Hoult 0 Reputation points
0 answers

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) :…

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-13T19:55:45.0833333+00:00
Noah Aas 625 Reputation points
commented 2025-02-13T20:34:34.4466667+00:00
RLWA32 47,196 Reputation points
1 answer

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?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,435 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2022-11-16T13:17:43.917+00:00
Itay Shwartz 1 Reputation point
edited the question 2025-02-13T10:19:47.5366667+00:00
Itay Shwartz 1 Reputation point
2 answers

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…

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,435 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-13T04:21:25.4333333+00:00
Bryan Kelly 401 Reputation points
answered 2025-02-13T08:06:00.7366667+00:00
Minxin Yu 12,676 Reputation points Microsoft Vendor
1 answer

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…

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,735 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-05T01:22:18.9666667+00:00
Geoff Hale 0 Reputation points
commented 2025-02-13T07:05:00.2633333+00:00
Roy Li - MSFT 33,931 Reputation points Microsoft Vendor
1 answer

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…

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,435 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2024-11-13T12:56:41.03+00:00
Andrei Hanganu 0 Reputation points
answered 2025-02-13T04:01:58.5866667+00:00
寿猛 韦 0 Reputation points
1 answer One of the answers was accepted by the question author.

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…

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-11T21:06:58.2866667+00:00
ChuckieAJ 201 Reputation points
accepted 2025-02-12T13:30:35.37+00:00
ChuckieAJ 201 Reputation points
1 answer

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++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-08T14:21:59.67+00:00
ChuckieAJ 201 Reputation points
edited an answer 2025-02-11T14:47:26.4433333+00:00
ChuckieAJ 201 Reputation points
2 answers One of the answers was accepted by the question author.

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…

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,435 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2024-01-08T10:57:35.0433333+00:00
Mohammad Mohsin Siddiqui 175 Reputation points
edited a comment 2025-02-11T09:50:31.2466667+00:00
Hopkins, Piers 0 Reputation points
4 answers One of the answers was accepted by the question author.

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…

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,735 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-03T11:30:25.02+00:00
ChuckieAJ 201 Reputation points
edited the question 2025-02-11T02:58:35.7333333+00:00
Roy Li - MSFT 33,931 Reputation points Microsoft Vendor
1 answer One of the answers was accepted by the question author.

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…

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,735 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-04T11:35:15.4433333+00:00
ChuckieAJ 201 Reputation points
edited the question 2025-02-11T02:58:15.14+00:00
Roy Li - MSFT 33,931 Reputation points Microsoft Vendor
0 answers

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+?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,735 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,733 questions
asked 2025-02-07T02:22:18.55+00:00
lam nguyen 0 Reputation points
commented 2025-02-11T02:18:01.73+00:00
Roy Li - MSFT 33,931 Reputation points Microsoft Vendor
2 answers One of the answers was accepted by the question author.

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,…

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,435 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-07T19:40:00.2266667+00:00
genush 61 Reputation points
commented 2025-02-10T14:08:28.5966667+00:00
genush 61 Reputation points
0 answers

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…

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,435 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-09T13:00:30.7733333+00:00
empeirikos 0 Reputation points
commented 2025-02-10T01:43:38.2433333+00:00
Minxin Yu 12,676 Reputation points Microsoft Vendor
0 answers

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…

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,797 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2024-12-30T21:49:19.45+00:00
CDev-8220 220 Reputation points
commented 2025-02-08T15:27:15.53+00:00
CDev-8220 220 Reputation points
1 answer One of the answers was accepted by the question author.

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…

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-07T14:09:18.95+00:00
ChuckieAJ 201 Reputation points
commented 2025-02-07T17:06:59.4833333+00:00
ChuckieAJ 201 Reputation points
1 answer

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.…

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,735 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-03T03:24:51.68+00:00
szx0427 101 Reputation points
commented 2025-02-06T21:20:04.96+00:00
David Lowndes 2,590 Reputation points MVP
0 answers

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))     …

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-03T10:55:36.34+00:00
Praveena S Kumar 20 Reputation points
commented 2025-02-06T12:47:27.02+00:00
RLWA32 47,196 Reputation points
1 answer

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…

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-06T11:59:28.5666667+00:00
ChuckieAJ 201 Reputation points
answered 2025-02-06T12:05:28.2333333+00:00
ChuckieAJ 201 Reputation points
1 answer One of the answers was accepted by the question author.

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…

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,854 questions
asked 2025-02-04T20:54:38.59+00:00
ChuckieAJ 201 Reputation points
edited a comment 2025-02-06T11:12:46.07+00:00
ChuckieAJ 201 Reputation points