Thursday, December 31, 2020

MSIX Tutorial: A comprehensive 24-chapter guide

MSIX Tutorial: A comprehensive 24-chapter guide

  1. MSIX Tutorial: A comprehensive 24-chapter guide
  2. Prepare to package a desktop application
  3. Advanced Installer 17.7 Release Notes
  4. Mitigate the security doubts and provide trust and warranty to users by adding an extra step to your application packaging process with Digital Signing.

    Advanced Installer 17.7 enables you to use Device Guard Signing Service(DGSS) v2 to better manage code signing certificates and sign your packages, guaranteeing that your application comes from a trusted source.

    Take a look at the following video to see how easily you can enable digital signing using DGSS v2 from Advanced Installer.

  5. Digital Signatures

Friday, December 25, 2020

Error C3646 'CHAR': unknown override specifier autoaero c:\program files (x86)\windows kits\10\include\10.0.18362.0\um\minwinbase.h

Error C3646 'CHAR': unknown override specifier autoaero c:\program files (x86)\windows kits\10\include\10.0.18362.0\um\minwinbase.h

  1. c++ - error C3646: unknown override specifier
  2. Replacing text macros
  3. Adding or Retrofitting Aero Glass into Legacy Windows Applications
  4. too complicated to use.

  5. All About MFC Serialization
  6. A Serialization Primer - Part 1
  7. A Serialization Primer - Part 2
  8. A Serialization Primer - Part 3

Error C1189 #error: MFC does not support WINVER less than 0x0501. Please change the definition of WINVER in your project properties or precompiled header.

When I compiled this project, I ran into this error:

Error C1189 #error: MFC does not support WINVER less than 0x0501. Please change the definition of WINVER in your project properties or precompiled header.

it is old message, but we can have new solution or fix:

