- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In most programs on the market, it is a standard feature to be able to right-click the mouse and get up a list of options for various actions. I want simply to be able to highlight some text in a window, right-click the mouse and get a list containing just "Copy", click on "Copy" and for it to go into the Windows' paste buffer for pasting elsewhere. Is this possible in Quickwin CVF Fortran? Alternatively, if this is not possible, I could allow the user to highlight the text and to click on "Copy" in the dialog window. The question then is - How do I write it to the Windows paste buffer?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's not too complicated if you involve some Windows APIs. I don't have a fully compilable example ready, but here are fewoffhandsnippets:
To display a 1-item context menu (place this e.g. in a MOUSE$RBUTTONUP callback):
hPopupMenu = CreatePopupMenu()
iSt=AppendMenu(hPopupMenu, MF_STRING.OR.MF_ENABLED, & IDC_COPY, LOC("Copy"))
idCommand = TrackPopupMenu(hPopupMenu, &
TPM_LEFTALIGN.OR.TPM_LEFTBUTTON.OR.TPM_RETURNCMD, &
iXPos, iYPos, 0, GetHWNDQQ(YourUnit), NULL)
IF (idCommand = IDC_COPY) THEN
iXPos, iYPos, 0, GetHWNDQQ(YourUnit), NULL)
IF (idCommand = IDC_COPY) THEN
!"Copy"item is selected
ELSE IF (idCommand = IDCANCEL) THEN
!The selection was canceled
END IF
iSt = DestroyMenu(hMenu)
Copying text to the clipboard is not too complicated either:
CHARACTER(Long_enough):: szText; POINTER(pszText, szText)
IF (OpenClipboard(NULL)) THEN
!Allocate "system global" buffer
hMem = GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, &
hMem = GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, &
LEN_TRIM(YourText)+1)
!Copy the text into your buffer
pszText = GlobalLock(hMem)
szText = TRIM(YourText)//CHAR(0)
!Unlock the memory & copy the text
iSt = GlobalUnlock(hMem)
hData = SetClipboardData(CF_TEXT, hMem)
iSt = CloseClipboard()
END IF
iSt = CloseClipboard()
END IF
However, the biggest obstacle is to retrieve(a block of) text from a QuickWin window. Unlike console windows, there's AFAIK no way to "get back" the string once you wrote it toa QuickWinchild window. Thus, you could use e.g. a multi-line edit control in adialog (which gives you context-menu with "Copy" functionality for free).
HTH
Jugoslav

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