Clipboard object questions... using the clipboard with vb4 
Author Message
 Clipboard object questions... using the clipboard with vb4

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.

Any help on this matter would be greatly appreciated

Ian



Thu, 03 Dec 1998 03:00:00 GMT  
 Clipboard object questions... using the clipboard with vb4

: 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.

: Any help on this matter would be greatly appreciated

: Ian

Here's the way I used for testing something like that:

    Let Flag = (ActiveControl.TabIndex = VScroll1.TabIndex)

Of course, you need not use a Boolean variable, and "VScroll1" would be
replaced by whatever the name of your control is.



Thu, 03 Dec 1998 03:00:00 GMT  
 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




Sat, 05 Dec 1998 03:00:00 GMT  
 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



Cheers.. i'll give it a go.


Sat, 05 Dec 1998 03:00:00 GMT  
 Clipboard object questions... using the clipboard with vb4

You should also be testing the clipboard format using
IsClipboardFormatAvail API Call to see if the clipboard contains text.
This will allow you to accept data from other apps via the clipboard
without compromising your app. Don't forget _never place objects on the
clipboard unless the user selects cut or copy. The user is always in
charge of the clipboard.

Hope this is useful

Regards

Stuart



Mon, 07 Dec 1998 03:00:00 GMT  
 Clipboard object questions... using the clipboard with vb4

Quote:

>You should also be testing the clipboard format using
>IsClipboardFormatAvail API Call to see if the clipboard contains text.

Or you could just use Clipboard.GetFormat

Joe

Never underestimate the power of a WAG.

http://www.citilink.com/~jgarrick



Wed, 09 Dec 1998 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Using Clipboard object in Access 97

2. Access XP: Clearing the clipboard / not saving data to the clipboard

3. Copying DBGrid contents to clipboard (Or copying a table from a Data component to clipboard)

4. Clipboard with VB4.0

5. Clipboard with VB4.0

6. Clipboard/VB4

7. Clipboard in VB4.0 32-bit

8. Clipboard with VB4.0

9. VB4 32 Clipboard and Metafiles

10. VB4 and the Clipboard.

11. Clipboard.Clear - Returns Error 424 - Object Required

12. How to reference the Clipboard object

 

 
Powered by phpBB® Forum Software