- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I want to copy some text (character area) from my quickwin-application to the clipboard and read from the clopboard. Is there an examle how this can be done. Thanks.
Solved, found an example
I want to copy some text (character area) from my quickwin-application to the clipboard and read from the clopboard. Is there an examle how this can be done. Thanks.
Solved, found an example
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps you could post some code or point others to the example you found?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is some example I worked out a couple of years ago:
I just tested that and it still works almost error free. I am getting an error 1418 on the call of
Kind regards,
Jrg Kuthe
www.qtsoftware.com
[bash]! Last change: JK 1 May 97 7:58 pm
SUBROUTINE PrintErr
USE DFWIN
PRINT*,'Error code= ',GetLastError()
END SUBROUTINE
PROGRAM ClipBoard
USE DFWIN
IMPLICIT NONE
CHARACTER, DIMENSION (:), ALLOCATABLE :: CBCopy
INTEGER (KIND=HANDLE) :: hWndNewOwner, hClipboardData
INTEGER (KIND=DWORD) :: CBObjectSize
INTEGER (BOOL) bRet
INTEGER :: ErrorCode, lpClipboardData, lpCBCopy
PRINT*,'Program ClipBoard returns current clipboard contents (text).'
hWndNewOwner = NULL
IF ( OpenClipboard(hWndNewOwner) ) THEN
hClipboardData = GetClipboardData(CF_TEXT)
IF (hClipboardData == NULL) THEN
CALL PrintErr
ELSE
PRINT*,'ClipBoard handle = ',hClipboardData
CBObjectSize = GlobalSize(hClipboardData)
PRINT*,'ClipBoard object size = ', CBObjectSize
! lock clipboard handle and get pointer to the beginning of the block
lpClipboardData = GlobalLock (hClipboardData)
! allocate memory to copy clipboard contents to
ALLOCATE(CBCopy(1:CBObjectSize), STAT=ErrorCode)
IF (ErrorCode/=0) THEN
PRINT*,'ALLOCATE failed, ErrorCode = ',ErrorCode
ELSE
! copy clipboard memory contents to CBCopy (use CopyMemory function)
lpCBCopy = LOC(CBCopy)
CALL CopyMemory( lpCBCopy, lpClipboardData, CBObjectSize )
!IF ( .EQ.NULL) THEN
! PRINT*,'CopyMemory failed'
!ELSE
PRINT*,'Clipboard contents: ',CBCopy(1:CBObjectSize)
!END IF
! Unlock clipboard block
bRet = GlobalUnlock (hClipboardData)
IF ( bRet == 0 ) THEN
ErrorCode = GetLastError()
PRINT*,'GlobalUnlock failed'
IF (ErrorCode == ERROR_ENVVAR_NOT_FOUND) THEN
PRINT*,' ErrorCode = ERROR_ENVVAR_NOT_FOUND; do not ask me why this...'
ELSE
PRINT*,' ErrorCode = ', ErrorCode
END IF
END IF
! deallocate CBCopy
DEALLOCATE(CBCopy, STAT=ErrorCode)
IF (ErrorCode/=0) PRINT*,'DEALLOCATE failed, ErrorCode = ',ErrorCode
END IF
END IF
IF (.NOT. CloseClipboard() ) CALL PrintErr
ELSE
CALL PrintErr
END IF
pause
END PROGRAM
[/bash] I just tested that and it still works almost error free. I am getting an error 1418 on the call of
[bash]CloseClipboard() [/bash](meaning: Thread does not have a clipboard open). Maybe someone has an idea what's wrong.
Kind regards,
Jrg Kuthe
www.qtsoftware.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The documentation of CloseClipboard says:
Return Values
Nonzero indicates success. Zero indicates failure.
So replace
IF (.NOT. CloseClipboard()) CALL PrintErr
with
IF (CloseClipboard()==0) Call PrintErr
The document also says that the return value is of type BOOL but keep in mind that a BOOL is not a LOGICAL. (see http://software.intel.com/en-us/forums/showthread.php?t=41785&o=a&s=lr)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page