Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

The problem I'm having is this.

 

I'm developing a control panel interface for a piece of machinery. I need a momentary contact button on the interface, which sends and reads addresses from an industrial PLC. When using just the MouseDown and MouseUp events, if a user just "pokes" the button, the MouseUp event doesn't communicate with the PLC in time. If I start a timer in the MouseDown event to prevent it, then the button hangs if pushed, held, quickly released and hit again.

 

I know, what are the chances that someone's going to do that - but this is a control for an industrial grinder - and I can't take the chance.

 

What I need is some sort of event that checks if the mouse is down, and if so, do an instruction - and if not, stop that instruction.

 

Would there be a way to call on the MouseDown event as a RaiseEvent to check for it's condition inside of a "while" loop? "I hope that didn't sound as silly as it did to me when I wrote it.)

  • *Experts*
Posted

If I understand you correctly, you could set a form level flag such as bMouseIsDown in the MouseDown/MouseUp events. In the MouseDown (of a button, a label or whatever you want) set the flag to true and call some function that loops and does what's needed. Make sure the loop has a call to Application.DoEvents so that you can pick up the window events. You can exit the loop when the variable is false. Is that what you were looking for?

 

-Ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

That sounds about right -

 

Literally what I need to do is set bit in the PLC to true when the mouse is down, but only when the mouse is down - otherwise the bit is set to false. What I have tried is to set the bit in a MouseDown event, and reset the bit in the MouseUp event - but the communication lag (or something?) keeps the MouseUp event from reaching the PLC.

 

BTW - dunno if this makes any difference, but this is a touch screen (so MouseEnter/Hover events wouldn't really work either)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...