AddClipboardFormatListener function
Applies to: desktop apps only
Places the given window in the system-maintained clipboard format listener list.
Syntax
BOOL WINAPI AddClipboardFormatListener( __in HWND hwnd );
Parameters
- hwnd [in]
-
Type: HWND
A handle to the window to be placed in the clipboard format listener list.
Return value
Type: BOOL
Returns TRUE if successful, FALSE otherwise. Call GetLastError for additional details.
Remarks
When a window has been added to the clipboard format listener list, it is posted a WM_CLIPBOARDUPDATE message whenever the contents of the clipboard have changed.
Requirements
|
Minimum supported client | Windows Vista |
|---|---|
|
Minimum supported server | Windows Server 2008 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/6/2012
- 9/20/2011
- Jack Tripper
Edit: This set of APIs (AddClipboardFormatListener, RemoveClipboardFormatListener, WM_CLIPBOARDUPDATE) was probably created after the problems with the previous set of APIs (ChangeClipboardChain, SetClipboardViewer, WM_DRAWCLIPBOARD). The problems were that the previous set of APIs depended on the programs itself to maintain the clipboard chain, just like the old, pre-Win3.1 hook APIs, and thus was fragile. If you kill a process that used the previous set of APIs, all the windows that came after the window that got killed was yanked out as well, as the next window varible was inside the process that got killed. It was error-prone as well, programs that do not implement WM_CHANGECBCHAIN properly could affect the operation of the ChangeClipboardChain function, and windows that do not pass on WM_DRAWCLIPBOARD messages could affect all of the windows that came after that window.
Edit 2: Wow.. all that text there, Yohawn, and not a single answer. Good job. Idiot.
Edit 3: That was very useful information.
- 10/3/2008
- BooGhost
- 10/14/2010
- GabSoftware
The description is not adequate to use this API. Please add more explanation like when this can be used. Probably…with a sample code.
[Conrad] Actually it's quite simple: All you need is your window handle, to start getting notification call AddClipboardFormatListener with your window handle, then later to stop getting updates call RemoveClipboardFormatListener http://msdn.microsoft.com/en-us/library/ms649050(v=VS.85).aspx.
Every time you get the WM_XXX message fetch the clipboard formats your application is interrested in. To handle the notification, add a WM_CLIPBOARDUPDATE handler into your message queue handler function.
- 9/9/2009
- Venu Nathani
- 9/22/2010
- Conrad Braam