c++

passing pointers or integral types via performSelector

I am mixing Objective-C parts into a C++ project (please don't argue about that, its cross-platform). I now want to invoke some C++ functions or methods on the correct thread (i.e. the main thread) in a cocoa enviroment. My current approach is passing function pointers to an objective-c instance (derived from NSObject) and do performSel...

Ensuring pointer is not deleted

I've stumbled onto something I can't figure out, so I think I'm missing something in the greater C++ picture. In short, my question is: how to keep a mutable, non-deletable, possibly NULL instance of an object in a class. The longer version is: I have the following scenario: a bunch of classes (which I can change slightly, but not tho...

C++: static function wrapper that routes to member function?

Hi, I've tried all sorts of design approaches to solve this problem, but I just can't seem to get it right. I need to expose some static functions to use as callback function to a C lib. However, I want the actual implementation to be non-static, so I can use virtual functions and reuse code in a base class. Such as: class Callbacks { ...

COM Basic links

Hi, folks can you provide me the tutorial link or .pdf for learning basic COM?. i do google it.. still i recommend answers of stackoverflow so please pass me.. Thanks ...

How do I get the PowerBuilder graphicobject for a given HWND handle?

In my (PowerBuilder) application, I'd like to be able to determine the graphicobject object which corresponds to a given window handle. Simply iterating over the Control[] array and comparing the value returned by the Handle() function for each of the child controls doesn't work, since not all objects in my application are children of t...

CertCreateCertificateContext returns ASN1 bad tag value met

Hi, I'm loading a .p7b certificate file into memory and then calling CertCreateCertificateContext on it, but it fails with the error "ASN1 bad tag value met.". The call look like this: m_hContext = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, pbCertEncoded, dwCertEncodedLen); This returns NULL and GetLastErro...

Template metaprogram converting type to unique number

I just started playing with metaprogramming and I am working on different tasks just to explore the domain. One of these was to generate a unique integer and map it to type, like below: int myInt = TypeInt<AClass>::value; I want to know if this is at all possible, and in that case how. Because although I have learned much about explor...

record duplication in c++

hey i want to know if anyone can tell me how to delete duplicate records or avoid duplication in the first place.... the problem is that whenever i edit a record, a duplicate record is created. can anyone please send an answer?? ...

check type of element in stl container - c++

how can i get the type of the elements that are held by a STL container? ...

Intercepting messages from a child of a child with MFC

I have a CListCtrl class and at the moment when a user selects one of the sub items I am displaying a CComboBox over the subitem which the user can then make a selection from. However I have a problem. When the user has made a selection i need the combo box to disappear (ie intercept CBN_SELCHANGE). The problem is that I need to make ...

How to create a fixed back-end DLL for Pantheios logger

I have a VS 2005 solution that has numerous projects (most are DLL, 1 EXE which is a CppUnit project) and I am trying to add a fixed back-end DLL for the Pantheios logger so that I can use a single logger instance throughout the solution. Following the directions from the below URLs: http://stackoverflow.com/questions/1460185/use-panth...

MySQL/C++ and Prepared Statements: setInt always 0

I'm using the MySQL Connector/C++ library to insert values into a database table. I'm following the examples at http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html almost exactly. However, I can't seem to get prepared statements to work with value placeholders. sql::mysql::MySQL_Driver* driver = sql::mysql::MySQL...

Overloading *(iterator + n) and *(n + iterator) in a C++ iterator class?

(Note: I'm writing this project for learning only; comments about it being redundant are... uh, redundant. ;) I'm trying to implement a random access iterator, but I've found very little literature on the subject, so I'm going by trial and error combined with Wikpedias list of operator overload prototypes. It's worked well enough so far...

Coding Standards / Coding Best practices in C++

Consider the two code segments below. Which one is better and Why? If you have any other idea, please do mention. Where can I find answers to coding practices like these? If you are aware of any book / article, please do share. //Code 1 bool MyApplication::ReportGenerator::GenerateReport(){ bool retval = false; ...

Combine multiple videos into one.

I have three videos: a lecture that was filmed with a video camera a video of the desktop capture of the computer used in the lecture and the video of the whiteboard I want to create a final video with those three components taking up a certain region of the screen. Is open-source software that would allow me to do this (mencoder, f...

how to copy one linked list contents to another linked list

Hi, I have been given list L1, L2. L1 contains 1,2,3 and L2 contains 4,5,6. how do i copy the contents from L2 to the end of L1 so in the end L1 contains 1,2,3,4,5,6. any suggestions? ...

When should you use an STL other than the one that comes with your compiler?

I was curious about STL implementations outside of what's packaged with gcc or Visual Studio, so a quick Google search turned up a few results, such as: Apache stdcxx uSTL rdeSTL Under what circumstances should one use an alternative standard template library? For instance, Apache's page has a list including items such as "full conf...

Am I using a global state here, is there any better way to do this?

I am modifying some legacy code. I have an Object which has a method, lets say doSomething(). This method throws an exception when a particular assertion fails. But due to new requirement, on certain scenarios it is okay to not throw the exception and proceed with the method. Now I am not calling this method directly from the place whe...

Internet Explorer control (or other) rendered onto a directdraw surface

Hi everyone. I'm tasked with modifying an existing c++ codebase which uses directdraw for its UI. Is it possible to make use of a browser control that renders onto one of the (existing) directdraw surfaces? If so, can anyone point me in the right direction on how to get started? (or an alternative approach) Regards all, Jaime ...

In what order are the aggregated classes deleted?

Let's say I have a basic class A that aggregate B and C: class A { B _b; C _c; } in what order are _b and _c going to be deleted? I've read somewhere that it's the reverse order of their allocation. So I guess in this little example _c is deleted before _b, right? Now if I have a A constructor that looks like that: A...