c++

How to easily map c++ enums to strings

I have a bunch of enum types in some library header files that I'm using, and I want to have a way of converting enum values to user strings - and vice-versa. RTTI won't do it for me, because the 'user strings' need to be a bit more readable than the enumerations. A brute force solution would be a bunch of functions like this, but I f...

How do i specify a bold version of the theme's default font?

Hi Guys, I'm having problems with cross theme compatibility in windows forms. If you don't set the font for a control on a windows form, it will use the system font with correct typeface and size. If you want to make the font bold, it hard codes in the rest of the system font values for the current theme you're programming with. For ...

MS CA Exit Module Code or Tutorial

Hi I'm struggling to find examples/explanations of coding a MS Certificate Authority exit module. If anybody has any help or resources they can point me at I'd be grateful. Thanks Mark ...

Enumerating network shared directories in C++ / MFC

I need to get a list of directories shared by the current computer, and their shared names. How do I do this in C++ / MFC? ...

wxWidgets: How to initialize wxApp without using macros and without entering the main application loop?

We need to write unit tests for a wxWidgets application using Google Test Framework. The problem is that wxWidgets uses the macro IMPLEMENT_APP(MyApp) to initialize and enter the application main loop. This macro creates several functions including int main(). The google test framework also uses macro definitions for each test. One of ...

How do I write a short literal in C++?

Very basic question.. how do I write a short literal in C++? I know the following: 2 is an int 2L is a long 2LL is a long long 2.0f is a float 2.0 is a double '\2' is a char. But how would I write a short literal? I tried 2S but that gives a compiler warning. ...

Application Settings

What is a fairly standard way for storing application settings, mainly for windows but also easy to move over to other platforms. There's basically 4 groups of settings I want to have: Global settings, affects all users, and may be moved between machines Global system settings, affects all users, but specific to that system (eg defaul...

How to get pointer from another thread?

Let's have the following class definition: CThread::CThread () { this->hThread = NULL; this->hThreadId = 0; this->hMainThread = ::GetCurrentThread (); this->hMainThreadId = ::GetCurrentThreadId (); this->Timeout = 2000; //milliseconds } CThread::~CThread () { //waiting for the thread to terminate if (...

C++ Variant

I'm in the process of creating a class that stores metadata about a particular data source. The metadata is structured in a tree, very similar to how XML is structured. The metadata values can be integer, decimal, or string values. I'm curious if there is a good way in C++ to store variant data for a situation like this. I'd like for...

How do I guarantee fast shutdown of my win32 app?

I've got a c++ Win32 app that has a number of threads that might be busy doing IO (HTTP calls, etc) when the user wants to shutdown the app. Currently, I play nicely and wait for all the threads to end before returning from main. Sometimes, this takes longer than I would like and indeed, it seems kind of pointless to make the user wait...

MFC: Showing / Hiding Splitter Panes

In my application I have a number of panes from m_wndspliter classes. What I want to do is at run time show and hide one of these panes. Whilst with the following code I can show and hide the view associated with the pane, I can't temporarily remove the pane itself. CWnd * pCurView = m_wndSplitter2.GetPane(2, 0); if( !pCurView == NULL ...

MFC: What on earth is a CSplitterWnd Caret?

What on earth is a caret in the context of a CSplitterWnd class? I can't find any documentation relating explicitly to CSplitterWnds... EDIT: Specifically, what do these functions actually do: CWnd * pCurView = m_wndSplitter2.GetPane(2, 0); pCurView->ShowCaret() pCurView->HideCaret() EDIT2: Please note, I know what a caret is, I am s...

Borland x86 inlined assembler; get a label's address?

Hello I am using Borland Turbo C++ with some inlined assembler code, so presumably Turbo Assembler (TASM) style assembly code. I wish to do the following: void foo::bar( void ) { __asm { mov eax, SomeLabel // ... } // ... SomeLabel: // ... } So the address of SomeLabel is placed into EAX. This doesn't ...

How to start Linux Programming

I am working on C++ and COM/ATL in Windows from last few years. Now I want to shift to Linux Programming. I know basic architecture of Linux. I did some of the projects which are using ncurses, sockets and audio libraries(Terminal Applications). On which tool I should be familiar to start with projects. In windows I have started with Win...

Steps to make a LED blink from a C/C++ program?

What are the easiest steps to make a small circuit with an LED flash from a C/C++ program? I would prefer the least number of dependencies and packages needed. What port would I connect something into? Which compiler would I use? How do I send data to that port? Do I need to have a micro-processor? If not I don't want to use one for ...

Any way to cast with class operator only?

Kind of a random question... What I'm looking for is a way to express a cast operation which uses a defined operator of the class instance I'm casting from, and generates a compile-time error if there is not a defined cast operator for the type. So, for example, what I'm looking for is something like: template< typename RESULT_TYPE, ty...

Doxygen won't index my C++ source - why not?

I have some C++ source code with templates maybe like this - doxygen runs without errors but none of the documentation is added to the output, what is going on? /// /// A class /// class A { /// /// A typedef /// typedef B<C<D>> SomeTypedefOfTemplates; }; ...

Visual studio intellisense for headers without .h

I am using a library that has headers without the .h This defeats visual studio's intellisense (declaration/definition lookup) Anyone know how to tell VS2008 that a file is a header? ...

Tracking automatic variable lifetime?

This may not be possible, but I figured I'd ask... Is there any way anyone can think of to track whether or not an automatic variable has been deleted without modifying the class of the variable itself? For example, consider this code: const char* pStringBuffer; { std::string sString( "foo" ); pStringBuffer = sString.c_str(); }...

C++ Constructor

I'm reading this C++ open source code and I came to a constructor but I don't get it ( basically because I don't know C++ :P ) I understand C and Java very well. TransparentObject::TransparentObject( int w, int x, int y, int z ) : _someMethod( 0 ), _someOtherMethod( 0 ), _someOtherOtherMethod( 0 ), _someMethodX( ...