
Clipboard object questions... using the clipboard with vb4
Quote:
Gregson) writes:
>I would like to know if it possible to disbale/enable the clipboard
depending
>if the user is in a specific text box and also if the clipboard contains
only
>text.
>I have written an application and I am now trying to implement
cut/paste/copy
>into the app.
>The application I have written sends messages, it has two text boxes. 1
is
>MESSAGE text box and the other is TO text box
>If the clipboard contains text only then a user can clicks on EDIT menu
(in
>my
>app) and then he would see the PASTE sub menu enabled as long as the rule
>below is also followed
>If the users current focus is set to the message box paste can be enabled
but
>if the users current focus (active control) is set to the to box then
paste
>must be disbaled
>If any of these rules were broken then the paste would be disabled i.e.
>enabled property set to FALSE
>I beleive you can something like "ACTIVECONTROL" to find out if the
MESSAGE
>text box has focus.... but can't seem to get it to work.
I would put this code in your Form_Load function:
mnuEditPaste.Enabled = False ' Assuming no text in MESSAGE at startup
mnuEditCopy.Enabled = False
Then in MESSAGE_Change function add this:
If MESSAGE.Text <> "" then
mnuEditCopy.Enabled = True
Else
mnuEditCopy.Enabled = False
End If
Your code for the mnuEditCopy option would look something like this:
Sub mnuCopy_Click()
If MESSAGE.SelText <> "" then ' Copy only selected text
Clipboard.SetText MESSAGE.SelText
Else
Clipboard.SetText MESSAGE.Text ' Copy all text
End If
mnuEditPaste.Enabled = True
End Sub
Your code for the mnuEditPaste option would look something like this:
Sub mnuEditPaste_Click()
' If the user hasn't selected any text, this acts as an insertion
method.
' Otherwise, it replaces the selected text.
TO.SelText = Clipboard.GetText()
End Sub