I redefined these macro in stdafx.h, but forgot to remove old ones below it. so old ones are still valid. remove the old one, then everything is good: error message disappeared:)

  1. MFC does not support WINVER less than 0x0501
  2. I had a similar problem, and no amount of #define fixed it. Turns out, in Visual Studio 2013, if you right click on your project, select properties, then in the options Configuration Properties -> C/C++ -> All Options, there was a /DWINVER there. – thejinx0r Mar 4 '15 at 3:43

    @thejinx0r There is no such option in VS2017. But you can still do this by adding like "/DWINVER=0x0603" into Configuration Properties -> C/C++ ->Command Line->Additional Options –

    In my case my project had a source file with name stdafx.h, inside that file there was:

    #ifndef _WIN32_WINNT
    #define _WIN32_WINNT 0x0500 #endif

    I changed it to:

    #ifndef _WIN32_WINNT
    #define _WIN32_WINNT 0x601 #endif

    By default WINVER is defined as 0x0500 in preprocessor. To overcome from this error, remove defined win version "WINVER=0x0500" from Configuration Properties => c/c++ => Preprocessor tab and rebuild.

    Or you can provide higher WIN VERSION as #define _WIN32_WINNT 0x601 in your code wherever you getting error.

  3. Update WINVER and _WIN32_WINNT Update WINVER and _WIN32_WINNT
  4. To modify the macros, in a header file (for example, in targetver.h, which is included by some project templates that target Windows), add the following lines.

    #define WINVER 0x0A00
    #define _WIN32_WINNT 0x0A00

    The macros in the example are set to target every version of the Windows 10 operating system. The possible values are listed in the Windows header file sdkddkver.h, which defines macros for each major Windows version. To build your application to support a previous Windows platform, include WinSDKVer.h. Then, set the WINVER and _WIN32_WINNT macros to the oldest supported platform before including sdkddkver.h. Here are the lines from the Windows 10 SDK version of sdkddkver.h that encode the values for each major version of Windows:

  5. Upgrade C++ projects from earlier versions of Visual Studio
  6. Overview of potential upgrade issues (Visual C++)
  7. Upgrade your code to the Universal CRT
  8. Update WINVER and _WIN32_WINNT
  9. Fix your dependencies on C++ library internals
  10. Floating-point migration issues
  11. Use native multi-targeting in Visual Studio to build old projects
  12. C++ features deprecated in Visual Studio 2019
  13. Microsoft C++ porting and upgrading guide
  14. Visual Studio IDE tools for upgrading C++ code
  15. Microsoft C/C++ change history 2003 - 2015
  16. Visual C++ What's New 2003 through 2015
  17. C++ binary compatibility between Visual Studio 2015, 2017, and 2019
  18. Porting and Upgrading: Examples and Case Studies
  19. Porting Guide: MFC Scribble
  20. Step 2. Getting it to build Before building, we check the platform toolset so we know what compiler version the project system is using. In the project properties dialog, under Configuration Properties, in the General category, look at the Platform Toolset property. It contains the version of Visual Studio and the platform tool version number, which in this case is v141 for the Visual Studio 2017 version of the tools. When you convert a project that was originally compiled with Visual Studio 2010, 2012, 2013 or 2015, the toolset is not automatically updated to the latest toolset.

    To make the switch to Unicode, open the project's properties, under Configuration Properties, choose the General section, and locate the Character Set property. Change this from Use Multi-Byte Character Set to Use Unicode Character Set. The effect of this change is that now the _UNICODE and UNICODE macros are defined and _MBCS is not, which you can verify in the properties dialog under the C/C++ category at the Command Line property.

    Now build the solution. In the output window, the compiler tells us that _WINNT32_WINNT is not defined:

    Output
    _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

    This is a warning, not an error, and is very common when upgrading a Visual Studio C++ project. This is the macro that defines what the lowest version of Windows that our application will run on. If we ignore the warning, we accept the default value, _WIN32_WINNT_MAXVER, which means the current version of Windows. For a table of possible values, see Using the Windows Headers. For example, we can set it to run on any version from Vista onwards.

    Step 3. Testing and debugging There is no test suite, so we just started the app, tested its features manually through the UI. No issues were observed.

    Step 4. Improve the code Now that you've migrated to Visual Studio 2017, you might want to make some changes to take advantage of new C++ features. The current version of the C++ compiler is much more conformant to the C++ standard then previous versions, so if you have a mind to make some code changes to make your code more secure, and more portable to other compilers and operating systems, you should consider some improvements.

  21. Using the Windows Headers
  22. Predefined Symbol IDs
  23. When you begin a new project, depending on the project type, some symbol IDs are predefined for your use. These symbol IDs support the various libraries and project types such as MFC. They represent common tasks that are usually included in any application, or actions of hardware items, such as a mouse or printer.

    These symbol IDs become important when working with resources. They are available when you edit accelerator tables and some of them are already associated with virtual keys. They're also available to you through the Properties window. You can assign any of the predefined symbol IDs to new resources, or you can assign accelerator keys to them and the functionality associated with the symbol ID automatically associates with that key combination.

  24. Win32 Predefined Symbols
  25. MFC Predefined Symbols
  26. MFC projects always include several header files that support windows. These are added via #include statements in the StdAfx.h file:

    #include < afxwin.h > //MFC core and standard components
    #include < afxext.h > //MFC extensions
    #include <afxdisp.h > //MFC automation classes
    #include < afxdtctl.h > //MFC support for Internet Explorer common controls
    #include < afxcmn.h > //MFC support for Windows common controls.

    The header files include symbol ID values for MFC common values. These symbols are only available when you're working in an MFC project. The AFX_ prefix is followed by the standard symbol name prefixes.

  27. Porting Guide: Spy++
  28. This porting case study is designed to give you an idea of what a typical porting project is like, the types of problems you might encounter, and some general tips and tricks for addressing porting problems. It's not meant to be a definitive guide to porting, since the experience of porting a project depends very much on the specifics of the code.

    Spy++: Spy++ is a widely used GUI diagnostic tool for the Windows desktop that provides all sorts of information about user interface elements on the Windows desktop. It shows the complete hierarchy of windows and provides access to metadata about each window and control. This useful application has shipped with Visual Studio for many years. We found an old version of it that was last compiled in Visual C++ 6.0 and ported it to Visual Studio 2015. The experience for Visual Studio 2017 or Visual Studio 2019 should be almost identical.

    We considered this case to be typical for porting Windows desktop applications that use MFC and the Win32 API, especially for old projects that have not been updated with each release of Visual C++ since Visual C++ 6.0.

    Step 3. Linker OutputFile setting

    Older projects sometimes have files placed in unconventional locations that can cause problems after upgrading. In this case, we have to add $(SolutionDir) to the Include path in the project properties to ensure that Visual Studio can find some header files that are placed there, rather than in one of the project folders.

    MSBuild complains that the Link.OutputFile property does not match the TargetPath and TargetName values, issuing MSB8012.

    warning MSB8012: TargetPath(...\spyxx\spyxxhk\.\..\Debug\SpyxxHk.dll) does not match the Linker's OutputFile property value (...\spyxx\Debug\SpyHk55.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).warning MSB8012: TargetName(SpyxxHk) does not match the Linker's OutputFile property value (SpyHk55). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

    Link.OutputFile is the build output (EXE, DLL, for example), and it is normally constructed from $(TargetDir)$(TargetName)$(TargetExt), giving the path, filename and extension. This is a common error when migrating projects from the old Visual C++ build tool (vcbuild.exe) to the new build tool (MSBuild.exe). Since the build tool change occurred in Visual Studio 2010, you might encounter this issue whenever you migrate a pre-2010 project to a 2010 or later version. The basic problem is that the project migration wizard doesn't update the Link.OutputFile value since it's not always possible to determine what its value should be based on the other project settings. Therefore, you usually have to set it manually. For more details, see this post on the Visual C++ blog.

    In this case, the Link.OutputFile property in the converted project was set to .\Debug\Spyxx.exe and .\Release\Spyxx.exe for the Spy++ project, depending on the configuration. The best bet is to simply replace these hardcoded values with $(TargetDir)$(TargetName)$(TargetExt) for All Configurations. If that doesn't work, you can customize from there, or change the properties in the General section where those values are set (the properties are Output Directory, Target Name, and Target Extension. Remember that if the property you are viewing uses macros, you can choose Edit in the dropdown list to bring up a dialog box that shows the final string with the macro substitutions made. You can view all available macros and their current values by choosing the Macros button.

    more to take note ....

  29. Visual Studio 2010 C++ Project Upgrade Guide
  30. MSBuild Task:: Visual C++
  31. VC++ Directories
  32. Life in VS 2008 To start with, let’s take a look at the VS 2008 feature of VC++ Directories. If you were to go to the Tools->Options menu, you would see the following under the Project and Solutions settings

    These are the IDE equivalents to the command line environment variables of PATH, INCLUDE, etc. However, these values only apply within the IDE or vcbuild.exe – they don’t apply when executing cl.exe, for example, directly from the command line. Additionally, as you can see from the Platform dropdown at the top of the dialog, you can customize these settings for each platform.

    The implementation for these settings is to store the values in the VCComponents.dat file stored in %LOCALAPPDATA%\Microsoft\VisualStudio\9.0. Looking at the file, you’ll notice two things. First, it is in the LocalAppData directory, which means the settings are per-user, per-machine. The second thing you’ll notice is that the file is in an INI format, not the XML of a .vcproj file. This shows that the importing of the .dat file is some custom code of vcbuild.exe and the IDE.

    Changes in VS 2010 The first thing you’ll notice in VS 2010 when working with VC++ Directories is that they appear to have disappeared. When you go to the Tools->Options window and look in Project and Solutions, you’ll see the window looks very similar to the screenshot above – only VC++ Directories is gone. However, if you bring up a VC++ project in the IDE and open the project properties window (right-click on the project node and select Properties), you will notice a Rule called VC++ Directories (Rules are the tree of selections on the left pane of the property page window) and that the values you see are the same defaults that you would get from VS 2008. Additionally, you can edit these properties in the same way as any other project property (including using the macro editor as shown – something not possible in VS 2008).

    Of course, any edits you make right here are applied directly to the project you are working on – and directly to the project file itself. This means that the edits are NOT per-user, per-machine as they were in VS 2008. However, that option still exists in the form of a property sheet (If you don’t know about property sheets or how they work in VS 2010, I recommend reading my previous post about them here).

    If you open up the Property Manager view to see the property sheets associated with your project, you’ll see that one of the property sheets is named Microsoft.Cpp.Win32.User. This property sheet is actually stored in LocalAppData, just as VCComponents.dat file was, in the directory %LocalAppData%\Microsoft\VisualStudio\10.0. Using the property editor on the property sheet (just right-click on this property sheet node and select Properties…), you can see that you are able to make edits directly to this file. Since all projects, by default, import this property sheet, you are effectively editing the VC++ directories in the same way you were able to do before.

    Additionally, you can also delete the reference to this per-user, per-machine property sheet and create your own set of property sheets that set these values. Deleting the reference to this property sheet makes your project operate independently of any per-user, per-machine settings – and important step when trying to ensure correct behavior in a SCC (source code control) environment.

  33. How To Display XML Code as Plain Text in Blogger
  34. Enable C++ project system logging
  35. MSBuild Syntax and the IDE
  36. Kate Gregory's Blog

