c++

Flash ActiveX: How to Load Movie from memory or resource or stream?

I'm embedding a Flash ActiveX control in my C++ app (Flash.ocx, Flash10a.ocx, etc depending on your Flash version). I can load an SWF file by calling LoadMovie(0, filename), but the file needs to physically reside in the disk. How to load the SWF from memory (or resource, or stream)? I'm sure there must be a way, because commercial sol...

Does overriding OnNcPaint() affect the painting of the client area of a window?

I want to change the appearance of a window's caption bar, so I decided to override the OnNcPaint() method of CMainFrame. But when I did this, I found a problem. If there is another window covering my window, and I drag the window quickly, the content of the client area of my window disappeared, which came to sight only when I stopped th...

Since I can't return a local variable, what's the best way to return a string from a C or C++ function?

As a follow-up to this question: From what I've seen, this should work as expected: void greet(){ char c[] = "Hello"; greetWith(c); return; } but this will cause undefined behavior: char *greet(){ char c[] = "Hello"; return c; } If I'm right, what's the best way to fix the second greet function? In an embedded environme...

Use of CoGetClassObject() in C - access COM Object interface

Instruction on accessing a interface to an application, in plain C/C++ without: MFC ATL WTL Basically, I would like to make use of a COM object. Working sample source code or guidance - to using (functionality) a COM object, not creating a COM server. Regards ...

What can C++ do that is too hard or messy in any other language?

I still feel C++ offers some things that can't be beaten. It's not my intention to start a flame war here, please, if you have strong opinions about not liking C++ don't vent them here. I'm interested in hearing from C++ gurus about why they stick with it. I'm particularly interested in aspects of C++ that are little known, or underut...

How do you block selected applications from accessing the internet (C++, Win32)

I want to have an application or service that is running that, on some schedule, can disable access to the internet for all applications except for specific ones. I'm trying to create a filter that can be turned on or off under programmatic control. Not just IP addresses and ports, but I want to be able to block specific applications as...

What are the tell-tale signs in an interview that a developer is not competent?

I'm specifically talking about interviewing for a position for a very experienced and competent C++/C#/Java systems developer, not a html, javascript web developer position. In my experience nervousness is often not a good indicator, because many good developers get very nervous under pressure, so what is a good indicator? Hmmm... so...

How to pass a COM method as a function argument? And Microsoft Compiler error C3867.

Hello, I would like to pass a COM method as a function argument but I get this error (Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86): error C3867: 'IDispatch::GetTypeInfoCount': function call missing argument list; use '&IDispatch::GetTypeInfoCount' to create a pointer to member What am I missing? Tha...

What's the best way of ensuring valid object lifespan when using Boost.Asio?

Hi all. Been playing a lot with Boost.Asio of late. I like the library a lot since it offers a fantastic way to squeeze performance out of today's multicore systems. A question I have asked myself a few times, and I thought worth throwing out there regards object lifespan / ownership when making async calls with Asio. The problem I'v...

easy way to add 1 month to a time_t in C/C++

I have some code that uses the Oracle function add_months to increment a Date by X number of months. I now need to re-implement the same logic in a C / C++ function. For reasons I don't want/need to go into I can't simply issue a query to oracle to get the new date. Does anyone know of a simple and reliable way of adding X number of m...

Symbian C++ - Use a TTF font in your application?

Hi Is it possible to package a .TTF file in your application and use it to render text at runtime, and have the application release the font after use? I've found bits of information scattered around the forum, but nothing conclusive. Can anyone offer any advice? ...

How to link a .DLL statically?

We have a (pure native C++) .DLL that is build by VS. As clients we have some native C++ applications and a .Net-Wrapper around this DLL written in C++/CLI. Finally there are some client applications for the .Net-Wrapper written in C#. My problem is that the native.dll must be distributed in a different way than the .Net world works and...

Can I access private members from outside the class without using friends?

Disclaimer Yes, I am fully aware that what I am asking about is totally stupid and that anyone who would wish to try such a thing in production code should be fired and/or shot. I'm mainly looking to see if can be done. Now that that's out of the way, is there any way to access private class members in C++ from outside the class? For...

What kind of code library should I build for distribution?

I need to build a C++ library to distribute among our customers. The library must be able to be accessed from a wide range of languages including VB6, C++, VB.net and C#. I've being using ActiveX controls (ocx files) until now. But I wonder if there is a better kind of library (dll, etc.) that I can build. What do you recommend? I'm li...

C++ and gnuplot

Hi everybody! This is my first post and I'm quite a novice on C++ and compiling in general. I'm compiling a program which requires some graphs to be drawn. The program create a .dat file and then i should open gnuplot and write plot '.dat'. That's fine. Is there a way to make gnuplot automatically open and show me the plot I need? I s...

How do I open a new document in running application without opening a new instance of the application?

I have a situation that has been partially covered by other answers at SO, but I cannot find a complete answer. In short, we are trying to use URL's for our specific data types that when double clicked will open up our application and load those data sets into that app. We have this part working. (for example, an URL might look like t...

Difference between C/C++ Runtime Library and C/C++ Standard Library.

Can you guys tell me the difference between them? BTW is there something called C++ library or C library?? Thanks. Dazza ...

C++ DLL: Not exposing the entire class

How can I "hide" parts of a class so that whoever is using the libary does not have to include headers for all the types used in my class. Ie take the MainWindow class below, ho can I have it so when compiled in a static/dynamic libary, whoever is useing the libary does NOT have to include windows.h, ie HWND, CRITICAL_SECTION, LRESULT, e...

How do you return a vector iterator from a variable in a templated class?

I'm trying to return an iterator for a vector in a templated class (I'm not sure if that makes a difference, but I've read that may, so I thought I'd mention it). The problem is that I get an error about C++ not supporting default-int when I try this. I've looked online and from what I can see in forums and explanaions, I don't think I...

Inheriting from a non-templated class that has a templated constructor - how to resolve ambiguity?

Hello all, Let's say we have a class, MyParent: class MyParent { public: template<namespace T> MyParent() { T* Something; } }; And a derived class, which uses this constructor: class MyDerived : public MyParent { public: MyDerived() : MyParent<int>() { } }; Then I get a compiling error, because there's ambiguit...