Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

support of edit keys via menu shortcuts

Status
Not open for further replies.

srbentley

Programmer
Dec 8, 2000
7
US
I'm trying to make my UI nice and professional and add an Edit menu like most Win programs have. If the user doesn't know about Ctrl-X for cutting for example, they need to use Cut from the Edit menu. However, I'm not sure what to do at that point. I tried SendKey {^}x (Ctrl-X) but that doesn't seem to work. Any ideas out there greatly appreciated.

Steve
 
You need to use the
Code:
Clipboard
object. try the VB App Wizard and choose all the default menus. When the wizard has finished the code will hopefully in place..

As an example, to copy the selected text in a textbox use:

Code:
ClipBoard.SetText txtMain.Seltext

This code goes in the menus copy procedure.

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
The VB app wizard unfortunately just gives you dummy code to replace. By using the clipboard object I guess I'll have to keep track of which text field has focus. Then I'll know whose text to put in the clipboard. Then I can copy, cut, paste. Undo will be a little harder.
 
Hi,
heres the code that might solve that problem:

Code:
Private Sub EditCut_Click ()
   ' Clear the contents of the Clipboard.
 Clipboard.Clear
   ' Copy selected text to Clipboard.
   ClipBoard.SetText Screen.ActiveControl.SelText
   ' Delete selected text.
   Screen.ActiveControl.SelText = ""
End Sub

Private Sub EditCopy_Click ()
   ' Clear the contents of the Clipboard.
 Clipboard.Clear
   ' Copy selected text to Clipboard.
   ClipBoard.SetText Screen.ActiveControl.SelText
End Sub

Private Sub EditPaste_Click ()
   ' Place text from Clipboard into active control.
   Screen.ActiveControl.SelText = ClipBoard.GetText ()
End Sub

Private Sub EditDelete_Click ()
' Delete selected text.
Screen.ActiveControl.SelText = ""
End Sub

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
James,

Thanks for the code. I haven't used the Screen object very much and wasn't aware of the ActiveControl property. Sure makes things much easier. Thanks again.

Steve
 
Everything works great, with one exception. Any ideas on supporting the edit undo command?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top