c++

How do I get the default check box images?

I'm trying to build an owner-drawn check box using CButton, but since I only want to change the text color, I'd like the check-box marks to remain the same. Is there a command that allows me to retrieve the default check box bitmaps for the platform where the program is running? (alternatively: how could I change only the text color,...

C/C++ - Any good web server library?

Are there any open source, fast web server libraries? Thanks. ...

How do I best silence a warning about unused variables?

I have a cross platform application and in a few of my functions not all the values passed to functions are utilised. Hence I get a warning from GCC telling me that there are unused variables. What would be the best way of coding around the warning? An #ifdef around the function? #ifdef _MSC_VER void ProcessOps::sendToExternalApp(QS...

Copy constructor: deep copying an abstract class

Suppose I have the following (simplified case): class Color; class IColor { public: virtual Color getValue(const float u, const float v) const = 0; }; class Color : public IColor { public: float r,g,b; Color(float ar, float ag, float ab) : r(ar), g(ag), b(ab) {} Color getValue(const float u, const float v) const ...

Qt4 modular synth editing widget

Hi, I'm about to start writing a GUI for a modular synthesis app (like Alsa Modular Synth, Pure Data, Ingen) that will be used for patch (sound) editing. What I need to do is something like this: So, basically, it's an area where I can draw some rectangles (boxes) that represent synth modules with input and output ports that I ca...

Qt stylesheets: QHeaderView draws header text in bold when view data is selected

I'm trying to style a QTableView with Qt Stylesheets. Everything works OK, except that all the table header texts (column headers) are drawn as bold text whenever data in the table view is selected. I've tried things like this: QTableView::section { font-weight: 400; } QTableView::section:selected { font-weight: 400; } QHeader...

Why do Boost Parameter elected inheritance rather than composition?

I suppose most of the persons on this site will agree that implementation can be outsourced in two ways: private inheritance composition Inheritance is most often abused. Notably, public inheritance is often used when another form or inheritance could have been better and in general one should use composition rather than private inhe...

hex string to signed short int in c++

Hi, I could find the code to convert a hexadecimal string into a signed int (using strtol), but I can't find something for short int (2 bytes). Here' my piece of code : while (!sCurrentFile.eof() ) { getline (sCurrentFile,currentString); sOutputFile<<strtol(currentString.c_str(),NULL,16)<<endl; } My idea is to read a file with 2 byt...

Debugging multitheaded programs

I have been a C programmer for many years and my favorite "debugger" has always been the printf() function - I only resort to visual studio's debugger when absolutely forced and so have never been very proficient in using it. Recently I have had to modify a program from C to C++ (although of course printf still works fine) and and parts ...

How to work out which widget to target with Qt stylesheets

Hi, I'm attempting to use Qt stylesheets to style a reasonably complex UI. So far things are going reasonably well, but I'm running into a difficulty: How can I work out what widget name I should be targeting for a particular part of a UI? For example, if I want to change the font size in the cells of a QTableView, do I write a style t...

C++ Cross-Platform High-Resolution Timer

I'm looking to implement a simple timer mechanism in C++. The code should work in Windows and Linux. The resolution should be as precise as possible (at least millisecond accuracy). This will be used to simply track the passage of time, not to implement any kind of event-driven design. What is the best tool to accomplish this? ...

What could be causing this crash?

I have a C++ program (GCC) and when I add one or more int members to an abstract base class, the program starts crashing. In the case I've exampled, it seems that by adding this member, a member in a derived class quits getting initialized (or gets stomped on at some point). If I add more members, it starts (not) working different. This ...

Search Hex substring in string

Hi all! Well i got a socket that receives binary data and I got that data into an string, containing values and strings values too. (for example "0x04,h,o,m,e,....") How can i search for an hex substring into that string? I.e. i want to search "0x02,0x00,0x01,0x04". I'm asking for a c++ version of python 'fooString.find("\x02\x00\x01...

access violation in WM_PAINT not caught

To test this problem I have written a minimal windows application. If I force an access violation in the WM_PAINT handler this exception never gets to the debugger. If started without debugger the access violation also does not show up. Usually you should get the Windows Error Reporting dialog. Digging a bit deeper it seems that somethi...

Debugger question

I have a bug I am chasing (I think its a deadlock). When I run the code it hangs without the debugger flagging an error, so after a while I try pressing the pause (break all) button. The debugger then reports "The process appears to be deadlocked...". I then can see that all the threads are held up at lines saying EnterCriticalSection ex...

malloc_error_break causing C++ SIGABRT

What is wrong with my code? (I'm trying to at least get copy a file with this code in XCode (OS X 10.6 Snow Leopard.) I keep on getting a SIGABRT with an malloc_error when running: Lesson 4(796) malloc: *** error for object 0x10000a8a0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Here's th...

Jumping straight to network container

Hello, I am currently working on a project where I need to get all the computers inside a network resource. I am currently using WNetOpenEnum and its associated functions to find the computers, but as this is running on a large network, it takes a while to iterate through all the network workgroups. Is it possible just to 'jump' to a c...

Stringifying template arguments

Is it possible in C++ to stringify template arguments? I tried this: #define STRINGIFY(x) #x template <typename T> struct Stringify { Stringify() { cout<<STRINGIFY(T)<<endl; } }; int main() { Stringify<int> s; } But what I get is a 'T', and not an 'int'. Seems that the preprocessors kicks in before tem...

play video clip in windows c++ app

Im currently using wxMediaCtrl to play videos in my app. The api is unfortunately a little buggy, and doesn't playback all media types i need to support (e.g. wmv). I am wondering if there is an alternative c++ api, that will allow me to do this. I am currently just concerned with supporting windows. What do people normally use to embe...

Malloc/Bus error with fprintf

Hi I am getting a malloc error with bus error on using the fprintf statements in C++ (code below). Any pointers on what could be going wrong? Note absAmb and dModel both have valid values. Thanks. FILE *fPtr; char fName[100]; sprintf(fName, "Info.dat", block); if ( (fPtr = fopen(fName,"w")) == NULL ) { return( FALSE ); } int ab...