Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

Right click mouse for menu to copy highlighted text

rtsmith
Beginner
435 Views
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?
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
435 Views
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
!"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, &
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
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
0 Kudos
Reply