- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
I've done some searching on this issue, but with no results.
I want to retrive the contents of the clipboard (characters only) in one of my programs (built with CVF 6.6B). It appears to me that if the support was there, it would be a matter of calling some function which would return a character string with the contents of the clipboard. Does anyone have experience on this?
Thank you.
Joo
I want to retrive the contents of the clipboard (characters only) in one of my programs (built with CVF 6.6B). It appears to me that if the support was there, it would be a matter of calling some function which would return a character string with the contents of the clipboard. Does anyone have experience on this?
Thank you.
Joo
Ссылка скопирована
6 Ответы
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Fragment from an actual app:
Jugoslav
INTEGER:: iSt, i, hData CHARACTER:: sText(*); POINTER(pText, sText) ... IF (IsClipboardFormatAvailable(CF_TEXT)) THEN iSt = OpenClipboard(NULL) hData = GetClipboardData(CF_TEXT) pText = LocalLock(hData) !Do something with sText here iSt = LocalUnlock(hData) iSt = CloseClipboard() END IFBasically, sText is a string of "infinite" length, CHAR(0) terminated. You can copy it to your own string variable up to CHAR(0).
Jugoslav
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
So is pasting text to the clipboard similar to this code fragment?
Harry Bell
Harry Bell
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Um, pasting to? You mean, copying to? Yes, should be (but I didn't try). You have to allocate the memory using GlobalAlloc, obtain the normal pointer to it via GlobalLock (I think Cray (integer) pointers have to be used), copy the contents of your data into that pointer and call SetClipboardData. Don't forget to call GlobalUnlock, but do not call GlobalFree -- system will do it.
Jugoslav
Jugoslav
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Ha, I did find a sample (it's for copying a bitmap so it's a tad complicated):
INTEGER:: iSizeImage, cClrBits, iSt, hmemBmBits, hClipboard INTEGER(1):: bmBits(*); POINTER(pbmBits, bmBits) TYPE(T_BITMAPINFO):: BI; POINTER(pBI,BI) ... !Allocate memory for BITMAPINFO structure. It consists of BITMAPINFOHEADER !structure followed immediately in memory by array of color bits. hmemBmBits = GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, iSizeImage+SIZEOF(BI%bmiHeader)) pbmBits = GlobalLock(hmemBmBits) pBI = pbmBits !Fill in the BITMAPINFOHEADER. BI%bmiHeader%biSize = SIZEOF(BI%bmiHeader) BI%bmiHeader%biWidth = 100 BI%bmiHeader%biHeight = 100 BI%bmiHeader%biPlanes = 1 !1 plane (e.g. icons have 2) BI%bmiHeader%biBitCount = cClrBits !color depth BI%bmiHeader%biCompression = BI_RGB !no compression BI%bmiHeader%biSizeImage = iSizeImage BI%bmiHeader%biXPelsPerMeter = 96*100/2.54+1 BI%bmiHeader%biYPelsPerMeter = 96*100/2.54+1 BI%bmiHeader%biClrImportant = 0 !Get the color bits into BI. Actual bits start at this offset--v iSt = GetDIBits(hdcComp, hBmp, 0, 100, pbmBits+SIZEOF(BI%bmiHeader), & pBI, DIB_RGB_COLORS) !Release the resources for buffer iSt = DeleteObject(hBmp) iSt = DeleteDC(hdcComp) hClipboard = OpenClipboard(GETHWNDQQ(QWIN$FRAMEWINDOW)) !Copy the contents onto clipboard iSt = SetClipboardData(CF_DIB, hmemBmBits) !Clean up iSt = CloseClipboard() iSt = GlobalUnlock(hmemBmBits)
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
I'm having trouble following Jugoslav's second example and how it can be morphed into code to copy text onto the clipboard (after eliminating what already exists on the clipboard). Does anybody have a simpler code fragment for copying text onto the Windows clipboard?
Harry Bell
Harry Bell
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Below is a far simpler CVF code fragment that I finally
figured out for pasting text onto the clipboard.
Clipstring is a zero terminated string, all other variables are integer*4.
Ilen is the length of clipstring from the first character through the null byte:
Harry Bell
figured out for pasting text onto the clipboard.
Clipstring is a zero terminated string, all other variables are integer*4.
Ilen is the length of clipstring from the first character through the null byte:
... pstring = LOC(clipstring) iSt = OpenClipboard(NULL) iSt = EmptyClipboard() hData = GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, ilen) pdummy = GlobalLock(hData) call CopyMemory(pdummy,pstring,ilen) iSt = SetClipboardData(CF_TEXT,hData) iSt = CloseClipboard() iSt = GlobalUnlock(hData) ...
Harry Bell

Ответить
Параметры темы
- Подписка на RSS-канал
- Отметить тему как новую
- Отметить тему как прочитанную
- Выполнить отслеживание данной Тема для текущего пользователя
- Закладка
- Подписаться
- Страница в формате печати