visual-c++

GCC with Visual Studio?

How hard would it be to use GCC instead of VC++ from within Visual Studio 2008? Obviously, some of the keywords won't match, and some may not get syntax highlighting (unless you made a new language service). Is this what a 'makefile project' is for, pretty much? ...

MFC: Changing the colour of CEdit

Guys, can someone give me a brief run through of how to change the background colour of a CEdit control at runtime? I want to be able to change the background to red if the field is zero length and the normal white otherwise. ...

Is there an equivalent to -pedantic for gcc when using Microsoft's Visual C++ compiler?

I would like to have my warnings set to the highest level using Microsoft Visual C++ compiler. Similar to using -pedantic on gcc. What compiler switches do you use to have the most warnings enabled? ...

VC++ MFC edit box sorting

How do I sort the date and time in decending order in edit box? ...

Why destructor is not called on exception?

I expected A::~A() to be called in this program, but it isn't: #include <iostream> struct A { ~A() { std::cout << "~A()" << std::endl; } }; void f() { A a; throw "spam"; } int main() { f(); } However, if I change last line to int main() try { f(); } catch (...) { throw; } then A::~A() is called. I am compiling with "Micr...

How to script Visual Studio 2008 from Python?

I'd like to write Python scripts that drive Visual Studio 2008 and Visual C++ 2008. All the examples I've found so far use win32com.client.Dispatch. This works fine for Excel 2007 and Word 2007 but fails for Visual Studio 2008: import win32com.client app1 = win32com.client.Dispatch( 'Excel.Application' ) # ok app2 = win32com.client.Di...

Constant value in conditional expression

In a coding style question about infinite loops, some people mentioned they prefer the for(;;) style because the while(true) style gives warning messages on MSVC about a conditional expression being constant. This surprised me greatly, since the use of constant values in conditional expressions is a useful way of avoiding #ifdef hell. F...

Embed image in code, without using resource section or external images

I'm looking for a way to embed an image in a library (Windows-only). I don't want to go the 'traditional' way of putting it in the resources (because of special circumstances that make it not so convenient to mess around with the resource handle. Ideally, there would be something like xpm files: a 'text' representation of an image that ...

How to load string of array in to combobox faster in MFC?

I have an array of 1000 strings how to load them in to combo box faster like kind of dumping in to rather than iterating it? And to copy the combo box data to some 10 other combo box? ...

Strategies for multicore builds (/MP) that use #import

I'm working on a new solution configuration for our large VC++ project using VS 2008. I'd like this configuration to use the multicore build flag /MP. However, the "#import" feature of generating COM wrapper classes is sprinkled through-out the code base and this feature is not supported when using /MP. I understand why #import won't ...

How can I set the flag FILE_FLAG_BACKUP_SEMANTICS for an fstream object?

How can I set the flag FILE_FLAG_BACKUP_SEMANTICS for an fstream object? You can set most flags with fstream, but it seems like this one is not availble. You can read about the flag here. ...

VC++ problem with 64 bit oracle client with OpenforwardOnly flag in database connection.

Hi, I am porting an existing windows based C++ application to 64 bit environment and this is one of those weird errors. In the code snippet you can that I am using openforwardonly and it used to work fine with our old setup but in the 64 bit environment it gives the problem of fetching only ONE recordset. Or it could be a problem with th...

How to change item size and gap between them in Custom Drown CListCtrl

As far as I know ON_WM_MEASUREITEM does not get called in Custom Draw list control. It is only used if control is Owner Drawn. I have found a way to do that, but it is somewhat a HACK and I still can not control gaps between items they are set up somehow automatically. The trick is that you can create CImageList with the unused images of...

How to use std::signaling_nan?

After looking at another question on SO (Using NaN in C++) I became curious about std::numeric_limits<double>::signaling_NaN(). I could not get signaling_NaN to throw an exception. I thought perhaps by signaling it really meant a signal so I tried catching SIGFPE but nope... Here is my code: double my_nan = numeric_limits<double>::sig...

Anything I should know before converting a large C++ program from VS2005 to VS2008?

Is there anything I should know before converting a large C++ program from VS2005 to VS2008? ...

Monitoring a folder for new files in Windows

What is the best way to go about monitoring a folder to see when an image file has been added to it? Files are added approximately once a minute and the naming goes like this... image0001.jpg, image0002.jpg, image0003.jpg etc. I need to know when a file has been written to the folder so that my app can access and use it. ...

Class Constructor never executed in release mode.

Exactly what the title says. I'm using MSVC++ 2008 express, and my class constructor is never executed when compiled in release mode. It DOES work in debug mode. I am doing something like: ClassTest test; test.DoIt(); Breakpoints on DoIt(); trigger, but breakpoints on ClassTest::ClassTest(); do not. ...

VC++ linker errors on std::exception::_Raise and std::exception::exception

I am using Visual C++ 2005 Express Edition and get the following linker errors: 19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ) referenced in function "protected: static void __cdecl std::v...

DSOFramer closing Excel doc in another window. If unsaved data in file, dsoframer fails to open with "Attempt to access invalid address"

I'm using Microsoft's DSOFramer control to allow me to embed an Excel file in my dialog so the user can choose his sheet, then select his range of cells; it's used with an import button on my dialog. The problem is that when I call the DSOFramer's OPEN function, if I have Excel open in another window, it closes the Excel document (but l...

What's the latest version of Boost compatible with VC++6?

What is the latest version of the Boost library that is compatible with Microsoft Visual C++ 6? And can you provide a link to download it directly? The Downloads link at http://www.boost.org only gives a download for version 1.36.0, and the documentation for that version lists Visual C++ 7.1 as the lowest version of Microsoft compiler ...