c++

How do you make a program sleep in C++ on Win 32?

How does one "pause" a program in C++ on Win 32, and what libraries must be included? ...

Using DirectX DLL (C++) from C#

I have a native C++ DLL using DirectX, that I want to be able to use through C# to be able to create content creation tools. Adding COM would require quite an effort it seems. Can P/Invoke be used to maintain classes using polymorphism, or would it require me to wrap most of the code to facilitate use of P/Invoke? It there a better sol...

does a getter function need a mutex?

I've a class that is accessed from multiple threads. Both getter and setter functions are guarded with locks. Are the locks for getter functions relly needed? Why? class foo { public: void setCount (int count) { boost::lock_guard<boost::mutex> lg(mutex_); count_ = count; } int count () { boost::lock_...

C++ Really basic drawing/GUI

I'm searching for some examples on drawing basic shapes on the screen using only the Win32 API in C++ Do you need other libraries beside the standard Win32 API? Could you give me a very short example on how to, e.g.: draw a single line on the screen? Are there libaries that are easier to use for basic drawing than Win32? ...

Permissions denied for directory - c++

Hi guys, I'm trying to build ogre newton application from svn. I have win7 && vs 2008. There is inc directory which is included into resources (additional include directories). But after compiling I get error: fatal error C1083: Cannot open source file: '*\newton20\inc': Permission denied c1xx What's wrong? ...

Entering a string of characters using arrays and pointers

Ok guys, i'm very beginner and trying to enter string to a char array using pointers..and then display what i've written. There're two things i want to ask about. First , if i didn't want to specify a size for the array and just want it to expand to contain all string i've entered ..how is that ? And second after i enter the string and...

How would you implement basic reflection in C++?

I'm thinking about adding some sort of reflection capabilities to some C++ classes ( so that I wouldn't have to use RTTI ): getting names of methods, declared fields, class name ... this sort of stuff. I was thinking about parsing existing source files, get a list of declared fields & methods, and rewrite each source file, adding this s...

Managing windows API differences between Windows XP and Vista/Server 2008

I am trying to create a single executable of a simple Win32 application that has to be able to run on both Windows XP and Windows Vista/2008. Due to some changes in the way Vista works some extra Win32 API calls have to be made to make the program function correctly as it did on XP. Currently I detect if the application is running on a...

Is there a C++ MinMax Heap implementation?

I'm looking for algorithms like ones in the stl (push_heap, pop_heap, make_heap) except with the ability to pop both the minimum and maximum value efficiently. AKA double ended priority queue. As described here. Any clean implementation of a double ended priority queue would also be of interest as an alternative, however this question ...

Reading Firefox Bookmarks

Apparently, latest Firefox versions stores its bookmarks in a file called 'places.sqlite'. Like a browser can import the bookmarks from another browser, I would want to import the bookmarks to a file, but I need to know what would you need to do it? ...

gdb error: Unable to execute epoll_wait: (4) Interrupted system call

I am unable to run my code in debug using gdb because of the following error: Unable to execute epoll_wait: (4) Interrupted system call Any ideas on how to solve this? Thanks ...

How can i get the printer's network path (\\COMPUTER\PRINTERNAME)

How can i get the printer's network path (\COMPUTER\PRINTERNAME) from default printer window c++. ...

C++ Recursion problems <confused>

I am working on understanding recursion, and I think I have it down alright... I'm trying to build a search function (like the std::string.find()) that searches a given string for another string for example: Given (big) string: "ru the running cat" search (small) string: "run" I'm trying to return a index for the where the wor...

enterprise library logging in C++ - logwriter->Dispose() error

I'm using Microsoft's enterprise library logging to log to a rolling flat file listener in my C++ dll. (IDE - VS2005) I'm having an issue that new files keep getting generated, with the GUID appended to the beginning of the file name. I've been googling this issue, and the solution seems to be to call logwriter.Dispose(). For some rea...

dynamic_cast in c++

As i am new to c++ ,i am quite confused with the dynamic_cast keyword in c++. struct A { virtual void f() { } }; struct B : public A { }; struct C { }; void f () { A a; B b; A* ap = &b; B* b1 = dynamic_cast<B*> (&a); // NULL, because 'a' is not a 'B' B* b2 = dynamic_cast<B*> (ap); // 'b' C* c = dy...

How to install Microsoft.VisualStudio.Shell.dll on Client Computer

I am dealing with some code that won't install on client machines (NOT running Visual Studio) because is makes reference to VSConstants.S_OK, which is in Microsoft.VisualStudio.Shell.dll. Is there a redistributable that includes this, or do I need to have the code updated to use a different constant. ...

C++, How to maintain both data locality and well splitted code structure at every layer of a program?

In my recent project I have a class like this: class layer1 { myclassa l1dataa; // layer1 data ... myclassn l1datan; public: void l1datatransformsa() { myotherclassa l2dataa; // layer2 data ... myotherclassn l2datan; many operations; // way too many operations for a single method } void l1datatransformsb() {} }; The method ...

Ideas for specific data structure in c++

I need to do some task. There are numbers give in two rows and they act like pairs of integers (a, b). I have to find the maximum 5 numbers of the a-row and then select the max of those 5 but this time from the b-row. Ex: 1 4 5 2 3 3 7 5 6 6 2 9 3 1 In this example, the pair i need is (6,6) because 6 (a) is in the top 5 of the a[i] nu...

What makes STL fast?

If one implements an array class the way it is commonly implemented, its performance is slower compared to its STL equivalent like a vector. So what makes STL containers/algorithms fast? ...

How can I work around the GetParent/EnumChildWindows asymmetry?

I recently inspect a GUI with Microsoft's Spy++ and noticed a strange structure; it looked like this (warning, ASCII art ahead): | + 002004D6 "MyRootWindow1" FooClassName | | | + 001F052C "MyChildWindow" ClassOfChildWindow | \ 001D0A8C "MyRootWindow2" SomeOtherClassName There are two root windows, 002004D6 and 001D0A8c, the...