how to enable/disable paste

  • Thread starter Stilgar[bbs.isca.uiowa.edu]
  • Start date
S

Stilgar[bbs.isca.uiowa.edu]

Here's my newbie question:

I have several VB forms which are all inherit a standard template form
that I made. In my template form, I added a menu bar with some
generic cut, copy, and paste functionality.

I'd like to have the paste button disabled when the clipboard is
empty, but I'm not sure how I should do this. Ideally, I suppose I'd
like to constantly monitor the clipboard for data, (in a thread?) but
I'm not even sure how I'd monitor the clipboard.

while (1==1)
if clipboard != mt
enable paste
else
disable paste

Or maybe there there's an event that I could monitor?

on Event
if clipboard != mt
enable paste
else
disable paste

What's the best way to tackle this?

TIA
 
D

Dominique Vandensteen

well i think there must be an event somewhere but I don't know where...

the while(1=1) is a bad idea, will use too much cpu...
something you can also use is listen on the popup event of the menuitem to
dis/enable your menuitem...

hope this helps

dominique
 
S

Stilgar[bbs.isca.uiowa.edu]

I can't listen for the pop-up event because I'm also using the
standard cut, copy, paste shortcut keys (ctrl-x, ctrl-c, ctrl-v),
unless using the shortcut keys activates the menu event too??? I
guess I'll have to try that.

You're right about using "while(1==1)" using a lot of CPU, that's why
I'd make my application multithreaded and use VB's equivalent of
wait() or sleep().
 
D

Dominique Vandensteen

I don't see the problem with the shortcut keys. I suppose you listen for the
keyevent for that.
When you receive the keyevent just check the clipboard like you do in the
popup event.
If the clipboard is empty (for ctrl-v) just return...

Dominique
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top