How to solve error LNK1104: cannot open file ‘mfc120d.lib’


If you encounter the same problem as below:

 error LNK1104: cannot open file ‘mfc120d.lib’ 

You can solve this problem by downloading Multibyte MFC Library for Visual Studio 2013 and install that. However note that VisualStudio has deprecated MBCS support in MFC, and unicode is preferred.

Using /clr and incompatibility troubleshooting in MFC applications


In some circumstances, to use C# Winform or other .Net objects in MFC applications, the “/clr” directive should be used in the MFC project settings. However, it is found not always possible to use “/clr” to avoid conflicts with other projects in the same solution.

The workaround is to apply “/clr” on a specific cpp file, rather than on the entire project!

clip_image002

Continue reading “Using /clr and incompatibility troubleshooting in MFC applications”

How to use .Net Winform or UserControl in MFC


For VisualStudio 2005 or above versions, refer to below link

http://msdn.microsoft.com/en-us/library/ahdd1h97.aspx
http://msdn.microsoft.com/en-us/library/b1kyh79x(v=VS.80).aspx

The basic idea of this implementation is to use the class CWinFormsControl<NameSpce::WinformClass/UserControlClass> to host .Net Winform or UserControl.

This article presents how to implement this in VS2002 environment. Continue reading “How to use .Net Winform or UserControl in MFC”

How to manually setup/modify Visual C++ Project settings such as /GL, /Yu etc. in VisualStudio.Net 2002


Most Visual C++ project settings can be setup using the Project Properties dialog, but not all. In my recent project, I am trying to host Windows Form in MFC (VS2002), and the directive “/clr” must be used.

Once “/clr” is used, some other directives such “/GL” must be disabled to avoid incompatibilities. After searching MSDN, I have found that “/GL” is related to “Whole Program Optimization”, but even after disabling the whole program optimization in Visual Studio 2002, it is stated that the “/GL” switch is still turned on. I have tried every setting, but have no way to disable this, and this is clearly shown in the final command line.

Continue reading “How to manually setup/modify Visual C++ Project settings such as /GL, /Yu etc. in VisualStudio.Net 2002”

MFC:Using Numerical Recipe in C++


I was forced to come back to MFC, as the company I am now serving still uses VisualStudio.net 2002.

The happy days using C# are gone,… tears…

Below is my trial to use code from Numerical Recipe in C++, 3rd ed, in a MFC dialog application:

1. Include “nr3.h” where all the data structures and function interfaces are defined.

MFCNumericalRecipe_B

2. You need also to include specific module in which you are interested in. In this example, I am trying to use LU decomposition based methods to solve linear equation.

Continue reading “MFC:Using Numerical Recipe in C++”

Shell extension and ATL development


  1. An absolutely must-read paper is here.
  2. To install the ATL dll to the target machine: Regsvr32 /s Your.dll
  3. To get the shell extension to work in x64 mode, use VS2005 or VS2008 ATL wizard, as VC6 does not support to change the x86 or x64 platforms;
  4. In VS2008 wizard, some interface’s signigures are different from that in VC6 enviromment, for instance, in VC6, for the IContextMenu inteface , the function to be implemented is:
    STDMETHODIMP GetCommandString(UINT, UINT, UINT*, LPSTR, UINT);
    and in ATL 9.0, however it is:
    STDMETHODIMP GetCommandString(UINT_PTR, UINT, UINT*, LPSTR, UINT);
  5. To generate the DLL for x64 machines, in VS2008, go to Project->Properties (or Alt+F7), then Configuration Properties-> Linker -> Advanced, on the right side, go to “Target Machine”, change this to “MachineX64 (/MACHINE:X64) and Rebuild.
  6. The transparency of the icon in the shortcut menu can be found here.