How do I expand all macros in Visual C++ ?

     CL /EP /C YourCodeFile.cpp

This command will carry out all preprocessor directives and expand macros in the C++ code file "YourCodeFile.cpp". 
The /EP option suppresses compilation. /EP also suppresses the output files from the /FA, /Fa, and /Fm options. 
The /C (Preserve Comments During Preprocessing) option is used to preserve comments in the preprocessed output.

I have a combo box in my dialog, but it won't drop down, why?

You need to set the height of the dropdown. You can do this in the dialog editor. Open your dialog template, then click on the combo box to select it. Now click on the down arrow on the right and you should be able to resize the combo box.

How can I delete a class from my project?

   It's not as easy as it seems. Unfortunately, the Class Viewer doesn't directly support this option, so you have to a lot of work. First, you have to start by removing the .h and .cpp files that implement the class itself. You do this by switching to the 'File' pane of the Class Viewer (that thingy with the three panels: Classes, Resources and Files), selecting the files and pressing the Delete Key in your keyboard. Be aware, however, that this won't delete the actual files, you still have to do it manually from explorer.
Now, you have to go through your code searching for places where you've used the class, and remove those occurrences. You'll also need to delete any #include statements that involve the class .h file.

Why do I get an "Can't access sample data" on VC++ 5 when I try to copy the sample projects?

 The reason for this is an incompatibility with Internet Explorer 4 (IE4). The update that fixes this problem can be obtained by installing the Visual Studio Service Pack 3 (SP3), which you can download from Microsoft's Visual C++ page.

Does VisualC++ take advantage of my SMP machine to compile faster?

  In short: no. The Microsoft C/C++ compiler is not optimized for multiprocessor machines, nor does DevStudio or NMAKE take advantage of them by performing parallel builds. Also, the compiler itself is not [currently] multithreaded, as the compiling process is basically a sequential process. However, you might see some overall performance improvements on an SMP machine.

On the other hand, the compiler is pretty optimized for single-processor machines, which are the most common ones. For example, the compiler can accept multiple filenames on the command line and process them one-by one sequentially. This reduces system overhead, because there is only one compiler instance created for all files, instead of creating a process for each file.

What does Link warning LNK4089 mean, and how can I avoid it?

This warning simply means that you are linking against a library and the linker has detected that you are not really using any functions from it. This warning usually only pops when you are making release builds, because the /OPT:REF switch of the linker that's set by default on release builds asks the linker to trim your resulting executable as much possible by avoiding linking unnecessary dlls in. (this makes the import address table of your executable much smaller).

If you don't care about the warning, you can tell the linker to ignore it by adding the /IGNORE:4089 switch to the linker command line from the Project->Settings dialog

 How can I disable the "No symbols found" messages that show on the debug output window when I debug my program?
This, is not an error message. It simply informs you that the IDE found no debug symbols for the loaded DLL. One good way to get rid of the "error" is to actually install the Windows NT/2000 debug symbols on your CD, which you can download from the Microsoft website, or from the CD marked "Customer Diagnostic and Support Tools" on your MSDN subscription. As an added benefit, you'll have a much easier time debugging complex problems.

I put a RichEdit control on my MFC Dialog-based app and the program won't run anymore. What do I do?

                         You have to load the richedit control's library explicitly. To do this, call AfxInitRichEdit() from your InitInstance() function in your CWinApp-derived class.

How can I handle dynamic menus in MFC?

 The problem with handling dynamic menus in MFC is that you obviously can't set up standard menu handlers for them, as you don't know their ID's until runtime. However, there's a simple way to do it: Overriding OnCmdMsg(). By doing this, you get first chance at catching the menu events so you can handle them properly.

How do I prevent my application showing a button on the taskbar?

One method is to give your window the WS_EX_TOOLWINDOW style. However, this has the side effect of making your application's caption bar much smaller than a normal caption bar, and may not be ideal. The best method is to make the application's top level window have a parent window that is invisible.

How do I display a bitmap on a button?
You can use a bitmap or an icon on a button, although an icon is a better choice, as icons support transparency.

How do I subclass the Desktop Window?