Modernizing Legacy C++ Code

Modernizing Legacy C++ Code

  1. Adding or Retrofitting Aero Glass into Legacy Windows Applications
  2. Modernizing Legacy C++ Code
  3. Porting a legacy MFC application to MFC Feature Pack
  4. MFC Feature Pack - CMFCEditBrowseCtrl
  5. Refactoring - elixir of youth for legacy VB code
  6. CMap How-to
  7. What static_cast<> is actually doing
  8. Scan and Merge INI Files
  9. Memory Leak Detection
  10. Quick and Dirty Collection Class Notes
  11. CPPMessageBox v1.0
  12. CPPToolTip v2.1
  13. Handle Management - Complete Solution
  14. Yet Another Custom Tree Control
  15. TOOL
  16. TCX Owner Draw Engine
  17. A Self-extracting Installer

Thursday, December 24, 2020

Error C2065 'afxChNil': undeclared identifier Demo2 c:\demo_temp\sizecbar_src\src\sizecbar.cpp 1296

to test Demo2, after I corrected all configuration property set up, such as $(SolutionDir)$(Configuration)\, and $(OutDir)$(TargetName)$(TargetExt), removed some warnings, compiled it, I am still get the final eorror(hopefully):

Error C2065 'afxChNil': undeclared identifier Demo2 c:\demo_temp\sizecbar_src\src\sizecbar.cpp 1296

pin point the location in the source code:

if (!CMiniFrameWnd::CreateEx(dwExStyle, NULL, &afxChNil, dwStyle, rectDefault, pParent))
{
m_bInRecalcLayout = FALSE;
return FALSE;
}

it is residing in this statement: CMiniFrameWnd::CreateEx

just neeed to figure out what type of this variable, then redefine it in this source code file:

  1. Parameters for CFrameWnd::CreateEx called by CFrameWnd::Create
  2. lpszWindowName lpszWindowName

    so afxChNil is constant string: jut define as below:
    TCHAR afxChNil;

    my fix is working well.

  3. Free MFC Source Code
  4. CSizingControlBar: resizable control bars by Cristi Posea. Do you need an edit control, tabbed tree or other window to be docked to the frame's sides? But after browsing through the MFC documentation, didn't find nothing like this? You came to the right place. CSizingControlBar is an easy to use collection of classes, allowing you to focus on your application needs rather than on implementation tweaks.

  5. Dynamic child window positioning
  6. CSizingControlBar - A Resizable Control Bar
  7. How to verify the bar state info
  8. Reference

  9. CFrameWnd
  10. CWnd Class ==> CreateEx() parameters
  11. virtual BOOL CreateEx( DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU nIDorHMenu, LPVOID lpParam = NULL);

    virtual BOOL CreateEx( DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, LPVOID lpParam = NULL);

Error C2440: 'static_cast': cannot convert from 'UINT (__thiscall CSizingControlBar::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)'

Error C2440: 'static_cast': cannot convert from 'UINT (__thiscall CSizingControlBar::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)'

  1. CSizingControlBar - A Resizable Control Bar
  2. My fix is: find all defined af_msg handler definition and update return type to : LRESULT.

    afx_msg LRESULT CSizingControlBar::OnNcHitTest(CPoint point)
    afx_msg LRESULT OnNcHitTest(CPoint point);

  3. Thread: VC2005 not happy with what ON_WM_NCHITTEST() returnsshare-icon
  4. It may depend on which version of VC you are using and which version of MSDN.
    VS2005 MSDN shows the prototype for WM_NCHITTEST to be:
    afx_msg LRESULT OnNcHitTest( CPoint point );

  5. Error C2440: 'static_cast' cannot convert from __thiscall
  6. very close to answer/fix...

  7. ON_WM_NCHITTEST (and other MFC macros) won't compile in whidbey
  8. error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CImportProjectDlg::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)'
  9. Issue with conversion from Visual C++ 6.0 to Visual Studio 2012
  10. Getting a program from Windows XP to Windows 7, MFC vs C# vs C++
  11. a good reference
  12. error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CStaticLink::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint) (转)
  13. 解决方法: 找到 UNIT CStaticLink::OnNcHitTest(CPoint point) 将UNIT 改为LRESULT

  14. error C2440: 'static_cast' 错误的解决方法
  15. 问题描述:
    在将vc6.0程序转换到vs2005或者vs2008、vs2010时提示:error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CStaticLink::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint) 解决方法:
    找到 UNIT CStaticLink::OnNcHitTest(CPoint point) 将UNIT 改为LRESULT

  16. errors pointing to the message map

Warning C4653 compiler option 'Optimizations (one or more of /Oawstgp[y]) or debug checks (one or more of /GZ, /RTCcsu)' inconsistent with precompiled header; current command-line option ignored

When I compile this project, I play around with more configuration in Visual Studio 2017. then I run into the following two warnings:

Warning C4653: compiler option 'Optimizations (one or more of /Oawstgp[y]) or debug checks (one or more of /GZ, /RTCcsu)' inconsistent with precompiled header; current command-line option ignored Project c:\demo_temp\outlooktabctrl_src\containerbar\containerbar.cpp 7

Warning C4651: '/D__MSVC_RUNTIME_CHECKS' specified for precompiled header but not for current compile Project c:\demo_temp\outlooktabctrl_src\containerbar\containerbar.cpp 7

MY playing is at: Configraton Properties->C/C++ -> Code Generation -> Enable String Pooling: I select "YES / GF"; Basic Runtime Checks: I set to "Both (RTC1)". Note: if I set to this value, then the warnings are gone.

