c++

Generic var c++

Hello, I want to create a generic var, that could be from one class or another class. In this code sample I want that var aa be generic so in my code I can access code from class A or class B. But aa MUST BE GLOBAL. Could you help me? class MyClass { public: MyClass() {} //contructor padrão, não deve ser utilizado isoladamente ...

Register hotkeys in Linux using library for c++

Hi guys, are there any libraries for linux wroted in C++ which could register global hotkeys for my application? Thanks. ...

Detecting when an object is passed to a new thread in C++?

I have an object for which I'd like to track the number of threads that reference it. In general, when any method on the object is called I can check a thread local boolean value to determine whether the count has been updated for the current thread. But this doesn't help me if the user say, uses boost::bind to bind my object to a boost:...

How to hook webcam capture?

Hi, I'm working on a software that the current version has a custom made device driver of a webcam, and we use this driver with our software, that changes the captures image before displaying it, very similar to YouCam. Basically, when any application that uses the webcam starts, our driver runs a processing in the frame before showing ...

Net-SNMP varibles using C++

I am having trouble with a few of the variables that the Net-SNMP library provides, specifically the ability to capture in/out Octets. In/OutOctets Issue: I have another check for ASN_INTEGER and I am catching this oid put the output does not seem to be correct. I am using *vars->val.integer and pushing this into a long but I am current...

VC++ doesn't detect newly created env variable using GetEnvironmentVariable

I'm using the Win32 function GetEnvironmentVariable to retrieve the value of a variable that I just created. I'm running Windows XP and VC++ 2005. If I run the program from within Visual Studio, it can't find the new variable. If I run it from a command-prompt, it does. I restarted VC++ but same result. I even restarted all instances of ...

How could this simple pointer equality test fail?

void FileManager::CloseFile(File * const file) { for (int i = 0; i < MAX_OPEN_FILES; ++i) { if ((_openFiles[i] == file) == true) { _openFiles[i] == NULL; } } ... _openFiles is a private member of FileManager and is just an array of File *'s When the exact same test is performed in the Immediate window i get a result of 1!?!...

What does the construct keyword do when added to a method?

The code here is X++. I know very little about it, though I am familiar with C#. MS says its similiar to C++ and C# in syntax. Anyway, I assume the code below is a method. It has "Construct" as a keyword. What is a construct/Constructor method? What does the construct keyword change when applied to the function? Also, am I wrong in ...

Machine ID for Mac OS?

I need to calculate a machine id for computers running MacOS, but I don't know where to retrieve the informations - stuff like HDD serial numbers etc. The main requirement for my particular application is that the user mustn't be able to spoof it. Before you start laughing, I know that's far fetched, but at the very least, the spoofing...

What is #nomacros (EP003), and is it alive?

The Evolution WG Issues List of 14 February 2004 has ... EP003. #nomacros. See EI001. Note by Stroustrup to be written. In rough (or exact) terms, what is #nomacros, and is it available as an extension anywhere? It would have been a useful diagnostic tool in a recent project involving porting thousands of files of 1995-vintage C...

QTabBar icon position

Is there a way to change the alignment of the icon or text of a tab in Qt? Specifically, I would like the text to appear below the icon. By default the icon sits to the left of the text, but that's not appropriate for all situations (especially when you start styling your tabs with stylesheets) It would seem very odd to me that this aspe...

What is LogonUser()'s token returned used for?

Hey Folks, What can you do with the token LogonUser returns? And what is it used for? BOOL LogonUser( __in LPTSTR lpszUsername, __in_opt LPTSTR lpszDomain, __in LPTSTR lpszPassword, __in DWORD dwLogonType, __in DWORD dwLogonProvider, __out PHANDLE Token ); I just need a more general discription an...

Simplest sample with 2D sprites in directx 10

As in question, I'm trying to make sprites working but it's very hard and it doesn't display, so if anyone has a simple sample I'd be grateful. ...

Is it possible to use anonymous functions in C++ .NET?

Wikipedia seems to say that C++0x will support anonymous functions. Boost also seem to support it. However I'm using .NET so if I could stick with it it would be awesome. Basically I just want to write some quick code for objects. I have a robot which can have about 85 - 90 states. Most of the states are just "integer values passed to t...

Use of activeX object on non-MFC applications

Hi all, I'd like to use an activeX component in Visual C++. The ocx file has been registered and I can insert the component in a dialog of the resource editor. But how I get a wrapper class to use the activeX object now?? On MFC applications, the editor creates a wrapper class for the ocx, but I'm not using MFC... Thanks! Henry ...

How to take a pointer to a template function specialized on a string?

I was trying use a set of filter functions to run the appropriate routine, based on a string input. I tried to create matcher functions for common cases using templates, but I get a "type not equal to type" error when I try to store a pointer to the specialized function (in a structure, in the real application) Distilled example from a...

DirectShow stop/resume live stream

I'm using DirectShow to play audio/video files in my application. I use IGraphBuilder::RenderFile() to build the filter graph and the IMediaControl interface to play/pause/stop the media. This works fine for local media files, but causes problems with live mms streams. If I call IMediaControl::Stop() on a live stream, the stream will st...

Managing Implicit Type Conversion in C++

I'm working on code that does nearest-neighbor queries. There are two simple ideas that underlie how a user might query for data in a search: closest N points to a given point in space. all points within a given distance. In my code, Points are put into a PointList, and the PointList is a container has the job of keeping track of the...

Combing an External Event Loop with Qt's

I'm building a Qt client for the open-source client/server 4X strategy game Thousand Parsec. This a Google Summer of Code project. I'm however stuck at a dead end. Basically, the client interfaces with the server via a C++ protocol layer that facilitates client/server communication. The protocol's documentation is available here. Now my...

Is there a difference in C++ between copy initialization and assignment initialization?

Suppose I have this function: void my_test() { A a1 = A_factory_func(); A a2(A_factory_func()); double b1 = 0.5; double b2(0.5); A c1; A c2 = A(); A c3(A()); } In each grouping, are these statements identical? Or is there an extra (possible optimizable) copy in some of the initializations? I have seen peo...