Relative Content

Tag Archive for c++winapi

Message handling for a dialog

When using a dialog as a main form, what is the bare minimum of checks prior to having the TranslateMessage and DispatchMessage? In a code:

Casting to LPPOINT

Is casting a TPOINT argument to LPPOINT needed or not in the following scenario:

I can not create a caret using a bitmap

Even though I changed the WM_SETFOCUS section of the code under the “Processing Keyboard Input” heading in the link below to use a bitmap for caret, I cannot get any caret image on the screen and no error message from CreateCaret() function. I have checked that the code created a bitmap or not.

How to copy a bitmap to my window buffer?

My program creates a window with the Windows API. I allocate a memory region with the VirtualAlloc() function, and with two for loops i iterate through it and change the RGB values of each pixel to cover the whole client are with a color.

The call to SetClipboardData after EmptyClipboard

Is call to SetClipboardData needed after the call to EmptyClipboard when the clipboard is opened using a nullptr argument? When clearing the clipboard content, can the call to SetClipboardData be omitted?

Why asyncronous WriteFileEx behave like synchronous?

I’m trying to write something to replace synchronous WriteFile + CancelSynchronousIo, to add Windows XP support to a program. I chosed asynchronous WriteFile and CancelIo, that is much heavier to satisfy. I wrote small program to test behavior (full code). After some tests I understand that I don’t understand what is going on: