Posts in Visual Studio

Book review: Mastering Windows 8 C++ App Development

Disclaimer: I am a Microsoft MVP in Visual C++, so is Pavel Yosifovich, the author of the book. Mastering Windows 8 C++ App Development by Pavel Yosifovich is a new addition to the Windows Store development books. It took me a while to read (304 pages) but is well worth the time from the perspective of a C++ developer. The book obviously went through great lengths to be comprehensive, not only introduced the typical Windows Runtime (WinRT) APIs in a crisp manner but also added a refreshment of C++ 11, the Model View ViewModel (MVVM) pattern, and the Windows Runtime C++ Template Library (WRL). In addition, being a book for C++ developers, the author’s emphasis on performance can be found in several tips and discussions, which is a nice focus for C++ developers. There are also several weaknesses in the book. Introducing WRL before C++/CX may be a poor choice as it is difficult to inspire the reader with laborious code. Also the book could use a few more details on DirectX and some WinRT APIs such as GeoPosition. Nevertheless, the book is an excellent text for the subject and I recommend the book to C++ programmers who want to start developing Windows Store apps and can do research outside of the book.

Read more ...


When you get a System.BadImageFormatException. maybe you indeed have a bad system image.

I am getting a StackOverflowException with two functions repeating on the call stack, one is the constructor of System.BadImageFormatException, another is System.Environment.GetResourceStringLocal.

Read more ...


How to: Migrating a CLR console Visual C++ project to Windows Forms

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. The basic steps are listed at http://support.microsoft.com/kb/317433, conveniently named “How to suppress the console window for a managed extensions to Visual C++ Windows Forms application”. Yes, the need to convert a C++ console application to windows forms is that old, back all the way back in the managed extensions for C++  days. So what I need to do to add Windows Forms support to a C++/CLI console application? Of course the System.Windows.Forms.dll reference is missing in a new console application, so I need to reference it:

Read more ...


Add the correct interface first in Adding an MFC Class from an ActiveX Control wizard.

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.

Read more ...


Howto: reset IE security zone settings programmatically

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:

Read more ...


Bug in Security Update for Visual C++ Redistributable Package: April 12, 2011 causes program error on Windows 2000

Update:Microsoft’s Visual C++ team has released workarounds on the problem. AVG has released an utility that can revert the KB2467175 update, downloadable at http://twitter.blog.avg.com/2011/04/avg-feedback-update-26411.html

Read more ...


How to solve LNK2001 errors related to Windows SDK CLSIDs

User IMFCoder wants to know how to solve a LNK2001 error related to CLSID_CMpeg4sDecMediaObject. The user has no problem linking a lib file in the project but couldn’t find which lib the CLSID is in.

Read more ...


What is the difference between int and System::Int32

Some may say identical, at least that’s what the Visual C++ compiler tells you at the first glance  when you turn on /oldsyntax public __gc class Class1 { public: void F1(int a){} void F1(System::Int32 a){} //Error    2    error  2535:  void Class1::F1(int)’ : member function already defined or declared } Okay, so if I add & to the parameter types I should get the same error right?void F1(int&a){} void F1(System::Int32& a){} Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped Wait, didn’t I get an error just now? You are right, somehow the compiler treat the two types differently when passing by reference. look at the function signatures in MSIL. Int32 is passed by reference as expected

Read more ...


How to force popup window to navigate in the same window in a webbrowser control

When clicking on an link that targets a new window,  the default behavior of a webbrowser control host application is to open a new window in Internet Explorer. User ben_lai wants to know how to handle the click and navigate to the same window.

Read more ...


Intercept the download dialog in webbrowser control

User rsd102 looks already find the solution to his question when he posted the question to CSDN, except for one missing piece. The sample he found is for overriding the global download manager, and what he need is a process wide override.

Read more ...


How to change the user agent and download control flags in a webbrowser control host

User vnetvvv wants to know how to change the user agent string in a VB6 webbrowser control.

Read more ...


Walkaround for Error : An add-on for this website failed to run. When opening Visual C++’s Add Variable Wizard after IE 8 is installed

Update: it looks like a lot of people are hitting this page by mistake. If you don’t write software for a living then this page is probably not for you.

Read more ...


MFC更新Beta版

一个面向Visual C++ 2008的MFC更新测试版已经发布,同时也提供了文档的下载。这个版本包含新的界面的特性,例如Office Ribbon、2003和XP风格,Visual Studio风格和MDI标签。另外,这个版本也包含部分TR1的实现,例如正则表达式、更加丰富的集合和智能指针。 另外,在下载页面居然说这个版本还不支持Visual Studio 2008 Service Pack 1的Beta版,正式版才出来几天SP1的测试版就出来了?

Read more ...


Visual C++ 2008 Beta2 里面的Class Designer

image

Read more ...


STL/CLR, Compiler and Marshaling

MSDN第9频道又采访了Visual C++类库组的项目经理Nikola DudarSarita Bafna,以及质量控制组的Marina Polishchuk尽管Visual C++项目组已经转移了工作重点,但是很少人注意到这一点。或许这些采访可以帮助你了解Visual C++项目组的工作。 为什么C++仍旧重要?

Read more ...


Microsoft MVP re-awarded again

亲爱的 Sheng Jiang, 热烈祝贺并欢迎您参与 Microsoft® MVP Program! 作为本年度“最有价值专家”(Most Valuable Professional) 奖的获奖者,您成为了我们精英群体中的一员,在全球网上和网下技术社区中与他人积极分享 Microsoft 的产品和技术。Microsoft 向所有用技术帮助他人发挥潜力,从而促进社区发展的 MVP 们表示崇高的敬意。要了解有关 MVP Program 的更多信息,请访问:www.microsoft.com/mvp。 非常感激您在过去的一年中在指导Visual Developer - Visual C++技术社区中的同伴方面所做的杰出贡献。

Read more ...


How to use Visual C++ with Perl

Microsoft Visual C++ and later do not support perl scripts by default. That is, the Developer Studio does not associate any special significance to perl scripts without being informed otherwise. However, there are several viable options, namely custom build rules, which enable the creation of projects that depend directly upon perl scripts. The remainder of this article discusses the following three methods for adding perl script files to a Visual C++ project:

Read more ...


《转换指南: 将程序从托管扩展C++迁移到C++/CLI》译后

终于把Stan Lippman先生的这篇文章译完了。从去年4月在全球MVP峰会上拿到这篇文章的手稿到现在,差不多一年过去了。虽然当时的Visual Studio 2005还不支持一些语法,但是我和董颖涛对新的C++/CLI语言都很感兴趣,在当时就讨论过翻译的问题。之后我就开始翻译这篇文章,但是进度一直很慢——主要是杂务太多、语言上的困难(尽量避免误解和词不达意的情况,以及斟酌用词的选择)。在1月份完成了全文之后,看到了Sunhui的一篇文章(http://community.csdn.net/expert/Topicview1.asp?id=3834281),觉得附录里面讲到的一些内容或许一些人也有兴趣,所以继续翻译附录的工作,幸好现在是春假,比较有时间,终于在今天完成了。译文目前在http://blog.csdn.net/jiangsheng/archive/2004/10/18/140450.aspx可以访问,希望读者指正。

Read more ...