if I played at Configraton Properties-> Linker -> Optimization -> References -> I set to : "YES (/OPT:REF)", I will run into the following warning message:

Warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification Project C:\Demo_Temp\OutlookTabCtrl_src\LINK 1

  1. LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
  2. the good explanation /solution is:

    You can either have "Edit and continue" support or optimizations. Usually, you put "Edit and continue" on debug builds, and optimizations on release builds.

    Edit and continue allows you to change code while you are debugging and just keep the program running. It's not supported if the code also has to be optimized.

    another good explanation/solution is below:

    I also got this warning when converting a VS2008 project from .lib to .dll and the workaround was to change the Linker/Optimization settings on the Debug Win32 configuration from Default to:
    References = Keep Unreferenced Data (/OPT:NOREF)
    Enable COMDAT Folding = Do Not Remove Redundant COMDATs (/OPT:NOICF)

  3. OutlookTabCtrl, like CBCGPOutlookBar (in Mode2003)
  4. CSizingControlBar - A Resizable Control Bar

Wednesday, December 23, 2020

Warning C4840:: non-portable use of class ATL::CStringT as an argument to a variadic function

I am testing Splitter Control and ran into the following errors after I corrected project path set up etc.

Warning C4840 non-portable use of class "ATL::CStringT>>" as an argument to a variadic function

    A good Book to buy

  1. The Legacy Code Programmer's Toolbox
  2. Practical skills for software professionals working with legacy code

  3. Problems

  4. SplitterCtrl (Flexible Control with Custom Drawing)
  5. Why use static_cast(x) instead of (int)x?
  6. Compiler Warning (level 4) C4840
  7. static_cast in C++
  8. static_cast Operator
  9. static_cast
  10. 6.16 — Explicit type conversion (casting) and static_cast
  11. Static Cast in C++ – static_cast() Method
  12. static_cast conversion
  13. static_cast in C++ | Type Casting operators
  14. std::to_string
  15. static_cast in C++ | Type Casting operators
  16. C++ Bitset Library - to_string() Function
  17. varargs and conversion operators in MFC CString
  18. cannot convert argument 1 from 'ATL::CStringT>>' to 'const char *'
  19. Variadic arguments
  20. Variadic functions

MFC custom control

keyword: MFC control, custom control on cp.com

    custom control tutorials

  1. CWinListBox - A CWin derived custom listbox control
  2. Step-by-step creation of a custom ListBox control from a generic CWin.

  3. Creating Custom Controls
  4. MFC Grid control 2.27
  5. An MFC Curve Control
  6. CCustomTabCtrl - MFC Tab Control
  7. Creating and Using custom controls in VC++
  8. MFC DataGrid
  9. Date Time Picker control for the MFC Grid Control
  10. Good Reference

  11. Design Time Architecture in .NET 2.0 - Part 1
  12. Customizing the "Browse for folder" dialog
  13. Customizing "Browse for folder" dialog Part - II
  14. Custom Controls in Win32 API: Control Customization
  15. Custom Controls in Win32 API: The Basics
  16. Custom Controls in Win32 API: The Painting
  17. Custom Controls in Win32 API: Visual Styles
  18. Custom Controls in Win32 API: Standard Messages
  19. Custom Controls in Win32 API: Control Customization
  20. Custom Controls in Win32 API: Encapsulation of Customized Controls
  21. Custom Controls in Win32 API: Scrolling
  22. mCtrl.org
  23. Bringing more controls for your Win32API applications.

    mCtrl is open-source C library providing set of additional user interface controls for Windows, intended to be complementary to standard Win32API controls from USER32.DLL and COMCTL32.DLL.

  24. WinDrawLib
  25. WinDrawLib
  26. Nice Custom Controls Library
  27. Nice Libraries
  28. Flicker free resizable custom control
  29. Wifi scanner + custom MFC controls
  30. Pixel graphics programming on Windows Mobile
  31. Tested Samples

  32. SplitterCtrl (Flexible Control with Custom Drawing)
  33. tested, it is good to use. very fancy..

  34. TabCtrl
  35. after download this example, when compiled it, I got a lot errors:

    corrected the path for the precompiled header file statement: #include "../StdAfx.h"

    turned off project level precompiled header file usage.

    in stdafx.h file, define:
    " #define _WIN32_WINNT 0x0502"
    "#define WINVER 0x0502 "

    after some easy fixes, the final one is:

    Warning MSB8012 TargetName(Project) does not match the Linker's OutputFile property value (TabCtrl). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). Project C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets 1218

    the fix is to reset all correct output path following this link:

    step 1: Configration Properties->General -> Output Directory:set to "$(SolutionDir)$(Configuration)\"; TargetName: set to "$(ProjectName)"

    step 2: Configration Properties-> Linker -> General -> Output File-> set to : "$(OutDir)$(TargetName)$(TargetExt) "

  36. Custom Drawn Vertical Tree Control
  37. tested: working

  38. OutlookTabCtrl, like CBCGPOutlookBar (in Mode2003)
  39. testing....

  40. MultiPaneCtrl
  41. need testing...

  42. Understanding CDockablePane
  43. tested, working well...

  44. CStaticTreeCtrl - A CStatic derived custom Tree control
  45. Stacked Windows Control Tutorial
  46. Editable ListBox Tutorial
  47. MFC Grid control 2.27
  48. Customizing the Appearance of CSliderCtrl Using Custom Draw
  49. Custom Control Graph and Process Bar
  50. Adding New Theme Variations to the MFC Ribbon (CMFCVisualManager)
  51. An MFC Calculator Custom Control with No Resource File Dependencies
  52. Simple zoom functionality for custom controls
  53. Yet Another Custom Tree Control
  54. Custom ToolTips for MFC Projects
  55. Tree Control with Columns
  56. Image Alignment Algorithms
  57. Image Alignment Algorithms - Part II
  58. Undockable Custom Control in an MDI Application
  59. Numeric Edit Control
  60. Tutorial: Creating a Lookless WPF Custom Rotate Control
  61. A Custom GUI System
  62. A Custom GUI System - Part 2: Dialogs and Controls oto spal
  63. dwl::fractalBrowser
  64. Fancy Controls
  65. A Custom Group Combo Box
  66. Framework

  67. GuiToolkit MFC Extension
  68. An Introduction to a Model-View-Controller Implementation for MFC
  69. The SBJ MVC Framework - The Model, from Abstraction to Realization
  70. The SBJ MVC Framework - The Design View, Responding to Model Change
  71. CKCSideBannerWnd: An MFC Banner Control that Can Add a Professional-looking Feel to Most Windows...
  72. MFC Docking Framework
  73. CGrid Control
  74. MFC/C++ Helper Class for Window Resizing
  75. MFC - Multiple inheritance and serialization
  76. MFC Windows Coding Guidelines
  77. ActiveX

  78. MFC GDI+ ActiveX Arrow Control For Excel
  79. A Simple Method to Control the Startup State of an MFC SDI Application
  80. An MFC ActiveX control to display trays
  81. Using ActiveX controls in MFC more efficiently
  82. CUltraPadWnd - A Simple Syntax Coloring Control Based on the MFC CWnd Class
  83. CRichEditControl50W - A VC++ Rich Text Edit 4.1 MFC Control
  84. XColorPickerXP - an MFC color picker control with themed look
  85. GDI+ in ActiveX Controls Using MFC
  86. MFC Controls using XML-Files as DataSource (XERCES-Parser)
  87. Control client area minimum size with MFC
  88. MFC List Control with Tool-tip, Menu, Colors, and Sorting Ability

