1.怎样操作剪贴板,从而实现复制、剪切与粘贴?同时判断剪贴板里边的数据是否是文本? if (!IsClipboardFormatAvailable(CF_TEXT)) return; if (!OpenClipboard(hwndMain)) return;
hglb = GetClipboardData(CF_TEXT); if (hglb != NULL) { lptstr = GlobalLock(hglb); if (lptstr != NULL) { // Call the application-defined ReplaceSelection // function to insert the text and repaint the // window.
Private Sub Form_Click () ' 定义位图各种格式。 Dim ClpFmt, Msg ' 声明变量。 On Error Resume Next ' 设置错误处理。 If Clipboard.GetFormat(vbCFText) Then ClpFmt = ClpFmt + 1 If Clipboard.GetFormat(vbCFBitmap) Then ClpFmt = ClpFmt + 2 If Clipboard.GetFormat(vbCFDIB) Then ClpFmt = ClpFmt + 4 If Clipboard.GetFormat(vbCFRTF) Then ClpFmt = ClpFmt + 8 Select Case ClpFmt Case 1 Msg = "The Clipboard contains only text." Case 2, 4, 6 Msg = "The Clipboard contains only a bitmap." Case 3, 5, 7 Msg = "The Clipboard contains text and a bitmap." Case 8, 9 Msg = "The Clipboard contains only rich text." Case Else Msg = "There is nothing on the Clipboard." End Select MsgBox Msg ' 显示信息。 End Sub