Im creating a simple PopUp menu... first I tried to use only PureBasic
commands but it seems that is imposible (at least for me
I decided to use win API but new in this topic, I can not make run the simple one.
The problem I have: I cant copy selected text to the clipboard.... using
#EM_GETSELTEXT
Could you give me a hand???
Code: Select all
Enumeration ;PopUp Menu
#PopUp_0
EndEnumeration
Enumeration ; PopUp menu items
#popCut
#popCopy
#popPaste
#popSelectAll
#popFind
EndEnumeration
Enumeration ; Gadget where menu works
#ed_file
EndEnumeration
If OpenWindow(0, 200, 200, 400, 400, #PB_Window_SystemMenu, "Popup-Menu")
If CreatePopupMenu(#PopUp_0)
MenuItem(#popCut, "Cut"+Chr(9)+"Ctrl+X")
MenuItem(#popCopy, "Copy"+Chr(9)+"Ctrl+C")
MenuItem(#popPaste, "Paste"+Chr(9)+"Ctrl+V")
MenuBar()
MenuItem(#popSelectAll, "Select All"+Chr(9)+"Ctrl+A")
MenuBar()
MenuItem(#popFind, "Find"+Chr(9)+"Ctrl+F")
EndIf
If CreateGadgetList(WindowID())
EditorGadget(#ed_file, 1, 1, 390, 390)
EndIf
Repeat
Event = WaitWindowEvent()
WindowID = EventWindowID() ; In what window or
MenuID = EventMenuID() ; In what menu item or:
GadgetID = EventGadgetID() ; In what gadget.:
EventType = EventType() ; Type of event for SOME gadgets (no menus, not ALL gadgets)
If Event = #WM_RBUTTONDOWN ; I want to use PureBasic.. apparently there is no way...
DisplayPopupMenu(#PopUp_0, WindowID()) ; display popup-menu
EndIf
If Event = #PB_Event_Menu
Select MenuID
Case #popCut
;"Menu: Cut"
Case #popCopy
SendMessage_(GadgetID(#ed_file),#EM_GETSELTEXT,0,text$) ; HERE IS THE PROBLEM
MessageRequester("ccc",text$,#PB_MessageRequester_Ok) ; to show if Im geting the text....
SetClipboardText(text$)
Case #popPaste
Text$ = GetClipboardText()
AddGadgetItem(#ed_file, -1, Text$ )
Case #popSelectAll
; Select All"
Case #popFind
;"Menu: Find"
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf


