c++

VC++: non-global old-style function declarations?

In Visual Studio 2003 using pure C, old-style function declarations do not show as global member i.e. void func(blah) int blah;{...} This shows as a global member in the members dropdown: void func(int blah) { ... } This compiles, but old-style does not appear in the global members dropdown: void func(blah) int blah; { ... }...

How to create a bold, red text label in Qt?

I want to write a single, bold red line in my application using Qt. As far as I understand, I would create a QLabel, set its textFormat to rich text and give it a rich text string to display: QLabel *warning = new QLabel; warning->setTextFormat(Qt::RichText); warning->setText("{\\rtf1\\ansi\\ansicpg1252 {\\fonttbl\\f0\\fswiss\\fcharset...

How to detect if errno_t is defined?

I'm compiling code using gcc that comes from Visual C++ 2008. The code is using errno_t, but in some versions of gcc headers including <errno.h> doesn't define the type. How do I detect if the type is defined? Is there a define that signals that the type was defined? In the case it isn't defined I'd like to provide the typedef to let the...

MS VC++ Convert a byte array to a BSTR?

Hi, I have a string that starts out in a .Net application, is encrypted and stored in AD. It's then picked up by a native C++ app and decrypted to produce an array of bytes e.g "ABCDEF" becomes 00,41,00,42,00,43,00,44,00,45 once it has been decrypted at the C++ end. I need to take this byte array and convert it to the BSTR "ABCDEF" so t...

I want to use Infocardapi.dll in Delphi/WIN32 but would like a header file for it.

Microsoft has this nice little feature called CardSpace. This is a Microsoft implementation of InfoCards. Microsoft has a nice document which explains how it can be used, which is useful. And doing a Google search doesn't provide me many useful answers but it does provide an enormous amount of noise. (Mostly because people wonder what it...

[c++ / pointers]: having objects A and B (B has vector member, which stores pointer to A), knowing A is it possible to retrieve pointer to B?

Hello, While trying to learn c++, I tried to implement class representing very basic trie. I came up with the following: class Trie { public: char data; vector<Trie* > children; Trie(char data); Trie* addChild(Trie* ch); // adds child node (skipped others members/methods) }; Method addChild checks if child c...

How to make the ToolTip appear in the foreground of the floating CPaneDialog?

Does anybody has a hint for the following problem? I have a derived class from CPaneDialog, it contains just one button. I want to show a tooltip if the mouse is over it. For this I use CMFCToolTipCtrl: // Create the ToolTip control. m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX); m_ToolTip.Activate(TRUE); CMFCToolTipInfo params...

Switch Programming Language

I've forgotten how to switch programming languages in Visual Studio 2008. I need to switch from C++ to C#. Help! ...

SetWindowsHook stops working after some time

I defined a global hook on WM_MOUSE that works perfectly for some time. It post a message to a specific window each time the mouse move. After some random time the hook stop sending messages. If I unregister and register the hook it works again. I suppose some specific thing happening in Windows cause the hook to stop, but I can't find ...

Waiting with a crash for a debugger?

When an assert fails or there is a segmentation fault, it would be very convenient that one of the following happens: Program ask whether to run a debugger. Program waits with crashing until debugger is attached. Program leaves something (core dump?) that we can resume execution from this point and investigate. The question is quite ...

service and registry

Hello, I have a problem in understanding the relationship between services and registry. I have the task of taking my windows C++ program and transform it from simple application to a service. I read that I need to produce some more functions as: start stop resume install. The problem is: Why I need the regisrty ? how I enter the new...

CMFCButton with Vista Style

I can't seem to get a CMFCButton to be displayed in Vista style in a dialog box application. I'm using VS2008 with MFC Feature Pack. Here are some steps to reproduce my problem: Create a new MFC Project; Specify a Dialog based project. Add two buttons to the main dialog. Add a variable for each button. Make one of the variables a CBut...

Unmanaged C++ tlh file not updating?

I have an IDL file with some interfaces in it. [ object, uuid(newguid), dual, helpstring("NewInterface Interface"), pointer_default(unique) ] interface INewInterface: IOldInterface { [id(newid), helpstring("method NewMethod")] HRESULT NewMethod([in] BSTR bstrParam ); } But when I compile my code it does not see my ne...

Returning const reference to local variable from a function

I have some questions on returning a reference to a local variable from a function: class A { public: A(int xx):x(xx) { printf("A::A()\n"); } }; const A& getA1() { A a(5); return a; } A& getA2() { A a(5); return a; } A getA3() { A a(5); return a; } int main() { const A& newA1 = getA1(); //1 A& newA2 = ge...

C/C++ Date Solution/Conversion

I need to come up with a way to unpack a date into a readable format. unfortunately I don't completely understand the original process/code that was used. Per information that was forwarded to me the date was packed using custom C/Python code as follows; date = year << 20; date |= month << 16; date |= day << 11; date |= hour <...

Transfer ownership within STL containers?

Is it possible to transfer ownership of a vector contents from one vector to another? vector<T> v1; // fill v1 vector<T> v2 = OvertakeContents(v1); // now v1 would be empty and v2 would have all the contents of v1 It is possible for lists with splice function. This should be possible in constant time for whole vector as well. If it...

How is std::string implemented ?

I am curious to know how std::string is implemented and how does it differ from c string?If the standard does not specify any implementation then any implementation with explanation would be great with how it satisfies the string requirement given by standard? ...

How to use Intel C++ Compiler with Qt Creator

I am writing a program wherein i will need to do a stupendous number of numerical calculations. But since I am developing the front end of the program in Qt Creator, I have as yet been dealing with MinGW. As such, is there any way to integrate or use the Intel C++ Compiler with QT Creator? Currently using IC++ 11.0 and QtCreator 1.2.1...

Overridden function pointer problem at template base class C++

hi, I implemented a template base class for observer pattern, template<class T> class ActionListener { public: ActionListener(void); virtual ~ActionListener(void); void registerListener(T* listener); void unregisterListener(T* listener); template<typename Signal> void emit(Signal signal); templa...

WaitForRequest with Timeout crashes

Hi, EDIT: I have now edited my code a bit to have a rough idea of "all" the code. Maybe this might be helpful to identify the problem ;) I have integrated the following simple code fragement which either cancels the timer if data is read from the TCP socket or otherwise it cancels the data read from the socket // file tcp.cpp void Che...