Today we discussed a question how to copy own-drawn picture to clipboard (for PaintBrush, Word and so on).
Bellow you can find more than simple solution (I found this solution on one of VB site).
You can type any text, then press "Copy to clipboard", switch to Word/Paintbrush and press Ctrl-V.
[This message has been edited by Semen Matusovski (edited May 04, 2000).]
Bellow you can find more than simple solution (I found this solution on one of VB site).
You can type any text, then press "Copy to clipboard", switch to Word/Paintbrush and press Ctrl-V.
Code:
#Compile Exe #Register None #Dim All #Include "Win32Api.Inc" Global hDlg As Long Sub CopyPicture(hWnd As Long) Static hBmpClip As Long Dim hDC As Long, hDC1 As Long, hBmp As Long, rc As Rect, hBmpOld As Long hDC = GetDC(hWnd) hDC1 = CreateCompatibleDC(hDC) GetClientRect hWnd, rc hBmp = CreateCompatibleBitMap (hDC, rc.nRight, rc.nBottom) hBmpOld = SelectObject (hDc1, hBmp) BitBlt hDC1, 0, 0, rc.nRight, rc.nBottom, hDC, 0, 0, %SRCCOPY SelectObject hDC1, hBmpOld OpenClipboard ByVal 0 EmptyClipboard If hBmpClip > 0 Then DeleteObject hBmpClip SetClipboardData %CF_BITMAP, hBMP CloseClipboard DeleteObject hDC1 hBmpClip = hBmp ReleaseDC hWnd, hDC End Sub CallBack Function ButProc CopyPicture hDlg End Function Function PbMain () As Long Dialog New 0, "Polus", ,, 200, 70, %WS_SYSMENU To hDlg Control Add TextBox, hDlg, 101, "", 5, 5, 190, 12 Control Add Button, hDlg, 102, "Copy client area", 30, 30, 140, 15 Call ButProc Dialog Show Modal hDlg End Function