c++

Intercepting mouse clicks when the mouse is hovering above a control

I'm working on a MFC C++ dialog where I need to respond to right mouse click events for a dialog even if the mouse is hovering over a control. I could write event handler code for each control to delegate the work to the parent dialog, but I'm hoping there is a more elegant solution? I'm hoping there is some way to intercept the window...

multidimensional array in C++ hang

I wanna to declare an array: int a[256][256][256] And the program hang. (I already comment out all other codes...) When I try int a[256][256], it runs okay. I am using MingW C++ compiler, Eclipse CDT. My code is: int main(){ int a[256][256][256]; return 0; } Any comment is welcomed. ...

Copying C-Style String to Free Store Using Only Dereference

As said in the title, the goal is to copy a c-style string into memory without using any standard library functions or subscripting. Here is what I have so far [SOLVED] #include "std_lib_facilities.h" char* strdup(const char* p) { int count = 0; while(p[count]) ++count; char* q = new char[count+1]; for(int i = 0; i < c...

#pragma - help understanding

Can anyone help me understand #pragma? ifndef TARGET_OS_LINUX #pragma once endif What,when, where, why, an example? The above is in some code that I am refactoring.... ...

GDI+ leaks memory when deleting pointers as GdiplusBase*? (C++)

Hi all, I'm trying to work with GDI+ and I'm running into a weird memory leak. I have a vector of GdiplusBase pointers, all of them dynamically created. The odd thing is, though, is that if I try to delete the objects as GdiplusBase pointers, e.g. vector<GdiplusBase*> gdiplus; gdiplus.push_back(new Image(L"filename.jpg")); delete gdiplu...

C, C++ preprocessor macro

Can anyone please explain how this works #define maxMacro(a,b) ( (a) > (b) ) ? (a) : (b) inline int maxInline(int a, int b) { return a > b ? a : b; } int main() { int i = 1; j = 2, k = 0; k = maxMacro(i,j++); // now i = 1, j = 4 and k = 3, Why ?? Where is it incremented ? //reset values i = 1; j = 2, k = 0; k = maxInlin...

Is this valid C++ code?

I had the following code, which was basically, class foo { public: void method(); }; void foo::foo::method() { } I had accidentally added an extra foo:: in front of the definition of foo::method. This code compiled without warning using g++(ver 4.2.3), but errored out using Visual Studio 2005. I didn't have a namespace named ...

Where do you track the developments of new c++ standards?

Where do you guys generally look for developments in C++, most importantly, developments in new standard and its approx/scheduled release data? also boost (well, boost.com) Is there a centralized place? thx ...

What apps do program in C++ nowadays

With RoR, Java, C#, PHP etc.. what do people use C++ for these days? ...

How to get the inside dimensions of a decorated window in XWindows?

If I create a full screen window where m_winw and m_winh is the full screen size, it seems to create a window for me where the outside dimension is the full screen and the inside is smaller based on the "decoration" (window border) size. Is there a way to query the window to get it's inside width and height? m_win=XCreateWindow(m_displa...

How to determine whether it is EOF when using getline() in c++?

string s; getline(cin,s); while (HOW TO WRITE IT HERE?) { inputs.push_back(s); getline(cin,s); } ...

In C++, what is the difference between 1 and 1i64?

I'm converting some 32-bit compatible code into 64-bit - and I've hit a snag. I'm compiling a VS2008 x64 project, and I receive this warning: warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) Here's the original line of code: if ((j & (1 << k)) != 0) { And here's what it look...

How to call a JNI DLL from C++

I have a task to interface with a dll from a third party company using C++. The dll package comes with: the dll itself a sample Java implementation - consists of a java wrapper(library) generated using the SWIG tool and the the java source file documentation that states all the public datatypes, enumeration and member functions. My ...

Diamond problem

I was going through the diamond problem and thought will work on various scenarios. And this is one among them which I was working on. #include <iostream> using namespace std; class MainBase{ public: int mainbase; MainBase(int i):mainbase(i){} void geta() { cout<<"mainbase"<<mainbase<<endl; } }; class D...

error: non-lvalue in unary `&' in C++

Hi, We are using a macro wrapper to Bind Where Parameter function. #define bindWhereClause(fieldName, fieldDataType, fieldData) _bindWhereClause(fieldName, fieldDataType, sizeof(fieldData), &fieldData) void _bindWhereClause(const char *name, int dataType, int dataSize, void *data) { // Implementation } Database.bindWhereClause( "FI...

Decode WMA with FFMpeg to PCM

Hello, I want to decode a WMA stream to 16 Bit PCM. Now i have a Question concerning FFMpeg- what is the output format of .. len = avcodec_decode_audio2(c, (int16_t *)outbuf, &outbuf_used, inbuf_ptr, size); is this the right function for this task? Thank you ...

How to add menu command handler in VC 2008?

how to add a menu command handler in vc 2008? ...

Using std Namespace

There seem to be different views on using 'using' with respect to the std namespace. Some say use ' using namespace std', other say don't but rather prefix std functions that are to be used with ' std::' whilst others say use something like this: using std::string; using std::cout; using std::cin; using std::endl; using std::vector; ...

How to find if an document can be OPENed via ShellExecute?

I want to check if a particular file can be successfully "OPEN"ed via ShellExecute, so I'm attempting to use AssocQueryString to discover this. Example: DWORD size = 1024; TCHAR buff[1024]; // fixed size as dirty hack for testing int err = AssocQueryString(0, ASSOCSTR_EXECUTABLE, ".mxf", NULL ,buff , &size); openAction->Enabled = ((...

C++/Qt memory Leak?

Hi all, I noticed a very interesting finding. I was testing my application involving a custom made GUI element which was being updated by data coming from an external source. The update of GUI was done using a slot(Qt specific detail) function whenever data arrived on serial port. Now the data was coming a rate of 10 packets a second i....