c++

Override System Draw on WM6+

Im developing a "desktop" for WM6+ and i was wondering if i can override the draw that WM does when it starts the OS (like the start menu, softkey bar, and background) basically have my program draw the today screen instead of windows. My program will of course integrate everything that the original "screen" integrated. C++ ...

How to build sliding block puzzle software for mobiles

I want to build software of the good old sliding block puzzle for mobile phones could you please guide me how to generate the sliding block puzzle and solving techniques ...

Linking languages

Hi, I asked a question earlier about which language to use for an AI prototype. The consensus seemed to be that if I want it to be fast, I need to use a language like Java or C++, but that Python / Perl / Ruby would be good for the interface bits. So, this leads me on to another question. How easy is it to link these languages togethe...

Parse a file using C++, load the value to a structure

Hi, I have the following file/line: pc=1 ct=1 av=112 cv=1100 cp=1700 rec=2 p=10001 g=0 a=0 sz=5 cr=200 pc=1 ct=1 av=113 cv=1110 cp=1800 rec=2 p=10001 g=0 a=10 sz=5 cr=200 and so on. I wish to parse this and take the key value pairs and put them in a structure: struct pky { pky() : a_id(0), sz_id(0), cr_id(0), ...

Is it possible to start a custom thread in an IIS hosted C++ application?

Hi all We host a C++ based WebServices application in IIS and we're finding that when we try to start our own C++ threads IIS has a fit and crashes. The threads are based on boost.thread which clearly dribbles down to the standard Windows threading API underneath. The reason I need to start the thread is to listen for multicasts fro...

MFC: Changing font of a List control

Hi guys, I need to at run time change the font of a List Control so as to used a fixed width font. I have seen some examples which suggest I should trap the NM_CUSTOMDRAW message, but I was wondering if there was a better way of doing it. Thanks. ...

Singleton getInstance in thread worker methods

Hello, This question is about using getter methods of a singleton object in worker threads. Here is some pseudo code first: // Singleton class which contains data class MyData { static MyData* sMyData ; int mData1[1024]; int mData2[1024]; int mData3[1024]; MyData* getInstance() { // sMyData is creat...

How can I improve/replace sprintf, which I've measured to be a performance hotspot?

Through profiling I've discovered that the sprintf here takes a long time. Is there a better performing alternative that still handles the leading zeros in the y/m/d h/m/s fields? SYSTEMTIME sysTime; GetLocalTime( &sysTime ); char buf[80]; for (int i = 0; i < 100000; i++) { sprintf(buf, "%4d-%02d-%02d %02d:%02d:%02d", sysTime.wYear...

Shadow Copying, and mixed C# and C++ DLLs loading from arbitrary folders

I have a VS 2005 C# project that uses a special Plugin folder to load extra DLLs (for use as nodes in an asset conversion process). I have a mixture of C# and C++ DLLs in this folder. The issue I have is that when Shadow Copying is enabled, the C++ DLLs refuse to load using Assembly.LoadFrom. I have attempted to create a custom app dom...

Alternative to GetProcessID for Windows 2000

I've accidentally removed Win2K compatibility from an application by using GetProcessID. I use it like this, to get the main HWND for the launched application. ShellExecuteEx(&info); // Launch application HANDLE han = info.hProcess; // Get process cbinfo.han = han; //Call EnumWindows to enumerate windows.... //with this as the callba...

User Interface Privilege Isolation in XP SP3

Hi All, Just after a bit of confirmation really: Does XP SP3 implement the User Interface Privilege Isolation (UIPI) mechanism found in Vista? Back story for human interest :) I've recently been handed the C++ source to a fairly large application. Sadly the sole developer of this application, since its inception back in the mid 90's, ...

Why can't I use static members, for example static structures, in my classes in VS2008?

When I write code like this in VS 2008: .h struct Patterns { string ptCreate; string ptDelete; string ptDrop; string ptUpdate; string ptInsert; string ptSelect; }; class QueryValidate { string query; string pattern; static Patterns pts; public: friend class Query; QueryValidate...

Boost Graph Library: Is there a neat algorithm built into BGL for community detection?

Anybody out there using BGL for large production servers? How many node does your network consist of? How do you handle community detection Does BGL have any cool ways to detect communities? Sometimes two communities might be linked together by one or two edges, but these edges are not reliable and can fade away. Sometimes there ...

How to get equivalent of printf_l on Linux?

This function exists on OS X and allows you to pass custom local to the function. setlocale is not thread-safe, and passing locale as parameter is. If there is no equivalent, any way of locale-independent printf, or printf just for doubles (%g) will be ok. ...

Socket Exception: "There are no more endpoints available from the endpoint mapper"

I am using winsock and C++ to set up a server application. The problem I'm having is that the call to listen results in a first chance exception. I guess normally these can be ignored (?) but I've found others having the same issue I am where it causes the application to hang every once in a while. Any help would be greatly appreciate...

How to precompute array of values?

Is there a way to pre-compute an array of values based on templates? In the following example I would like the 'powers_of_2' array to have 256 values computed at compile-time if that is possible without having to type all of the values. #include <iostream> using namespace std; template <int X, char Y> struct power { enum { value = ...

Kill a blocked Boost::Thread

I am writing an application which blocks on input from two istreams. Reading from either istream is a synchronous (blocking) call, so, I decided to create two Boost::threads to do the reading. Either one of these threads can get to the "end" (based on some input received), and once the "end" is reached, both input streams stop receivin...

C++: undefined reference to static class member

Hey, Can anyone explain why following code won't compile? At least on g++ 4.2.4. And more interesting, why it will compile when I cast MEMBER to int? #include <vector> class Foo { public: static const int MEMBER = 1; }; int main(){ vector<int> v; v.push_back( Foo::MEMBER ); // undefined reference to `Foo::M...

Will the c++ compiler optimize away unused return value?

If I have a function that returns an object, but this return value is never used by the caller, will the compiler optimize away the copy? (Possibly an always/sometimes/never answer.) Elementary example:ReturnValue MyClass::FunctionThatAltersMembersAndNeverFails() { //Do stuff to members of MyClass that never fails return success...

CMFCToolTipCtrl or CTooltipManager examples?

Has anyone tried using these new VS2008 MFC classes yet? I can't seem to find any examples anywhere. Even the VS2008 samples(1) don't mention these classes. (They use CToolTip.) (1) Update: My mistake. I had downloaded the non-SP1 samples. I see that the SP1 samples have samples specifically for the 2008 Feature Pack, including the DlgT...