c++

Custom UserControls in C++

In Native C++, how do you add a usercontrol like in vb .net where you do form.controls.add(controls) Because for instance, what if I wanted to make a usercontrol class that inherits from panel? How is this done in c++ Thanks ...

Qt and Sqlite examples

I am looking for some example code using Qt and it's SQL module with Sqlite driver. Main reason I need examples for is that I've prior experience with Qt's database interface and Sqlite has some weird behavior with field types (types are stored per-field, not per-column). ...

Bringing libcurl into a C++ program

I'm trying to pull libcurl into a large C++ project. However I am having trouble getting it to compile. I see errors coming from ws2def.h, winsock2.h, and ws2tcpip.h Some of the errors look like this: error C2061: syntax error : identifier 'iSockaddrLength' ws2def.h 225 error C3646: 'LPSOCKADDR' : unknown override specifier ws2...

What does sizeof(char *) do?

I was reading through the c++ Primer and this code snippet came up and I was wondering what does the sizeof(char *) do and why is it so significant? char *words[] = {"stately", "plump", "buck", "mulligan"}; // calculate how many elements in words size_t words_size = sizeof(words)/sizeof(char *); // use entire array to initialize w...

How to compare two BSTRs or CComBSTRs?

Hi, What is the right way to compare two CComBSTRs? I tried to use bool operator ==( const CComBSTR& bstrSrc ) const throw( ); However it always return false even two ComBSTRs are the same. It did not work correctly. Do I have to convert CComBSTRs to ANSI string first and then use strcmp? Thanks! -bc ...

Vector Ranges in C++

Another quick question here, I have this code: string sa[6] = { "Fort Sumter", "Manassas", "Perryville", "Vicksburg", "Meridian", "Chancellorsville" }; vector<string> svec(sa, sa+6); for (vector<string>::iterator iter = svec.begin(); iter != svec.end(); iter++) { std::cout << *iter << std::endl; } ...

Given a start, end, and increment value, I want an algorithm that counts up and down.

Ok, I have a control that want to fade in and out (continuously). In order to fade it I adjust the transparency value of the control in the drawing routine. So I set up a timer that runs and I adjust the m_transparency member. The timer runs and it should sweeps back and forth between the two defined values m_start, m_end. These can be 0...

Perform a simple HTTP request using C++ / Boost via a proxy?

I'm quite a newbie with Boost, and my only experience of surfing though a proxy using a library is using .NET (that is really convenient for that purpose). I'm now trying to perform a simple HTTP request through a HTTP proxy. Is there a tidy way to do it using boost directly? My proxy use a NTLM authentification. ...

Creating dummy shared object (.so) to depend on other shared objects

I'm trying to create a shared object (.so) that will make it so, by including one shared object with -lboost, I implicitly include all the boost libraries. Here's what I tried: #!/bin/sh BOOST_LIBS="-lboost_date_time-gcc43-mt -lboost_filesystem-gcc43-mt" #truncated for brevity g++ $BOOST_LIBS -shared -Wl,-soname,libboost.so.1 -o libb...

Doxygen not working on Public block(s) after Private block in Class

How do I tell Doxygen to document public sections after a private section in a (C++) class? E.g. class Brg { public: //! this function will be documented void documentedFunction1() private: void irrelevantFunction() public: //! this function will _not_ be documented void undocumentedFunction1() }; Even w...

C++ array to string

I have a vector<int> container that has integers (e.g. {1,2,3,4}) and I would like to convert to a string of the form "1,2,3,4" What is the cleanest way to do that in C++? In Python this is how I would do it: >>> array = [1,2,3,4] >>> ",".join(map(str,array)) '1,2,3,4' ...

looking for a keyboard API

looking for a library for accessing the keyboards functions, key states, etc. the language I'm planning on using is C++ ...

C++ design issue

Hi All, Here is the problem description of my design. There is a class A (Singleton) which creates and maintains objects of class B. But there is such scenario where if a particular condition hit in object of class B, it has to create another object of class B. But I need this creation of object to be done by class A. class B; class...

While Loop Taking Alot of CPU Usage

I am creating a keystroke logger for my personal interest, as well wanting to know how to capture and use them as functions (like key shortcuts). I got the code to learn how keylogger and GetAsyncKeyState() work: http://www.rohitab.com/discuss/index.php?showtopic=9931 I got it to run under Code::Blocks, but the weirdest things is that ...

Help in combining two functions in c++

I am just trying something with someones code. I have two functions: int Triangle(Render *render, int numParts, Token *nameList, Pointer *valueList) int i; for (i=0; i<numParts; i++) { switch (nameList[i]) { case GZ_NULL_TOKEN: break; case GZ_POSITION: return putTrianglePosition(render, (Co...

How to set different timeouts for each socket that select() monitors?

I am currently using the BSD sockets API. I would like to use the select() function to monitor (a) the listener socket which waits for new connections using accept(), and (b) all the client sockets created via accept() or connect(). I want the listener socket to not have any timeout, and I want each client socket to have a timeout of 120...

How can we initialize the structure?

Suppose there is a structure such as: struct XYZ { double a; double b; } Now we make an object of it struct XYZ abcd[10]; and now I am filling this array. I have to initialize this array because I call this in a loop and it overwrites the previous values. If it overwrites the previous 5 values by 4 new values then still the 5th ...

How to output floating point numbers in the original format in C++?

It's a coding practice. I read these numbers as double from a file: 112233 445566 8717829120000 2.4 16000000 1307674.368 10000 2092278988.8 1234567 890123 After some computation, I should output some of them. I want to make them appear just the same as in the file, no filling zeros, no scientific notation, how could I achieve it? Do I ha...

What is the difference between PostMessage and AfxBeginThread?

Hi, I can acheive the same functionality by both PostMessage and AfxBeginThread ( calling asynchrously ) So where lies the the difference between PostMessage and AfxBeginThread? ...

Using Windows Vista Credentials

Hi all i am using CredUIPromptForWinodwsCredentialw for prompting the user for verifying his/her credentials how can i verify these credentilas. the code i am using is BOOL save = false; DWORD authPackage = 0; LPVOID authBuffer; ULONG authBufferSize = 0; CREDUI_INFO credUiInfo; DWORD logininfo; credUiInfo.pszCaptionText = T...