Code Library

Free Source Code and Program Tips

How to catch the events when you click on the application’s icon on the taskbar?

How to send/post message to CDocument?

Sometime you need to send/post message to CDoumnet, but CDocument is not a window, and it can’t receive message. How do that? There are 3 solutions: Solution 1: Send the message to the main window. Send/Post the message to the main frame or the view, and then call some functions of the document. But if [...]

Intermittent work in UI thread

Pedro Ferreira I’m trying to create a UI thread to do constant background work, but I’m having some design problems. The thread needs to fetch records from a database. do some processing on each record and, when there are no more records, sleep for 1 minute before check the database again. The process will be [...]

Intermittent work in UI thread

Pedro Ferreira said: I’m trying to create a UI thread to do constant background work, but I’m having some design problems. The thread needs to fetch records from a database. do some processing on each record and, when there are no more records, sleep for 1 minute before check the database again. The process will [...]

Install global hook without dll

Chinese version author: peach@newsmth.net Userally, when you install a global hook, you need a dll. But now, you can install WH_KEYBOARD_LL or WH_MOUSE_LL global hook without dll’s help. The following code was tested under win2k3. And I it will also run on 2k/xp.

We often meet such case: I have an application with a modeless dialog. The dialog comes up perfectly in DEBUG build, But in RELEASE build, it crashed. Such problem often occures because of incorrect signature of message handle functions, that included into MFC message map for your CWnd based class.We should very carefully check signatures [...]

What is the usage of WM_NULL?

Alex Rest found the WM_NULL message and was curious where somebody would need to use that. I have found a strange Windows message. It is described in MSDN so: WM_NULL: The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore. [...]