How do I find position of a Win32 control/window relative to its parent window?

The solution is using the combined power of GetWindowRect() and MapWindowPoints(). GetWindowRect() retrieves the coordinates of a window relative to the entire screen area you see on your monitor. We need to convert these absolute coordinates into relative coordinates of our main window area. The MapWindowPoints() transforms the coordinates given relative to one window into … Read more

Should I deal with files longer than MAX_PATH?

It’s not a real problem. NTFS support filenames up to 32K (32,767 wide characters). You need only use correct API and correct syntax of filenames. The base rule is: the filename should start with ‘\\?\’ (see http://msdn.microsoft.com/en-us/library/aa365247(v=VS.85).aspx) like \\?\C:\Temp. The same syntax you can use with UNC: \\?\UNC\Server\share\Path. Important to understand that you can use … Read more

Why are “TranslateMessage” and “DispatchMessage” separate calls?

The more traditional message loop looks like this: while (GetMessage(&msg, 0, 0, 0)) { if (!TranslateAccelerator(hwndMain, haccel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } It is a pretty big hint to what you’d want to do before dispatching the message: catch messages that ought to be intercepted and treated specially before the window sees them. Keyboard … Read more

Under which circumstances does the System process (PID 4) retain an open file handle?

Files accessed through a share will be locked by the system process (PID 4). Try opening compmgmt.msc -> System Tools -> Shared Folders -> Open Files to see if the locked file is listed there See also the sysinternals forum for a way to replicate this. Not all applications lock files when they are opened, … Read more

How do you set the glass blend colour on Windows 10?

Since GDI forms on Delphi don’t support alpha channels (unless using alpha layered windows, which might not be suitable), commonly the black color will be taken as the transparent one, unless the component supports alpha channels. tl;dr Just use your TTransparentCanvas class, .Rectangle(0,0,Width+1,Height+1,222), using the color obtained with DwmGetColorizationColor that you could blend with a … Read more

Removing window border?

In C/C++ LONG lStyle = GetWindowLong(hwnd, GWL_STYLE); lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); SetWindowLong(hwnd, GWL_STYLE, lStyle); WS_CAPTION is defined as (WS_BORDER | WS_DLGFRAME). You can get away with removing just these two styles, since the minimize maximize and sytem menu will disappear when the caption disappears, but it’s best to … Read more