Home   Index   About
Ultimate Pack


Custom Search
Using the Owner-Display Clipboard Format

If a window places information on the clipboard by using the CF_OWNERDISPLAY clipboard format, it must do the following:

  • Process the WM_PAINTCLIPBOARD message. This message is sent to the clipboard owner when a portion of the clipboard viewer window must be repainted.

  • Process the WM_SIZECLIPBOARD message. This message is sent to the clipboard owner when the clipboard viewer window has been resized or its content has changed.

Typically, a window responds to this message by setting the scroll positions and ranges for the clipboard viewer window. In response to this message, the Label application also updates a SIZE structure for the clipboard viewer window.

  • Process the WM_HSCROLLCLIPBOARD and WM_VSCROLLCLIPBOARD messages. These messages are sent to the clipboard owner when a scroll bar event occurs in the clipboard viewer window.

  • Process the WM_ASKCBFORMATNAME message. The clipboard viewer window sends this message to an application to retrieve the name of the owner-display format.

The window procedure for the Label application processes these messages, as follows.

LRESULT CALLBACK MainWindowProc(hwnd, msg, wParam, lParam)

HWND hwnd;

UINT msg;

WPARAM wParam;

LPARAM lParam;

{

static RECT rcViewer;

RECT rc;

LPRECT lprc;

LPPAINTSTRUCT lpps;

switch (msg)

{

//

// Handle other messages.

//

case WM_PAINTCLIPBOARD:

// Determine the dimensions of the label.

SetRect(&rc, 0, 0,

pboxLocalClip->rcText.right + CX_MARGIN,

pboxLocalClip->rcText.top * 2 + cyText

);

// Center the image in the clipboard viewer window.

if (rc.right < rcViewer.right)

{

rc.left = (rcViewer.right - rc.right) / 2;

rc.right += rc.left;

}

if (rc.bottom < rcViewer.bottom)

{

rc.top = (rcViewer.bottom - rc.bottom) / 2;

rc.bottom += rc.top;

}

// Paint the image, using the specified PAINTSTRUCT

// structure, by calling the application-defined

// PaintLabel function.

lpps = (LPPAINTSTRUCT) GlobalLock((HGLOBAL) lParam);

PaintLabel(lpps, pboxLocalClip, &rc);

GlobalUnlock((HGLOBAL) lParam);

break;

case WM_SIZECLIPBOARD:

// Save the dimensions of the window in a static

// RECT structure.

lprc = (LPRECT) GlobalLock((HGLOBAL) lParam);

memcpy(&rcViewer, lprc, sizeof(RECT));

GlobalUnlock((HGLOBAL) lParam);

// Set the scroll ranges to zero (thus eliminating

// the need to process the WM_HSCROLLCLIPBOARD and

// WM_VSCROLLCLIPBOARD messages).

SetScrollRange((HWND) wParam, SB_HORZ, 0, 0, TRUE);

SetScrollRange((HWND) wParam, SB_VERT, 0, 0, TRUE);

break;

case WM_ASKCBFORMATNAME:

LoadString(hinst, IDS_OWNERDISPLAY,

(LPSTR) lParam, wParam);

break;

default:

return DefWindowProc(hwnd, msg, wParam, lParam);

}

return 0;

}


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun