Recent

Author Topic: WinAPI - examples - post 6  (Read 2266 times)

440bx

  • Hero Member
  • *****
  • Posts: 4014
WinAPI - examples - post 6
« on: February 25, 2021, 07:04:00 pm »
This post includes examples for the following APIs :


The following two APIs are in one program named GetDesktopWindow

WinAPI - GetDesktopWindow         
WinAPI - GetWindowThreadProcessId 

This example gets the handle of the desktop window and the process and thread ids associated with it.  It also provides the option to hilight the desktop window in its "GetDesktopWindow" menu.

Note that the desktop window and the shell window are different windows in spite of the fact that they cover the same rectangle.




WinAPI - GetShellWindow           

This example is almost identical to the GetDesktopWindow except that it shows and highlights the shell window instead of the desktop window.




WinAPI - GetTaskmanWindow          (undocumented)

Also very similar to the above mentioned examples but showing the Task manager window.




The following two APIs are in one program named GetWindowTextLength

WinAPI - GetWindowText             
WinAPI - GetWindowTextLength       

This example shows how to use GetWindowText and GetWindowTextLength as well as drawing a frame around a window, creating a pen, offsetting a rectangle, locking out paint updates on a window, (using GetDCEx), SetROP2, SetWindowPos, GetCapture, ReleaseCapture, GetCursorPos, IsWindow and, LockWindowUpdate among others.

The example shows the window text and text length that is associated with the window that resides under the mouse.




WinAPI - IsTopLevelWindow          (undocumented)

Functionally similar to the GetWindowTextLength example.  It determines if the window that is currently under the cursor is a top level window or not.




WinAPI - GetTopLevelWindow          (undocumented)

The same as the IsTopLevelWindow example but displays the top level window that is associated with the window that is currently under the cursor.




WinAPI - SetWindowLong and SetWindowLongPtr

This example uses SetWindowLong (in 32bit) and SetWindowLongPtr (in 64 bit) to change its window frame from that of a typical window to one that has a thin dialog box frame without caption.

It also shows how to process the messages WM_NCHITTEST and WM_NCLBUTTONDBLCLK to switch from one frame style to another.

It also shows how to use a window's client area to drag it around the screen (feature is purposely active only when the window has no caption.)




Enjoy!.

« Last Edit: February 25, 2021, 07:21:24 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018