呵呵,六个人已经有三个同意了,CJ应该不会骂我,六比四,来点心理准备,28K<br>得文字,所以把C++源程序省了,要得人可以写信给我,如果实在多,我可以给YYSUN<br><br>Creating a Clipboard Viewer Window<br><br>A clipboard viewer window displays the current content of the clipboard, and receives messages when the clipboard content changes. To create a clipboard viewer window, your application must do the following: <br>· Add the window to the clipboard viewer chain. <br>· Process the WM_CHANGECBCHAIN message. <br>· Process the WM_DRAWCLIPBOARD message. <br>· Remove the window from the clipboard viewer chain before it is destroyed. <br><br>Adding a Window to the Clipboard Viewer Chain<br><br>A window adds itself to the clipboard viewer chain by calling the SetClipboardViewer function. The return value is the handle of the next window in the chain. A window must keep track of this value ? for example, by saving it in a static variable named hwndNextViewer. <br>The following example adds a window to the clipboard viewer chain in response to the WM_CREATE message. <br>case WM_CREATE: <br> <br> // Add the window to the clipboard viewer chain. <br> <br> hwndNextViewer = SetClipboardViewer(hwnd); <br> break; <br> <br>Processing the WM_CHANGECBCHAIN Message<br><br>A clipboard viewer window receives the WM_CHANGECBCHAIN message when another window is removing itself from the clipboard viewer chain. If the window being removed is the next window in the chain, the window receiving the message must unlink the next window from the chain. Otherwise, this message should be passed to the next window in the chain. <br>The following example shows the processing of the WM_CHANGECBCHAIN message. <br>case WM_CHANGECBCHAIN: <br> <br> // If the next window is closing, repair the chain. <br> <br> if ((HWND) wParam == hwndNextViewer) <br> hwndNextViewer = (HWND) lParam; <br> <br> // Otherwise, pass the message to the next link. <br> <br> else if (hwndNextViewer != NULL) <br> SendMessage(hwndNextViewer, uMsg, wParam, lParam); <br> <br> break; <br> <br><br> <br>Removing a Window from the Clipboard Viewer Chain<br><br>To remove itself from the clipboard viewer chain, a window calls the ChangeClipboardChain function. The following example removes a window from the clipboard viewer chain in response to the WM_DESTROY message. <br>case WM_DESTROY: <br> ChangeClipboardChain(hwnd, hwndNextViewer); <br> PostQuitMessage(0); <br> break; <br><br>Processing the WM_DRAWCLIPBOARD Message<br><br>The WM_DRAWCLIPBOARD message notifies a clipboard viewer window that the content of the clipboard has changed. A window should do the following when processing the WM_DRAWCLIPBOARD message: <br> 1. Determine which of the available clipboard formats to display. <br> 2. Retrieve the clipboard data and display it in the window. Or if the clipboard format is CF_OWNERDISPLAY, send a WM_PAINTCLIPBOARD message to the clipboard owner. <br> 3. Send the message to the next window in the clipboard viewer chain. <br> <br>For an example of processing the WM_DRAWCLIPBOARD message, see the example listing in Example of a Clipboard Viewer. <br><br>Example of a Clipboard Viewer<br>