c++

How to update a dialog box via SetDlgItemText within a function and have it take effect immediately in windows?

If I call SetDlgItemText() to update the value of a dialog text it seems to only be updated when the function returns. I'm using it to update a status message informing the user of the current progress mid function so I would like it to be updated immediately. If this can not be done, is there something else I can do that would perform...

Creating a win32 modal window with CreateWindow

Hi, I create a window with CreateWindow() and show it with ShowWindow(). But the parent window on which this was created should be disabled until user returns from this window, i.e. it should simulate modal dialog box. Any help is appreciated. Thanks ...

How delete folder in C++

Hey all, How delete folder using C++? I am something find at internet, but do not help me :( Can somebody help me? Thank you ...

Locking focus and capture to a specific window

I can call a setfocus and setcapture using a toggle mechanism and in OnLButtonDown make sure the message doesn't get passed on, but that seems to fail the moment you left click. Is there any way to ensure that the window which has capture and focus does not give it up? ...

How would you go about designing a function for a perfect hash?

The domain of interest is string matching. Assume I have a structure like this. typedef struct { char *name, int (*function)(); } StringArray StringArray s[] = { {"George", func1}, {"Paul", func2}, {"Ringo", func3}, {"John", func4} } There are a fixed number of strings in the array. They are hard cod...

Template Specialization of Function inside of a Templated Class

I have a templated class and inside I have a templated function( different template parameters ) and I having issues getting the compiler to call the correct one. Example: template< class Parm1, class Parm2, class Parm3 > class Class { public: void Func( Parm1 arg1, Parm2 arg2 ) { Call<Parm3>( arg1, arg2 ); } protected:...

Fixed-width integers in C++

Occasionally I need to use fixed-width integers for communication with external devices like PLCs. I also use them to define bitmasks and perform bit manipulation of image data. AFAIK the C99 standard defines fixed-width integers like int16_t. However the compiler I use, VC++ 2008 doesn't support C99 and AFAIK Microsoft is not planning t...

What is the best header structure to use in a library?

Concerning headers in a library, I see two options, and I'm not sure if the choice really matters. Say I created a library, lets call it foobar. Please help me choose the most appropriate option: Have one include in the very root of the library project, lets call it foobar.h, which includes all of the headers in the library, such as "s...

C++ empty-paren member initialization - zeroes out memory?

I originally wrote some code like this: class Foo { public: Foo() : m_buffer() {} private: char m_buffer[1024]; }; Someone who is smarter than me said that having the m_buffer() initializer would zero out the memory. My intention was to leave the memory uninitialized. I didn't have time to discuss it further, but it piqued ...

How to marshal C++/CLI array of struct to unmanaged C++

I'm searching for the correct syntax to pass a struct array to an unmanaged C++ dll. my dll imports are called like this #define _DllImport [DllImport("Controller.dll", CallingConvention = CallingConvention::Cdecl)] static _DllImport bool _Validation(/* array of struct somehow */); In my client code I have List<MyStruct^> list;...

Any ideas on how to integrate with nmap programatically?

I'm just starting to look into how to integrate nmap, an open source security product, into some c++ code. If anyone's tried this, and has some ideas on the best approach, I'd certainly appreciate it. Thanks for the responses. Specifically, I'd like to run a port scan (ipv6). I would definitely prefer non-gpl solutions such as a comman...

ordering edges for sweeping algorithm

I have the following data structures in my class: typedef vector< vector<int> > MxInt2d; typedef vector< vector<double> > MxDouble2d; class QSweep{ public: .... static MxDouble2d myPoints_; MxDouble2d myEdges_; } where: Each point has 3 components,thus being given by an index, an x, and a y coordinate; Each edge is given by its s...

Most useful or amazing STL short liners

I'm looking for practical and educational samples of C++ / STL code fitting in few lines. My actual favorites are: Empty a vector freeing its reserved memory: vector <...>().swap (v) (swap with a temporary) Copy a map to a vector: map<T1, T2> myMap; vector< pair<T1, T2> > myVec(myMap.begin(), myMap.end()); // or myVec.assign(myMap....

Video tutorial showing code editing

I'm working on a video tutorial (and accompanying text) for installing a program in Mac OS X (http://forum.codelain.com is where the program is downloaded). I'm almost done, but I've run into a problem that I don't really know how to show in the video. For the most part, the videos are just showing the user what to click, which command...

Can the "Application Error" dialog box be disabled?

I am using Hudson as a continuous integration server to test C/C++ code. Unfortunatly, I have a bug somewhere that causes memory corruption, so on some Windows machines I will sometimes get a "Application Error" dialog box explaining that an instruction referenced memory that could not be read. This dialog box pops up and basically han...

Does C++ support individual generic methods rather than generic classes?

Important: This question is getting quite long, if this is the first time you're reading this I suggest you start near the bottom as the solution is there in a round about way, but the code is a bit smelly. After reading a tutorial on templates, I was able to change my existing class to support generic types. However, many objects a...

Convert a String In C++ To Upper Case

Hello, I have looked around, but I can't seem to find any examples of this. I am relatively new to C++, and was wondering how I could convert a string to upper case. The examples I have found from googling only have to deal with char's, and not with strings. ...

Blocking socket returns EAGAIN

One of my projects on Linux uses blocking sockets. Things happen very serially so non-blocking would just make things more complicated. Anyway, I am finding that often a recv call is returning -1 with errno set to EAGAIN. The man page only really mentions this happening for non-blocking sockets, which makes sense. With non-blocking, the...

After implementing fmod Visual C++ test strange behavior - All tests fail - Unable to get type.... Error: System.IO.FileNotFoundException - if certain line of code in one test

Ok, I've figured out what caused the problem but I still don't know why - it happened when I started using fmod, and it must have something to do with how the linker decides to bring in and execute static libraries and dll's. My code under test is a static lib; it refers to fmodex_vc, another static lib, which at some point (though I k...

Cannot Load C++ DLL in C#

Hello, >My previous thread< I created this one,because I installed WinXP on VMBox and I cannot get it working again. This time I created an OnLoad Event on my form if (LoadLibrary("blowfish.dll") == 0) { Misc.LogToFile("Could not load dll", true); Application.Exit(); } Runs fine on my...