Click here to Skip to main content
15,891,976 members
Everything / Desktop Programming / Win32

Win32

Win32

Great Reads

by Szymon Roslowski
Just another approach to understanding communication between HID devices and C#.
by Jeffrey Walton
Import and export Cryptographic Keys in PKCS#8 and X.509 formats, using Crypto++, C#, and Java.
by Martin Mitáš
How to support scrolling within your controls.
by Hans Dietrich
XColorSpectrumCtrl displays a color spectrum that allows user selection, and provides APIs for color based on RGB and HSL color models.

Latest Articles

by Michael Chourdakis
An introduction to machine learning with working C++ code that trains a linear regression model.
by Ștefan-Mihai MOGA
Task Manager shows you the programs, processes, and services that are currently running on your computer. You can use Task Manager to monitor your computer’s performance or to close a program that is not responding.
by Ștefan-Mihai MOGA
This article is about the IntelliFile application which is a free alternative Windows version to Total Commander and uses many components that have been published on CodeProject.
by Michael Chourdakis
DirectX hardware screen capture and encoding with audio mixing capabilities. H264/H265/VP80/VP90/FLAC/MP3. HDR supported.

All Articles

Sort by Updated

Win32 

N 28 Apr 2024 by OriginalGriff
DeviceIoControl returns error code 50 when the requested operation is not supported by the device: System Error Codes (0-499) (WinError.h) - Win32 apps | Microsoft Learn[^] IIRC not all hard drives support serial numbers, so that may be your...
N 28 Apr 2024 by Gbenbam
The following program failed with GetLastError() returning code 50. What could be wrong? Please note the hard disk in question definitely has a serial number. BOOL GetDiskSerialNumber(std::wstring& wstSerialNumber, const TCHAR * wszPath) { ...
18 Apr 2024 by Michael Chourdakis
An introduction to machine learning with working C++ code that trains a linear regression model.
8 Apr 2024 by steveb
You need to draw to memory DC before you call BeginPaint. Your BeginPaint should have only 2 more lines after it - BitBlt and EndPaint. All drawing must be done prior to these lines. And perhaps use Direct2D API. This way you'll take care of...
8 Apr 2024 by Ștefan-Mihai MOGA
Task Manager shows you the programs, processes, and services that are currently running on your computer. You can use Task Manager to monitor your computer’s performance or to close a program that is not responding.
6 Apr 2024 by Pete O'Hanlon
The problem you're describing is resolution. Typically, printers support a much higher resolution than a screen does, so if you have made assumptions about DPI, for instance, you will see a different output. It's best to work with Device...
6 Apr 2024 by Gbenbam
The display program that I used to render to a window dc was used by me to write to PriPrinter a virtual printing software. Everything worked fine except that the images were rendered to true size and not according to specified size. Is it...
5 Apr 2024 by Gbenbam
For some time now I have been trying to resolve the WM_PAINT code or my application. Every advise I have ever been given on this issue, I have applied. Someone said I should carry out all the DC operations in WM_PAINT. I did that. Someone said...
5 Apr 2024 by KarstenK
I see no easy fix but you may debug it via double buffering. At first you paint a complete image into some memory dc and than make a BitBlt to the screen. Read this Guide to DC to improve your knowledge. Best is to optimize the code via...
30 Mar 2024 by Ștefan-Mihai MOGA
This article is about the IntelliFile application which is a free alternative Windows version to Total Commander and uses many components that have been published on CodeProject.
28 Mar 2024 by Richard MacCutchan
Here is the essential parts of the code I use to allow scrolling in a self painted Window. If you want an easier life then you can use one of the standard Windows controls (e.g. Edit Control (Windows Controls) - Win32 apps | Microsoft Learn[^] )...
27 Mar 2024 by Gbenbam
In the program below, everything works fine until I try to scroll with the thumbtrack. The thumtrack simply snaps back to its initial position after I release it. What could be wrong? case WM_VSCROLL: { SCROLLINFO scrollInfo; ...
23 Mar 2024 by merano99
What is meant by scrolling in this case is unclear. I assume that an image is to be drawn that is larger than the window. If the image is not to be scaled to the size of the window, you will only see the part of the image that fits into the...
22 Mar 2024 by OriginalGriff
If I understand you right, you are trying to "draw a picture" (which is what all text and lines end up as when they are rendered for actual display) that is bigger than the bitmap you are drawing into. Imagine this: you have a whiteboard on your...
22 Mar 2024 by Gbenbam
My app's document contains redered images, ellipse, rectangles, lines etc. For as long as I don't scroll past the memory dc bitmap size, display comes out fine, but ones I scroll over a distance greater than the memory dc bitmap size,the display...
21 Mar 2024 by Ege Öztaş
I am trying to understand python's capability to use Windows Messages with pywin32 library. For this I have created 2 scripts that are supposed to run parralel to each other. One is a client that is supposed to send messages the other is a server...
20 Mar 2024 by Michael Chourdakis
DirectX hardware screen capture and encoding with audio mixing capabilities. H264/H265/VP80/VP90/FLAC/MP3. HDR supported.
28 Feb 2024 by Chris Boss
BASIC: A powerful language often underestimated and undervalued
21 Feb 2024 by Ștefan-Mihai MOGA
You can use IntelliPort to transfer large files from a computer onto your portable computer using a serial port rather than going through the process of setting up your portable computer on a network.
20 Feb 2024 by Alex Rakov, Alexandre Bencz
ELENA is a general-purpose, object-oriented, polymorphic language with late binding
14 Feb 2024 by Michael Haephrati
Windows Services are powerful little beasts and encountering them is unavoidable when developing under Windows
1 Feb 2024 by Michael Chourdakis
Easily migrate to WinUI3 from plain Win32 while keeping all Win32 features intact
25 Jan 2024 by Bruno van Dooren
An introduction to exporting functions from DLLs
24 Jan 2024 by Allegra Angelo
Save, read and text recognition of network parameters
20 Jan 2024 by Ștefan-Mihai MOGA
The article discusses the concept of cryptography and its application in ensuring data security.
11 Jan 2024 by Bruno van Dooren
In this article, I explain how to create win32 style DLLs and what the various significant intricacies are.
25 Nov 2023 by Richard MacCutchan
It depends where you are storing the data that you dispaly in the Window. The proper sequence of operations is to respond to the WM_PAINT message by displaying all the relevant information in the window, as controlled by any scrollbar...
21 Nov 2023 by R1S8K
Hi, I'm working on developing my win32 api test application. I've done the tool bar menus. Static and button controls. Every thing is OK, but the problem is that when I want to print a new content, I still have some stuff from the previous...
13 Nov 2023 by zhivot
I am converting between GDI (Win32 API) and different drawing format that also supports text and glyph rotation. Text output in GDI is specified with a reference point (and vertical alignment), but it is easy to take that into account when the...
6 Nov 2023 by Gbenbam
The code below is snippet of a code in my application whose goal is to get item data from a listbox. for (int j = 0; j
5 Nov 2023 by Richard MacCutchan
I just tried the same code and it works correctly. You need to use the debugger to check what is happening. It would also help if you put the code in order, and showed the actual values that it uses.
3 Nov 2023 by Gbenbam
I have come to realise that one of the issues causing failure in my application recently is the improper use of smart pointer. I thought I had complete grasp of its usage until now! Consider the code snippet from an application that consumed...
3 Nov 2023 by Richard MacCutchan
The problem you have is with this line: int iSelected = (int)SendMessage(GetDlgItem(hDlg, IDC_LIST2), LB_GETSELITEMS, 0, (LPARAM)pStatus.get()); The WPARAM item is required to contain the maximum size of the input buffer: see...
27 Oct 2023 by Kyudos
I have some C code for a Win32 DLL that I'm trying to modify, but I'm having to guess at the build settings, because it is just code. I've got it building in VS2010, and it seems to be mostly working (despite some dodgy coding!) However, calls...
26 Oct 2023 by CPallini
A hint from 'the documentation[^]': CDERR_DIALOGFAILURE 0xFFFF The dialog box could not be created. The common dialog box function's call to the DialogBox function failed. For example, this error occurs if the common dialog box call specifies an...
26 Oct 2023 by KarstenK
You must do something wrong in the call like not provided enought data with null pointers. Read the documentation and the example code from Microsoft to learn it.
24 Oct 2023 by samas69420
I have a window made with win32 API and inside this window, there is a smaller window in which another thread draws images using opengl. I removed the default frame and painted the visible portion of the big window so I can use it as a custom...
24 Sep 2023 by merano99
When a Win32 DLL is loaded into an application using the LoadLibrary function, the DLL is loaded into the application's memory and becomes part of the application's address space. This means that the DLL and the original executable (exe) are in...
24 Sep 2023 by honey the codewitch
I was creating the window on a different thread without realizing it. Once I fixed that the problem went away.
23 Sep 2023 by honey the codewitch
I've got a DLL that gets loaded by a parent executable. The DLL needs to create a window. I'd like the DLL window to use the primary message loop in the executable, but the windowproc in the DLL. I'm just curious if this even a thing I can do,...
21 Sep 2023 by honey the codewitch
You need to use the HWND in the lParam of the WindowProc instead of the HWND retrieved from CreateWindowEx on the edit control.
21 Sep 2023 by honey the codewitch
I'm hanging on to my edit control window handle and calling GetWindowText every time I get a WM_COMMAND with EN_CHANGE on the parent window From there I don't get any reasonable value back. It's just an empty string. How the heck do I get the...
20 Sep 2023 by Javad Taheri (drjackool)
Show or hide, reorder, save and restore list view column headers
19 Sep 2023 by TheNewbieProgrammer
I know this may sound silly, but to fix this you need to replace the color value with the starting color. And the other thing you need to do is to use elapsedTime instead of deltaTime to calculate the progress. Here's the code: float progress =...
17 Sep 2023 by .dan.g.
A hierarchical task manager with native XML support for custom reporting
13 Sep 2023 by honey the codewitch
I have a little directX that is simply an overlapped window with a Direct2d surface on it. In WM_PAINT, I try to fill some memory with the color purple, and then copy that to a bitmap, before writing the bitmap to a display. Trouble is,...
13 Sep 2023 by Maxim Kartavenkov
You should made proper question naming as your question is about Direct2D not the DirectDraw - different technologies. Anyway here is the simple workable example implementation of what you need. It trigger repaint event each second and update...
12 Sep 2023 by NoviceCoder871987
I ran into a weird issue with custom drawing the listview control. I drew the grid lines in response to CDDS_POSTPAINT notification. All working okay so far. However, when scrolling vertically, the lines will be messed up and will not be drawn at...
9 Sep 2023 by Richard MacCutchan
See About Custom Draw - Win32 apps | Microsoft Learn[^] for custom drawing in Report mode.
20 Aug 2023 by Ștefan-Mihai MOGA
How to download files from an HTTP server.
13 Aug 2023 by Michael Chourdakis
Use SHA-3 and the CRYSTALS Kyber, Dilithium and Sphincs in Win32 projects
24 Jul 2023 by Michael Haephrati
The following code locates the handles of all windows per a given PID. #include #include void GetAllWindowsFromProcessID(DWORD dwProcessID, std::vector& vhWnds) { // find all hWnds (vhWnds) associated with a...
17 Jul 2023 by Rick York
One thing to keep in mind is the Windows timer works on multiples of 60Hz or 16.7ms. That is as low as it will go about 60Hz is achievable as is 30Hz. At the risk of blowing my own horn, I like this class for determining elapsed time : High...
17 Jul 2023 by TheNewbieProgrammer
I will explain the problem very briefly: In order to get a color animation, the lerp algorithm must be used to change the colors smoothly, which requires the progress of the animation (std::min)((deltaTime / duration), 1.0f) But there is a...
16 Jul 2023 by KarstenK
You wil have to dig it out yourself. Start by making more TRACE output with a detailed timestamp. I would use some constant for the timer id. In this code your arent correctly use the timer id. Check it! tip: start with a low frame rate like 10...
9 Jul 2023 by Avtem
There is a WM_SETREDRAW message in WinAPI which you can send to a window in order to suspend/resume drawing updates. It works fine, but as soon as i add visual styles from comctl32 v.6.0.0 to my program calling WM_SETREDRAW on a ListView control...
9 Jul 2023 by Avtem
Unfortunately i couldn't figure out how to use WM_SETREDRAW with ListView controls, but since MDSN describes us how it's implemented i decided to do what they do - remove or add WS_VISIBLE style from the window without invalidating its rectangle....
9 Jul 2023 by Richard MacCutchan
See the Remarks section at WM_SETREDRAW message[^].
18 Jun 2023 by Michael Chourdakis
Use your sensors for identification and verification
5 Jun 2023 by Sarthak S
Assembly inspection and hacking with windbg
31 May 2023 by Sarthak S
Assembly inspection and hacking with windbg
7 May 2023 by ToughDev
How to allow only numeric input in TextBox
6 May 2023 by Michael Chourdakis
How to use the WinUI3 controls in a plain Win32 application without packaging
25 Apr 2023 by Richard MacCutchan
See ComboBox.AutoCompleteMode Property (System.Windows.Forms) | Microsoft Learn[^]. My apologies, try CB_FINDSTRING message (Winuser.h) - Win32 apps | Microsoft Learn[^]
25 Apr 2023 by Avtem
So, many WinAPI controls have a very useful feature - you can select an item in Listbox, ListView, Combobox by typing first several letters. You can try it out: just open your windows calculator, hit Ctrl+U to enable converting units view and in...
16 Apr 2023 by Member 15980553
I've Tested this bindshell and it's working. in order to work you should use WSASocket & WSAAccept (CreateProcess I/O redirection requires HANDLEs that are non-Overlapped. Which is why use of socket doesn't work and WSASOCKET does) #include...
16 Apr 2023 by Member 13265280
Hello, I would like to get bind/reverse shell with win32 winsock. By calling CreateProcess with STARTF_USESTDHANDLES, I got a reverse shell (client mode) as expected. However I failed to got a bind shell (server mode) with same approach. What is the difference between client mode (reverse...
2 Apr 2023 by Bruno van Dooren
In this article, I will explain Asynchronous Procedure Calls (APCs), their uses and their pitfalls
1 Apr 2023 by Member 15925018
I use isf (type: IShellFolder* defined in ShlObjDl_Core.h) to use ParseDisplayName because it's a nonstatic member of IShellFolder, so it must be relative to a specific object. But, when I use that code: IShellFolder* isf; LPITEMIDLIST lprnt = {...
1 Apr 2023 by KarstenK
As Richard already wrote, you are missing some basics. To kickstart read the Microsoft documentation. Such stuff isnt a walk in the park, so you must understand the complex topic. Good luck. Here is some interesting stuff on github. When...
1 Apr 2023 by Richard MacCutchan
Similar to your previous question at I get always an error "exception thrown: write access violation. Lpsh was nullptr."[^]. But in this case you create a pointer but you do not initialise it to point to anything. If you do not understand...
30 Mar 2023 by Saleh 2023
What is wrong with this code line ? DWORD quantityXreserved; // I think there is a proper format // For the variable name // "quantityXreserved" , but // I donot know how exactly I am getting this error : Intellisence identifier "DWORD" is...
30 Mar 2023 by cute_friend7077
typedef unsigned long DWORD;
27 Mar 2023 by merano99
For Windows data types you should include windows.h.
21 Mar 2023 by gbeene
Capture protected document content as text without the need for breaking DRM
12 Mar 2023 by JacobLaw1
How do I fix "Severity Code Description Project File Line Suppression State Error (active) E0167 argument of type "LPSTR" is incompatible with parameter of type "LPCWSTR""? LPSTR lpsz; HWND handle, handle2; handle = FindWindowA(NULL,...
12 Mar 2023 by Dave Kreskowiak
You're retrieving the window text with GetWindowTextA, which will return an ANSI string, which is an array of single byte characters. LPSTR stands for "Long Pointer To Ansi String." The "Long" is a remnant from the old days of DOS, Windows 3.x,...
12 Mar 2023 by merano99
If you already use = FindWindowA() and GetWindowTextA(), why not MessageBoxA() as well? If you use C++ you should also think about using std::string and std::wstring.
12 Mar 2023 by Rick York
It appears that you have UNICODE defined. You call FindWindowA and GetWindowTextA which both take a MBCS character string. Then MessageBox is called and it takes a Unicode OR MBCS string, depending on whether UNICODE is defined. If you call...
11 Mar 2023 by JacobLaw1
How do I print the GetTitleBarInfo() title in a message box? What I have tried: I need to somehow work with the pointer PTITLEBARINFO pTi; in BOOL GetTitleBarInfo(handle, pTi);
11 Mar 2023 by Dave Kreskowiak
Ummm... GetTitleBarInfo does NOT get the text of the title bar of a window. It returns a RECT structure that describes the bound of the title bar, and array of 6 integers indicating the state of certain title bar elements. Did you not read the...
5 Mar 2023 by spidergeuse
Customize jigsaw (size and picture)
2 Mar 2023 by Michael Chourdakis
Quicky generate text and images
3 Feb 2023 by Paolo Messina
Class library to make development of resizable windows a easier for the MFC developer and pleasant for the user
23 Jan 2023 by vikramlinux
We are trying to use Shell_NotifyIcon along with NOTIFYICONDATA structure. On Window 10, We are seeing that if we try to display the balloon notification area along with Title ICON , the ICON gets copied to temp folder everytime it is displayed. It is possible to avoid this ? We have certain use...
23 Jan 2023 by Member 11229828
#include int main() { // Create a NOTIFYICONDATA structure NOTIFYICONDATA nid; ZeroMemory(&nid, sizeof(nid)); nid.cbSize = sizeof(nid); nid.hWnd = NULL; nid.uID = 1; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; ...
12 Jan 2023 by Yount_0701
When I try to draw a string in win32 program, there are some APIs like TextOut or DrawText and so on. If I want to draw a string of unicode which using wchar_t string, I should define the UNICODE marco. It works well untill some special...
12 Jan 2023 by Rick York
Yes, I have done this and the key is to use a font that depicts those characters the way you want. Try the Character Map application to see what they look like in various fonts. When you find a font that you like then you can create it and...
1 Jan 2023 by Graeme_Grant
For Data Binding[^], you use an ObservableCollection[^] class, not a List. UPDATE The trick with Data Binding[^] is not to replace the collection with a new collection, but to clear and add to the collection. Replacing the collection will...
31 Dec 2022 by Member 15061773
Hi there, I have a WPF application where I use a ComboBox. My ComboBox ItemSource is bind to a List which I populate from C# in background. Here is the C# code of that List : // Main code List devices = new...
27 Dec 2022 by Bruno van Dooren
What to do when you want to use the current thread handle
22 Dec 2022 by Bruno van Dooren
How to implement named pipe server for communicating with client apps
9 Dec 2022 by Bruno van Dooren
How to implement named pipe server for communicating with client apps
24 Nov 2022 by Bruno van Dooren
When calling into the win32 API, there are many times when you must deal with structures that have a variable size. This article shows how to do that in a convenient way.
20 Nov 2022 by Richard MacCutchan
See Using Tooltip Controls - Win32 apps | Microsoft Learn[^]. Also Tooltip Control Messages - Win32 apps | Microsoft Learn[^].
20 Nov 2022 by Yount_0701
In the non-client area of a standard win32 window, there would be three little buttons like maximize, minimize,close. When you put your cursor in these areas for some seconds, there would be a tooltip explaining the area for the area which your...
3 Nov 2022 by Bruno van Dooren
The win32 subsystem often returns pointers to objects that need to be deallocated by the caller. In this article, I show a way to do this reliably and in an exception-safe manner.