c++

how to send typing messages via WM_KEYBOARD_LL hook procedure

Hi there~ I'm trying to send a duplicate message to an editbox window in this code: extern "C" HOOK_DLL_API LRESULT CALLBACK GetMsgHookProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode < 0) { CallNextHookEx(gMsgHook, nCode, wParam, lParam); } KBDLLHOOKSTRUCT *lpk = (KBDLLHOOKSTRUCT*) lParam; ...

Center an OpenGL window with GLUT

I have an openGL window that is 640x480 that I need to center in the middle of the screen. I previously used: glutInitWindowPosition((GetSystemMetrics(SM_CXSCREEN)-640)/2, (GetSystemMetrics(SM_CYSCREEN)-480)/2); which WORKED. But now all of a sudden when I compile... Linking... 1>Project1.obj : error LNK2028:...

double free or corruption

Hi, I met a runtime error "double free or corruption" in my C++ program that calls a reliable library ANN and uses OpenMP to parallize a for loop. *** glibc detected *** /home/tim/test/debug/test: double free or corruption (!prev): 0x0000000002527260 *** Does it mean that the memory at address 0x0000000002527260 is freed more t...

Error modes for OpenCV

Hello, I am using OpenCV 1 to do some image processing, and am confused about the cvSetErrMode function (which is part of CxCore). OpenCV has three error modes. Leaf: The program is terminated after the error handler is called. Parent: The program is not terminated, but the error handler is called. Silent: Similar to Parent mode...

misusing OpenMP?

Hi, I have a program using OpenMP to parallelize a for-loop. Inside the loop, the threads will write to shared variable, so I need to synchronize them. However I can sometimes get either segment fault or double free or corruption error. Anyone knows what happens? Thanks and regards! Here is the code: void KNNClassifier::classify_variou...

Return a const reference or a copy in a getter function?

What's better as default, to return a copy (1) or a reference (2) from a getter function? class foo { public: std::string str () { // (1) return str_; } const std::string& str () { // (2) return str_; } private: std::string str_; }; I know 2) could be faster but don't have to due to (N)RVO. 1) is ...

Why does this code using `::boost::bind` get a compiler error?

This code: #include <boost/signals.hpp> #include <boost/bind.hpp> #include <boost/mem_fn.hpp> #include <iostream> class Recorder : public ::boost::signals::trackable { public: void signalled() { const void *me = this; ::std::cerr << "Recorder at " << me << " signalled!\n"; } }; void signalled() { ::std::cerr << "...

Static function access in other files

Hi, Is there any chance that Static function can be assessed outside the file scope. ? ...

Length of a BYTE array in C++

I have a program in C++ that has a BYTE array that stores some values. I need to find the length of that array i.e. number of bytes in that array. Please help me in this regard. This is the code: BYTE *res; res = (BYTE *)realloc(res, (byte_len(res)+2)); byte_len is a fictitious function that returns the length of the BYTE array and I...

where are the opengl libraries get stored on ubuntu : i need this to mention in my make file

where are the opengl libraries get stored on ubuntu9.10 : i need this to mention in my make file and what are all the link files i need to mention ...

If statement in c++

Hay Dear! i know that if statement is an expensive statement in c++. I remember that once my teacher said that if statement is an expensive statement in the sense of computer time. Now we can do every thing by using if statement in c++ so this is very powerful statement in programming perspective but its expensive in computer time pers...

boost::Spirit Grammar for unsorted schema

I have a section of a schema for a model that I need to parse. Lets say it looks like the following. { type = "Standard"; hostname="x.y.z"; port="123"; } The properties are: The elements may appear unordered. All elements that are part of the schema must appear, and no other. All of the elements' synthesised attributes go into...

C++: Why can't I use float value as a template parameter?

When I try to use float as a template param, the compiler cries for this code, while int works fine. Is it that I cannot use float as a template parameter? #include<iostream> using namespace std; template <class T, T defaultValue> class GenericClass { private: T value; public: GenericClass() { value = defaultValue; ...

using catch(...) (ellipsis) for post-mortem analysis

Someone in a different question suggested using catch(...) to capture all otherwise unhandled - unexpected/unforseen exceptions by surrounding the whole main() with the try{}catch(...){} block. It sounds like an interesting idea that could save a lot of time debugging the program and leave at least a hint of what happened. The essence ...

Should I use XML or Binary to send data from server to client ?

I have two separate apps - one a client (in C#), one a server (in C++). They need to exchange data in the form of "structs" and ~ about 1 MB of data a minute is sent from server to client. Whats better to use - XML or my own Binary format? With XML: Translating XML to a struct using a parser would be slow I believe? ("good",but: load...

C# and C++ Synchronize between processes

Hi guys, We have 2 applications. One written in C# and the other in C++. We need to maintain a counter (in memory) shared between these processes. Every time one of these applications start, it needs to check for this counter and increase it and every time the application shut-down it needs to decrease the counter. If the application has...

Best C++ library to interact with ICQ?

Hello. I have a Qt-based windows application written in C++ that needs to report it's status via ICQ and react on some ICQ messages. Maybe anyone know a good library to interact with ICQ? I need to connect ICQ with registered login and password, send messages to specified contacts and receive messages from them. ...

Extracting text from images

Can anyone tell me how to read the text in an image by using vc++ ...

ways to improve the launch speed of C++ application

Recently, my boss asked me to improve the launch speed of our application, the AP was written with C++. The AP is a little big, it used 200+ dll, Windows needs long time to enter the main() function. I tried these two ways, but still can't make our boss happy. 1. delay load dll http://msdn.microsoft.com/en-us/library/yx9zd12s(VS.80).aspx...

SMTP email on Windows using C++

Hi, Is there any Windows Native API to send SMTP based message using C++ ...