Tuesday, December 22, 2020

Error C2668 'abs': ambiguous call to overloaded function

Error C2668 'abs': ambiguous call to overloaded function
Triangle Renderer Project c:\demo_temp\triangle-renderer-project\triangle renderer project\c3dengine.cpp 5953

  1. Ambiguous overload call to abs(double)
  2. The cplusplus page you cite does not say to include cmath.h. It says cmath. That's the C++ version of math.h. Don't include both. – Rob Kennedy Sep 3 '09 at 15:54

    The header is a C std lib header. It defines a lot of stuff in the global namespace. The header is the C++ version of that header. It defines essentially the same stuff in namespace std. (There are some differences, like that the C++ version comes with overloads of some functions, but that doesn't matter.) The header doesn't exist.

    very clear and thorough answer is the following one:

    Since vendors don't want to maintain two versions of what is essentially the same header, they came up with different possibilities to have only one of them behind the scenes. Often, that's the C header (since a C++ compiler is able to parse that, while the opposite won't work), and the C++ header just includes that and pulls everything into namespace std. Or there's some macro magic for parsing the same header with or without namespace std wrapped around it or not. To this add that in some environments it's awkward if headers don't have a file extension (like editors failing to highlight the code etc.). So some vendors would have be a one-liner including some other header with a .h extension. Or some would map all includes matching to (which, through macro magic, becomes the C++ header when __cplusplus is defined, and otherwise becomes the C header) or or whatever.

    That's the reason why on some platforms including things like , which ought not to exist, will initially succeed, although it might make the compiler fail spectacularly later on.

  3. 3D Software Rendering Engine - Part I
  4. when I compile this project, I got this error message:

    I fixed it by using their new header file names: such as bracket cmath braket instead of cmath.h;

DEbug assertion failed D:\agent\_work\20\s\src\vctools\VC7Libs\Ship\ATLMFC\Src\MFC\occcont.cpp Line 925

when I compiled a legacy project NTGraph3d_demo.zip project, I got this error message:

DEbug assertion failed D:\agent\_work\20\s\src\vctools\VC7Libs\Ship\ATLMFC\Src\MFC\occcont.cpp Line 925

I suspect my ATL/STL is not installed in my Visual Studio 2017 installation. need to reinstall it.

  1. 3D Graph ActiveX Control
  2. Debug assertion failed error message

    firstly thank you for your reply WayneAKing. actually it wasn't showed any further error except what i placed the text and the regarding source path(file:f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occcont.cpp) also not existed in my computer. I haven't installed any earlier versions except vs2008 . finally it was solved when i register the MSCOMM32.OCX with the regsvr32 in command prompt. after that activeX controls worked properly and the error was resolved. i think the error has been occurred due to the missing of activeX controls but why the compiler wasn't showed it..? why it showed simply as debug assertion failed error..? Thank you...!

    it seems like I need to register this ActiveX component too.

3D surface plot research

3D surface plot research. the first two posts are good enough to build my own 3D engine.

    good start

  1. 3D Software Rendering Engine - Part I
  2. need to change header files: #include , #include

  3. Build My Own 3D Graphics Engine Step By Step
  4. xieguigang / GNUplot
  5. Optional Parameter Expression in VisualBasic
  6. CTGraphics - Anti-Alias C++ Drawing
  7. VisualClassBuilder - Free Code Generation Tool
  8. A Customizable Architecture for 3D Graphics Applications
  9. Diligent Engine: A Modern Cross-Platform Low-Level Graphics Library
  10. Learning Basic Math Used In 3D Graphics Engines
  11. good posts

  12. How to Write a 3D Modeling Application in JavaScript
  13. Rendering 3D Graphic in .NET with C# and Igneel.Graphics
  14. Euler Rotation
  15. 3D Graphics - Cube with Shading
  16. Build My Own 3D Graphics Engine Step By Step
  17. Plot 3D surfaces
  18. A 3D Plotting Library in C#
  19. Structure of 3D
  20. Detect Amount of Arc
  21. 3D Bar Chart
  22. Weiler-Atherton Algorithm in 3D
  23. Weiler-Atherton Algorithm in 3D
  24. 3D Graph ActiveX Control
  25. DISLIN Home Page
  26. Plotting Circular Relationship Graphs with Silverlight
  27. A C++ Implementation of an Improved Contour Plotting Algorithm
  28. GDI+ Plot ActiveX Control

Saturday, December 19, 2020

List of _MSC_VER and _MSC_FULL_VER

List of _MSC_VER and _MSC_FULL_VER

  1. List of _MSC_VER and _MSC_FULL_VER

what is SDKDDKVer.h for?

what is SDKDDKVer.h for?

  1. what is SDKDDKVer.h for?
  2. All project created with MSVC have stdafx, which is precompiled headers, which I know what they are but what about targetver.h ? It includes SDKDDKVer.h, and I can't find what is that header about. What is this for ?

    targetver.h and SDKDDKVer.h are used to control what functions, constants, etc. are included into your code from the Windows headers, based on the OS that you want your program to support. I believe that targetver.h sets defaults to using the latest version of Windows unless the defines are specified elsewhere.

    SDKDDKVer.h is the header file that actually defines the #defines that represent each version of Windows, IE, etc.

  3. What does the `Target Platform Version` mean for a VS C++ project?
  4. Using the Windows Headers

WARNING: _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

ERROR / WARNING: _WIN32_WINNT not defined.

  1. Problem with _WIN32_WINNT
  2. The correct format for the define is:

    #define _WIN32_WINNT 0x0502
    and this statement must come before any #includes in the StdAfx.h, or whatever include you use to build the precompiled headers

  3. How to get rid of _WIN32_WINNT not defined warning?
  4. find and review this good thought:

    #define _WIN32_WINNT and #define WINVER can occur in a header, so long as they occur before including SDKDDKVer.h or any headers from the Windows SDK (in particular Windows.h). Visual Studio VC++ projects typically provide a targetver.h header, where you can include WinSDKVer.h, define _WIN32_WINNT, NTDDI_VERSION and WINVER, and then include SDKDDKVer.h. Comments within this file say:

  5. _win32_winnt win10_th2 is not defined as a preprocessor macro
  6. Update WINVER and _WIN32_WINNT
  7. When you use the Windows SDK, you can specify which versions of Windows your code can run on. The preprocessor macros WINVER and _WIN32_WINNT specify the minimum operating system version your code supports. Visual Studio and the Microsoft C++ compiler support targeting Windows 7 SP1 and later. Older toolsets include support for Windows XP SP2, Windows Server 2003 SP1, Vista, and Windows Server 2008. Windows 95, Windows 98, Windows ME, Windows NT, and Windows 2000 are unsupported.

    When you upgrade an older project, you may need to update your WINVER or _WIN32_WINNT macros. If they're assigned values for an unsupported version of Windows, you may see compilation errors related to these macros.

    Remarks To modify the macros, in a header file (for example, in targetver.h, which is included by some project templates that target Windows), add the following lines.

    C Copy #define WINVER 0x0A00 #define _WIN32_WINNT 0x0A00

    The macros in the example are set to target every version of the Windows 10 operating system. The possible values are listed in the Windows header file sdkddkver.h, which defines macros for each major Windows version. To build your application to support a previous Windows platform, include WinSDKVer.h. Then, set the WINVER and _WIN32_WINNT macros to the oldest supported platform before including sdkddkver.h. Here are the lines from the Windows 10 SDK version of sdkddkver.h that encode the values for each major version of Windows:

    For a more fine-grained approach to versioning, you can use the NTDDI version constants in sdkddkver.h. Here are some of the macros defined by sdkddkver.h in Windows 10 SDK version 10.0.18362.0:

  8. /D (Preprocessor Definitions)
  9. Defines a preprocessing symbol for a source file.

  10. How to get rid of _WIN32_WINNT not defined warning?
  11. MSVC:fix warning: _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

Error C3861 '_DEBUG_RANGE': identifier not found ChartCtrlLib

Error C3861 '_DEBUG_RANGE': identifier not found ChartCtrlLib

  1. _DEBUG_POINTER in VS 2017
  2. Have you installed STL feature with your vs2017? Please provide more information or steps about your issue, so that we could find the root cause for you.

    there is code demo to test STL installation:

  3. _DEBUG_POINTER and _DEBUG_RANGE(First, Last)
  4. Using C++ Modules in Visual Studio 2017
  5. 为什么我会收到_SCL_SECURE_NO_WARNINGS消息
  6. Using C++ Modules in Visual Studio 2017
  7. 在Visual Studio 2017 中使用C++ Modules
  8. C++ Modules in VS 2015 Update 1
  9. Install C and C++ support in Visual Studio
  10. The Lightweight Visual Studio 2017 Installer
  11. C++17 Features And STL Fixes In VS 2017 15.3
  12. Visual Studio Build Tools now include the VS2017 and VS2015 MSVC Toolsets
  13. C++17/20 Features and Fixes in Visual Studio 2019
  14. How to enable C++17 compiling in Visual Studio?
  15. Compiler ICE when using STL modules on VS 2017 15.0.0+26228.9
  16. microsoft / STL
  17. What's New in Visual Studio 2017 (RC)
  18. STL Features and Fixes in VS 2017 15.8

MFC Collection Type Class

MFC Collection Type Class

also I searched geometry in cp.com and get some good posts.

  1. CArray Class
  2. CList Class
  3. CMap Class
  4. A Beginner's Guide to Pointers
  5. INI Reader / Writer Class for MFC and ANSI C++ ( Windows \ Linux )
  6. Using the List Control
  7. 45 Day Series: CodeProject VC++ Forum Q&A - V
  8. Classes for computational geometry
  9. A Tool for Visualizing 3D Geometry Models (Part 1)
  10. Making C++ Geometry headers
  11. Parametric Curves and Surfaces in the Public Domain Geometry Utilities Library

Friday, December 18, 2020

Enabling Debug Features in C++ projects (/D_DEBUG)

Enabling Debug Features in C++ projects (/D_DEBUG)

  1. Set debug and release configurations in Visual Studio
  2. Enabling Debug Features in C++ projects (/D_DEBUG)
  3. Migrating Projects Created with Visual Studio Versions Earlier than 2010
  4. Debugging with command-line parameters in Visual Studio
  5. Passing command line arguments in Visual Studio 2010?
  6. How do I start a program with arguments when debugging?
  7. Identifier not found - error C3861 in Visual Studio 2019
  8. Compiler Error C3861

Compile MFC Sources with Visual Studio 2019

Compile MFC Sources with Visual Studio 2019

  1. Compile MFC Sources with Visual Studio 2019
  2. What is dumpexts.exe? Is it Safe or a Virus? How to remove or fix it
  3. Introduction to Software Translation for MFC
  4. Linker Errors, CString, ATL, MFC, and YOU!
  5. How to Pass Command Line Arguments to MSI Installer Custom Actions
  6. Threads with MFC
  7. Setting Landscape Mode in an MFC Application Written in C++
  8. An MFC Chart Control with Enhanced User Interface
  9. SliderGdiCtrl: Yet Another Slider Control - Accepts (Almost) All POD Types and Uses GDI+
  10. C++: Converting an MFC CString to a std::string

debugging tricks in Visual Studio

debugging tricks in Visual Studio

  1. mariusbancila / mfccollectionutilities
  2. Modernizing Legacy C++ Code
  3. 10 Even More Visual Studio Debugging Tips for Native Development
  4. 10 More Visual Studio Debugging Tips for Native Development
  5. Create projects easily with private MFC, ATL and CRT assemblies
  6. mfccollectionutilities
  7. Enabling MFC Collections to Work in Range-based for Loops
  8. What's New in Visual Studio 2013 for Native Development

Warning LNK4075 ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification

when I compiled a legacy project from cp.com, I ran into this message after I set up the project as this:

Configuration Properties->C/C++ -> General -> Debug Information Format -> choose: Program Database for Edit And Continue (/ZI)

Warning LNK4075 ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification

the reason behind it is that there is a warning message related with No /Gy-. I configured it as:

Configuration Properties->C/C++ -> Code Generation -> Enable Functional-Level linking-> set :Yes (/Gy)

after some research, I need to set this value to:

Configuration Properties->C/C++ -> General -> DEbug Information Format -> choose: Program Database (/Zi)

  1. LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
  2. You can either have "Edit and continue" support or optimizations. Usually, you put "Edit and continue" on debug builds, and optimizations on release builds.

    Edit and continue allows you to change code while you are debugging and just keep the program running. It's not supported if the code also has to be optimized.

    one solution is: I had this problem too. I opened the Project Properties, and then clicked General in the C/C++ tab. There is an option that says 'Debug Information Format', which I changed to Program Database (/Zi), and I didn't get the warning anymore.

    another solution is : I also got this warning when converting a VS2008 project from .lib to .dll and the workaround was to change the Configuration Properties - > Linker -> Optimization -> Reference, or Enable COMDAT Folding settings on the Debug Win32 configuration from Default to:

    • References = Keep Unreferenced Data (/OPT:NOREF)
    • Enable COMDAT Folding = Do Not Remove Redundant COMDATs (/OPT:NOICF)

    Another good check is this setting: We had to set "Generate Debug Info" to "Yes (/DEBUG)" under the project properties' Configuration Properties -> Linker -> Debugging -> Generate Debug Info-> Generate Debug Information (/DEBUG) . Not sure how that wasn't set for a debug build in the first place, or why that wouldn't be the default, but there you go. (VS2010, in case that's relevant.)

  3. Linker Tools Warning LNK4075
  4. ignoring "option1" due to "option2" specification

    The second option overrides the first.

    Mutually exclusive linker options are being specified. Examine your linker options. Where linker options are specified depends on how you are building your project.

    • If you are building in the development environment, look in the linker property pages for your project, and see where both linker options are being specified. See Set compiler and build properties for more information.
    • If you build at the command line, look at the linker options specified there.
    • If you build with build scripts, look through your scripts to see where these linker options are being specified.

    When you find where the mutually exclusive linker options are specified, remove one of the linker options.

    Some specific examples:
    • If you link a module that was compiled with /ZI, which implies an internal linker option called /EDITANDCONTINUE, and a module that was compiled with /OPT:REF, /OPT:ICF, or /INCREMENTAL:NO, which imply no /EDITANDCONTINUE, you will get LNK4075. See /Z7, /Zi, /ZI (Debug Information Format) for more information.
  5. /Z7, /Zi, /ZI (Debug Information Format)
  6. Compiler options listed by category
  7. Compiler Options
  8. Visual Studio 2005 - Warning LNK 4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
  9. The above warning occurs as a result of a clash between two features of the Visual Studio development suite and can be eliminated by either disabling support for "Edit and Continue" or eliminating Incremental Compilation. The first allows you to edit code while debugging when stopped at a break point. The second specifies whether linking is done incrementally or not (that is, one included library at a time). Linking incrementally can result in larger file sizes and occassionally "jump thunks," which, I believe, are libraries that require multiple memory hops to reach.

    If you link a module that was compiled with /ZI, which implies an internal linker option called /EDITANDCONTINUE, and a module that was compiled with /OPT:REF, /OPT:ICF, or /INCREMENTAL:NO, which imply no /EDITANDCONTINUE, you will get LNK4075.

    The property controlling "edit and continue" can be changed in the Project Properties Pages -> Project Configuration -> C/C++ -> Debug Information Format, whereas the property specifies if linking should be done incrementally can be changed in the Project Properties Pages -> Project Configuration -> Linker -> Enable Incremental Linking.

pre-compiled header file configuration

pre-compiled header file configuration.

I tried many times and finally I got it! how to set up precompiled header file and output file is straight:

  1. StdAfx.h
  2. a good tutorial on how to use stdafx.h file

  3. fatal error C1010: unexpected end of file while looking for precompiled header.
  4. fatal error C1010 - “stdafx.h” in Visual Studio how can this be corrected?
  5. Precompiled Header Files from Microsoft
  6. When you create a new project in Visual Studio, a precompiled header file named pch.h is added to the project. (In Visual Studio 2017 and earlier, the file was called stdafx.h.) The purpose of the file is to speed up the build process. Any stable header files, for example Standard Library headers such as , should be included here. The precompiled header is compiled only when it, or any files it includes, are modified. If you only make changes in your project source code, the build will skip compilation for the precompiled header.

    The compiler options for precompiled headers are /Y. In the project property pages, the options are located under Configuration Properties > C/C++ > Precompiled Headers. You can choose to not use precompiled headers, and you can specify the header file name and the name and path of the output file.

    Already Reviewed and Understood

  7. “unexpected end of file while looking for precompiled header. Did you forget to add ‘#include “stdafx.” to your source?”
  8. How to implement precompiled headers into your project
  9. this is the answer I finally got it:

    1. You stdafx.cpp should include stdafx.h and be built using /Yc"stdafx.h".
    2. Your other *.cpp should be include stdafx.h and be built using /Yu"stdafx.h".
    3. Note the double-quote characters used in the compiler options!
    4. on project level: in Visual Studio 2017 Solution View, select the project node and right click it. from Configurations Proery-> C/C++ -> precompiled headers-> Precompiled Header: set "Use/ Yu"; Precompiled Header File: set "stdafx.h"; precompiled header output file: I need to play around it:)
    5. on source code stdafx.cpp file level:in Visual Studio 2017 Solution View, select "stdafx.cpp" file and right click it. from Configurations Proery-> C/C++ -> precompiled headers-> Precompiled Header: set "Create/ Yc"; Precompiled Header File: set "stdafx.h"; precompiled header output file: in debug mode, set to : ".\$(Configuration)\TestString.pch". in release mode, set to: ".\$(Configuration)\TestString.pch". the file name for .pch , you can specify any name you like. here is what I discovered. :). or to be easy, in "All Configurations" selected, set it to: ".\$(Configuration)\TestString.pch".
    6. on any .cpp source code files other than "stdafx.cpp" file level:in Visual Studio 2017 Solution View, select "stdafx.cpp" file and right click it. from Configurations Proery-> C/C++ -> precompiled headers-> Precompiled Header: set "Use/ Yu"; Precompiled Header File: set "stdafx.h"; precompiled header output file: I need to play around it:)
    Here's a screenshot of the Visual Studio settings for stdafx.cpp to create a precompiled header:

    another good summary is given below:

    "stdafx" is just a convention. It's in no way mandatory. In a multi-project solution, I've used other setups with multiple pre-compiled headers for different parts. E.g. it may be useful to have one PCH shared by your UI projects, and another one for your database projects.

    The relevant components are the X.h file listing precompilable headers, the X.cpp file that includes only X.h (and adds no code itself), and the X.pch file created by compiling X.cpp (and thus X.h) with compiler option /Yc.

    When you're now compiling Y.cpp file with /Yu"X.pch", the compiler reads and discards everything up to #include "X.h". At that point it replaces its internal state with the state stored in X.pch, except for the input stream (remains Y.cpp, with the file pointer set to the next line after #include "X.h").

  10. C Language Dynamic String
  11. I used this as example to configure precompiled header file.

  12. What is stdafx.cpp file that is created automatically in a new c++ project in visual studio 2012
  13. Pre-compiled headers can greatly speed the up the compilation of the .cpp files in your project. By convention, it is stdafx.h that #includes all of the .h files that you want to be precompiled. You can name it anything you want but the project template just picks stdafx.h

    But before that can work, there must be one .cpp file that #includes stdafx.h and gets compiled first. Before all the other .cpp files in your project. Once that's done, the compiler can use the .pch file that was created and quickly compile all the other .cpp files, no longer having to actually #include the headers anymore.

    Stdafx.cpp is that one .cpp file. It has a setting that's different from all the other .cpp files, it gets built with /Yc. The "Create precompiled header file" option.

    UPDATE: after 28 years, Microsoft broken their "there used to be an std framework but nobody ever saw it" practices at VS2019. Now named "pch" instead of "stdafx", surely for the more obvious acronym. Just a name change, the mechanics are still the same.

  14. What is stdafx.cpp file that is created automatically in a new c++ project in visual studio 2012
  15. a good exercise to practice my understanding

  16. fatal error C1010 - “stdafx.h” in Visual Studio how can this be corrected?
  17. Turn off pre compiled headers:

    Project Properties -> C++ -> Precompiled Headers -> set Precompiled Header to "Not Using Precompiled Header".

  18. What is “stdafx.h” used for in Visual Studio?
  19. All C++ compilers have one serious performance problem to deal with. Compiling C++ code is a long, slow process.

    Compiling headers included on top of C++ files is a very long, slow process. Compiling the huge header structures that form part of Windows API and other large API libraries is a very, very long, slow process. To have to do it over, and over, and over for every single Cpp source file is a death knell.

    This is not unique to Windows but an old problem faced by all compilers that have to compile against a large API like Windows.

    The Microsoft compiler can ameliorate this problem with a simple trick called precompiled headers. The trick is pretty slick: although every CPP file can potentially and legally give a sligthly different meaning to the chain of header files included on top of each Cpp file (by things like having different macros #define'd in advance of the includes, or by including the headers in different order), that is most often not the case. Most of the time, we have dozens or hundreds of included files, but they all are intended to have the same meaning for all the Cpp files being compiled in your application.

    The compiler can make huge time savings if it doesn't have to start to compile every Cpp file plus its dozens of includes literally from scratch every time.

    The trick consists of designating a special header file as the starting point of all compilation chains, the so called 'precompiled header' file, which is commonly a file named stdafx.h simply for historical reasons.

    Simply list all your big huge headers for your APIs in your stdafx.h file, in the appropriate order, and then start each of your CPP files at the very top with an #include "stdafx.h", before any meaningful content (just about the only thing allowed before is comments).

    Under those conditions, instead of starting from scratch, the compiler starts compiling from the already saved results of compiling everything in stdafx.h.

    I don't believe that this trick is unique to Microsoft compilers, nor do I think it was an original development.

    For Microsoft compilers, the setting that controls the use of precompiled headers is controlled by a command line argument to the compiler: /Yu "stdafx.h". As you can imagine, the use of the stdafx.h file name is simply a convention; you can change the name if you so wish.

    In Visual Studio 2010, this setting is controlled from the GUI via Right-clicking on a CPP Project, selecting 'Properties' and navigating to "Configuration Properties\C/C++\Precompiled Headers". For other versions of Visual Studio, the location in the GUI will be different.

    Note that if you disable precompiled headers (or run your project through a tool that doesn't support them), it doesn't make your program illegal; it simply means that your tool will compile everything from scratch every time.

    If you are creating a library with no Windows dependencies, you can easily comment out or remove #includes from the stdafx.h file. There is no need to remove the file per se, but clearly you may do so as well, by disabling the precompile header setting above.

    Good example to use precompiled header file

  20. Projects in Visual C++ 2010 – Part 1: Creating a DLL project
  21. Projects in Visual C++ 2010 – Part 2: Project Dependencies
  22. Projects in Visual C++ 2010 – Part 3: Precompiled Headers
  23. How to Optimize Compilation Times with Precompiled Headers (PCH Files)
  24. Misc Applications

  25. Tooltips for Toolbars in Non-CFrameWnd Windows
  26. Single View in MultiDoc-Application
  27. Documenting Header Files
  28. 0.8 — A few common C++ problems