You cannot subclass the real desktop window, as it is a hidden window, and you'll get strange results should you try it. 
However, the window most people call the desktop is in reality a ListView control, which is a child of the real desktop and it's owned by explorer.exe. You can find out this window using Spy++, which is included with Visual C++. Be aware, however, that it's not guaranteed that this will be so in all Windows versions, and it might change in the future.

To subclass the window you need to inject your code into explorer's process, because you can't directly subclass windows across process boundaries. The easiest way to do this is to put your subclassing code into a dll and using SetWindowsHookEx() to hook the window before subclassing it. That will cause Windows to load your dll into explorer's address space, and you can then proceed from there.

Why Array Index starts from Zero?

This boils down to the concept of Binary digits. Take an array size of 64 for example. We start from 0 and end at 63. We require 6 bits.But, if we were to start from 1 and end at 64, we would require 7 bits to store the same number, thus increasing the storage size. 

What is Microsoft (R) Visual C++ for Windows CE?

         Visual C++ for Windows CE is an add-on for Visual C++ 5.0 that allows developers to target applications to Windows CE-based devices. The add-on includes all of the headers, libs and DLLs needed to write code and cross compilers to build for Handheld PCs running Windows CE. Visual C++ is required and is licensed separately.

 Can I use Visual C++ for Windows CE to write applications on my handheld PC? (Can I write code while away from my desk using Visual C++ for Windows CE?)
             Visual C++ for Windows CE runs on the desktop PC, just like Visual C++. You cannot run Visual C++ for Windows CE on a Windows CE device.

Do I have to write different code for each device?
The Windows CE cross-compilers allow developers to create a single set of code that is then targeted towards a CPU. The same source can be used to compile for any of the supported CPUs and the compilers were built with chip specific optimizations to create the smallest and fastest code possible for the target.

Do I have to buy a handheld PC in order to begin developing? What if I do not know whether my application will work?

           Visual C++ for Windows CE also includes an emulation environment that can be used for initial testing and development before investing in additional hardware.

 Do I have to be running Windows NT?

The emulation environment only runs under Windows NT, a unicode environment is necessary for the emulator to operate properly. Otherwise, Windows 95 can be used to develop applications using Visual C++ for Windows CE using any off-the-shelf Windows CE device.

What else is provided as far as tools and debuggers?

                Windows CE versions of the Developer Studio tools are also included and provide the means to check memory, edit the registry, manipulate the object store, "spy" on and debug applications running on a handheld PC over a standard serial cable that comes with any off-the-shelf Windows CE-based devices. The Windows CE remote debugger has all of the functionality of the Visual C++ application debugger, including Data Tipstm, multiple watch windows and advanced "locals" windows. With the remote debugger, you can set breakpoints, control program execution, and view register values.

Where can I get a copy of Visual C++ for Windows CE?

                             Visual C++ for Windows CE is sold directly through Microsoft. You can get ordering information from the web site ( or visit to order online. HP suggests you go to express checkout or go through the Visual C++ section from the product shelf to order the product

How can server communicate with more than one client?

                Server can communicate with more than one client with using threading concepts there are java threads which are allocated to every client when he logs in to server,the thread handles the client. 

 How to change the Text of a CButton at Runtime?

    CButton *btnsample= (CButton *)GetDlgItem(IDC_BUTTON1); //suppose IDC_BUTTON1 is the ID of CButton

How to change the Size of CButton at Runtime?

      CButton *btnsample = (CButton *)GetDlgItem(IDC_BUTTON1);///suppose IDC_BUTTON1 is the ID of CButton/

When I build a Visual C++ project, how do I perform additional action before compiling?

   You can use the pre-build event. In the Command Line of pre-build event in the project properties, specify any command that is legal at the command line or in a .bat file.  You can use build events to specify commands that run before the build starts, before the link process, or after the build finishes.

 How do I get the system information with Visual C++?

 The System Information Functions are used to retrieve or set system information like The EnumDisplayDevices function lets you obtain information about the display devices in the current session.  The IP Helper Functions retrieve and modify configuration settings for the TCP/IP transport on the local computer.

Academic Projects