c++

How can I embed a PDF viewer in a cross-platform C++ application?

I need to embed a PDF viewer in my application. Is there any free software I can use? Thanks. ...

cannot trap VK_RETURN key for subclassed editbox control.

I subclassed an edit box control like lpfnOldWndProc = (FARPROC)SetWindowLong(hEdit,GWL_WNDPROC, (DWORD)SubClassFunc); LRESULT FAR PASCAL SubClassFunc( HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_CHAR: //Process this message to avoid messag...

How to create a Qt window behave like a message box ?

Hi! I want to create a Qt popup window which will behave like a message box in Qt. That means the rest of the GUI must blocked until that popup window is dismissed. This may be a child question, but can anyone pls help me with this ? Thanks... :) Edit: I want to use forms, labels, buttons and some other widget types in that popup ...

Enums: Can they do in .h or must stay in .cpp?

If I have something like: enum { kCP_AboutBox_IconViewID = 1, kCP_AboutBox_AppNameViewID = 2, kCP_AboutBox_VersionViewID = 3, kCP_AboutBox_DescriptionViewID = 4, kCP_AboutBox_CopyrightViewID = 5 }; in my .cpp can it go in the .h? More so, what other lesser know things can you put in a .h besides class definitions,...

GCC C++ (ARM) and const pointer to struct field

Let's say there is a simple test code typedef struct { int first; int second; int third; } type_t; #define ADDRESS 0x12345678 #define REGISTER ((type_t*)ADDRESS) const int data = (int)(&REGISTER->second)*2; int main(void) { volatile int data_copy; data_copy = data; while(1) {}; } Which is compiled in Code...

Command queueing without threads

Lets say I have a class where each object should interact independently. For example, I may have various tables out of a database over many servers offsite. However, internally, I happen to know that some of the tables are linked, and I can save a significant amount of IO by grouping commands that do not require any response together. ...

How Do I Stop An Application From Opening

Hi Guys, I want to write a small app that sits in my tray and that allows me to select an executable and prevent it from opening. The UI of the app is easy to do using WinForms. What I want to know is how to detect if a certain exe has been lauched and then how to stop it from running. I'm pretty sure I'll have to dig down into some W...

Weird in Header Files

I have lines in header files that are like: public: //! @name Constructor / Destructor //@{ //! Constructor. CP_AboutBox( CP_Application_Imp *inOwnerApp ); virtual ~CP_AboutBox() throw(); //@} //! @name Instance //@{ static CP_AboutBox *Instance(); //@} //! @name Display //@{ ...

Visual C++ class testing

Is there any way to easily test C++ classes in java way. In java you can add static function main and run it directly from IDE class Foo{ ... public static void main(String args[]) { System.out.println("Test class foo here"); } } is it possible to do it in Visual C++ ? Of course you can create another project, but it ...

Console get key press w/o windows messages c++

Is there any way to get the last key press in a console without using Windows messages or the std::cin stream? I've heard that there is a function in the standard library. Solutions should preferably be as portable as possible. Thanks for your help in advance. ...

check if numbers have the same sign

I came across this: http://stackoverflow.com/questions/66882/simplest-way-to-check-if-two-integers-have-same-sign How can this be extended to more than two numbers (not necessarily integers)? Say, check if 4 numbers have the same sign (+ve or -ve). I don't want to use bit operations as far as possible ... only logical conditions. Than...

Is there any difference in speed in manipulating different types of variables?

Hello everyone, This is in reference to C++ and using the Visual Studio compilers. Is there any difference in speed when reading/writing (to RAM) and doing mathematical operations on different types of variables such as bool, short int, int, float, and doubles? From what I understand so far, mathematical operations with doubles takes...

setting a default union member

i'm using templated unions to both assure myself that i always get a 64-bit field for pointers (even on 32-bit machines since there is transmission of data to a 64-bit machine occurring) and to save both the user and myself casting. template <typename type> union lrbPointer { uint64_t intForm; type ptrForm; //assumed that type i...

2D arrays with C++

I have a function that takes a pointer to a pointer an as argument. func(double **arr, int i); where in the main function the array is defined as follows: double arr[][] = //some initialization here; How can I call this function from my main code. I tried the following but it gives an error func (&arr); Doesn't work. Any help ...

Lightweight, portable C++ fibers, MIT license

I would like to get ahold of a lightweight, portable fiber lib with MIT license (or looser). Boost.Coroutine does not qualify (not lightweight), neither do Portable Coroutine Library nor Kent C++CSP (both GPL). Edit: could you help me find one? :) ...

How to initialize unmanaged static pointer in C++/CLI code?

Hi all, thanks for checking my problem:) I'm not able to initialize a static native pointer inside a managed class. Here's the detail: I created a C++/CLI console project and declared a static unmanaged pointer inside. However I can't initialize the static pointer with any means (but if I put the pointer into an anonymous namespace, th...

How to get the font size from CMFCPropertyFontProperty

Hi All, I'm using this code block to get the font name, style and size selected by the user from the font dialog of CMFCPropertyFontProperty control. I'm already able to get the name and the style, but the size seems to return a different value. *CMFCPropertyGridProperty pCurSel = m_wndPropList.GetCurSel(); CMFCPropertyGridFontProper...

For-loop in C++ using double breaking out one step early, boundary value not reached

I have a simple C++ program compiled using gcc 4.2.4 on 32-bit Ubuntu 8.04. It has a for-loop in which a double variable is incremented from zero to one with a certain step size. When the step size is 0.1, the behavior is what I expected. But when the step size is '0.05', the loop exits after 0.95. Can anyone tell me why this is happenin...

C++ and const - accessing a member function of a const reference

I have this snippet of code here. The intention is to make a copy of initialData. Since I am not modifying initialData in any way, I figure that I should pass it as a const reference. However, I keep getting this message when compiling. .\src\Scene\SceneAnimationData.cpp(23) : error C2662: 'SceneTrackerData::getRect' : cannot c...

Auto-cast two 3rd party classes?

I'm using two 3rd party libraries, which both implement their own 2D vector class. Unfortunately, I have to work with both of them, so is there anyway I can write some "friend" functions so that one can automatically be converted to the other when I try to use them in functions from the other library? ...