Posted in 2012
How to: Migrating a CLR console Visual C++ project to Windows Forms
- 17 December 2012
Note: Windows Forms programming in new development is discouraged by Microsoft at this point as Microsoft wants to make full use of hardware accelerated drawing instead of using the CPU-intensive GDI. But maintaining old Windows Forms code in Visual C++ 2012 is still supported, GDI isn’t going anywhere anytime soon.
Visual C++ 2012 removed the Windows Forms project template and I see people scramble to find ways to create a Windows Forms project. There is a walkaround that’s been around for years, that is, to convert a CLR console application to a Windows one, then add forms related code to the project.
Add the correct interface first in Adding an MFC Class from an ActiveX Control wizard.
- 04 December 2012
In good old times aka VC6, if you want to use an ActiveX in MFC, the Components and Controls Gallery would generate all the properties and methods of an ActiveX and pull dependent types and create wrapper classes for them as well. And it was good. It magically knows the main class of the Windows Media Player ActiveX is CWMPPlayer4 and that GetCurrentMedia method returns CWMPMedia.
Welcome to the modern Visual C++. Now comes a new wizard that gives you options to choose interfaces to import from. At the same time you got to decide if you really need that many types from an ActiveX. If you went the unfortunate path of Adding a Member Variable wizard in the dialog editor and somehow got a COCX1 class back, you don’t have the luxury to choose, and you end up with an CWnd wrapper class that does not really wrap up the properties and methods of the ActiveX. It is still good for early binding (like querying IWMPPlayer4 from the result of CWnd::GetControlUnknown) but if you plan to use late binding and MFC’s OLE support (hello COleException!), you probably want to delete the COCX1 files and start over with the Adding a Class from an ActiveX Control wizard.
Howto: reset IE security zone settings programmatically
- 26 November 2012
Internet Explorer 7 introduced the IInternetZoneManagerEx2 interface, which has a FixUnsecureSettings method to reset all security zone settings. Like all other IInternetZoneManager* interfaces, you can query this interface from the internet zone manager object:
There’s another CoInternetCreateZoneManager function to get the zone manager object’s IInternetZoneManager interface.
What’s new in MFC/ATL 11 Beta
- 22 April 2012
Note this post is on Visual Studio 11 Beta, you can download it from http://www.microsoft.com/visualstudio/11/en-us/downloads Since Sinofsky posted about no desktop apps on Windows on ARM (WOA), it looks like MFC and ATL are going to support metro-style apps, although most ATL classes are not going to be compatible with metro style apps.
DAO support for ARM is missing, just like the lack of DAO support for 64 bit apps. Jet was deprecated a while ago, no surprise here.
What is the Windows API for
- 21 March 2012
There are the questions programmers ask frequently. This faq does not contain sample code, readers should use keywords (showing in bold, such as function names, CLSIDs or interface names) to find complete solutions elsewhere.
Q: What is the Windows API for the Start Menu?
Choosing formats when putting data on clipboard
- 21 March 2012
The topic is from a forum discussion at https://web.archive.org/web/20131020094354/http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/94bb2db4-3ca2-4cd8-9f7c-6dd9aab6fd18/need-help-to-complete-gdi-program-to-loadsave-to-clipboard?forum=windowssdk
Generally an application should provide data in as many formats as possible so more applications can recognize the data. For example, IE stores text data in CF_UNICODETEXT, CF_TEXT and CF_HTML formats.