1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77:
| program ClipViewer;
{$R resource.res}
uses windows, messages;
const WM_RESETSELECTION = WM_USER + 1;
var hNextViewer: DWORD;
function DlgFunc(hWnd: hWnd; uMsg: dword; wParam: wparam; lParam: lParam): bool; stdcall; var hClipbrdObj: THandle; pClipbrdObj: Pointer; rect: TRect; begin result := true; case uMsg of WM_INITDIALOG: begin SendMessage(hWnd, WM_SETICON, ICON_BIG, Integer(LoadIcon(HInstance, MAKEINTRESOURCE(1)))); hNextViewer := SetClipBoardViewer(hWnd); end; WM_CHANGECBCHAIN: begin if wParam = hNextViewer then hNextViewer := lParam else if hNextViewer <> 0 then SendMessage(hNextViewer, uMSG, wParam, lParam); end; WM_SIZE: begin if GetClientRect(hWnd, Rect) then SetWindowPos(GetDlgItem(hWnd, 101), 0, Rect.Left, Rect.Top, Rect.Right - Rect.Left, Rect.Bottom - Rect.Top, SWP_NOZORDER); end; WM_DRAWCLIPBOARD: begin OpenClipboard(hWnd); hClipbrdObj := GetClipboardData(CF_TEXT); if hClipbrdObj <> 0 then begin pClipbrdObj := GlobalLock(hClipbrdObj); SendMessage(GetDlgItem(hWnd, 101), WM_SETTEXT, 0, Integer(pClipbrdObj)); PostMessage(hWnd, WM_RESETSELECTION, 0, 0); end; GlobalUnlock(DWORD(pClipbrdObj)); GlobalFree(hClipbrdObj); CloseClipBoard; end; WM_RESETSELECTION: SendMessage(GetDlgItem(hWnd, 101),EM_SETSEL, 0, 0); WM_CLOSE: begin ChangeClipBoardChain(hWnd, hNextViewer); EndDialog(hWnd, 0) end; else result := false; end; end;
begin DialogBoxParam(hInstance, MAKEINTRESOURCE(100), 0, @dlgfunc, 0); end. |