Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 3 Monaten
Letzter Beitrag:
vor 1 Jahr, 3 Monaten
Beteiligte Autoren:
Stefan Bentvelsen, Arie, Paulo Oliveira, Christoph Erdmann, Harry W

[WD20] Ignore mouse clicks on a button

Startbeitrag von Stefan Bentvelsen am 30.01.2017 14:56

Hi all,

to prevent multiple execution of code of buttons, I made the state grayed after a mouse click, but the mouse clicks after the first one (on the same button) are still executed when the button state become active again. So how can I ignore mouse clicks on a button with a state that is grayed?


Hallo Stefan,

I have tested this and it works as expected. If the button state become aktive, no previous MouseClick comes up. Maybe a timer or executeprocess() in your code ?


von Christoph Erdmann - am 30.01.2017 15:25
To prevent this i always use one invisible control and in the click of the button i check if the content is empty, if so i put 1 in the content at the begginig of the code of the button and empty the content at the end of the code.

von Paulo Oliveira - am 30.01.2017 16:06
Hi Christoph,

I have to disagree with you, if the button become active again, the button executes again for each time the button was clicked. I've checked it with a Trace().

von Stefan Bentvelsen - am 30.01.2017 19:30
Hi Paulo,

can you explain this a bit more? I don't understand what you mean.

von Stefan Bentvelsen - am 30.01.2017 19:32

could it be a Wait or Multitask statement in the code which is executed by pressing that button?
I had the same thing once in a WM app. There I use a global boolean to indicate the button was clicked and use that boolean in the clicked code to test if the code is still running. And than of course cancel the 2nd click.
I can't remember exactly but maybe the mouse-up event will act better in this case.

von Arie - am 31.01.2017 07:25
Hi Arie,

the question now is how to cancel the 2nd,, 3rd, etc. mouseclick when the buttoncode is running.

von Stefan Bentvelsen - am 31.01.2017 09:24
btn_run is one hiden control of the page

// click code of the button

if btn_run"" then

von Paulo Oliveira - am 31.01.2017 09:30
Okay, you mean the 2nd mouseclick comes AFTER your complete code has finished?
I thought the 2nd click came DURING your code being executed.

Then I have no answer at the moment I'm afraid.

von Arie - am 31.01.2017 09:50
Hi Paulo,

thanks voor your effort, but it doesn't work.
The mouse clicks are buffered in some way.

In fact, I want to empty the mouse-(clicks)buffer on the moment the end of the button code is reached.

von Stefan Bentvelsen - am 31.01.2017 09:56
Hi Arie,

thanks for your response but no, I mean that the user (who is a bit unpatient) clicks more than ones on a button while the buttoncode is running.

The mouse clicks seems to be buffered. So I only have to empty the mouse(click) buffer, but how can I do that?

von Stefan Bentvelsen - am 31.01.2017 10:00
Not nice but ....

Window Code
wt_ClickTime is Time

Click button code

When user clicks again.
if wt_ClickTime'' then
if not yesno(No,"You want it again ?","Previous report was "+wdt_ClickTime)

von Harry W - am 31.01.2017 13:48
Hi Harry,

thanks for your response, but I cannot use interaction with the user in this case.

von Stefan Bentvelsen - am 31.01.2017 15:00
Hallo Stefan,

write in the first line of button click code :

Button..State is grayed

if all is finish give the button active again.

Christoph (hope I understand your problem correct - my english is not the best)

von Christoph Erdmann - am 31.01.2017 15:26

Re: [WD20] Ignore mouse clicks on a button (SOLVED)

Hi all,

together with a colleague, we found the following solution that seems to work properly:
Thanks to all of you for your contributions.

In Init-of-window code (define a global boolean):

gbBtnProcessBezig is boolean

In click-code-of-button:
MyButton..state = grayed
// Do your thing
MyButton..state = active

In left-button-up-event-code-of-button:

liResult is system int

IF gbBtnProcessBezig THEN
liResult = API("user32.dll","PeekMessageA",Null,Handle(Frm_PlattegrondTabel..Name),WM_MOUSEFIRST,WM_MOUSELAST,1)

von Stefan Bentvelsen - am 31.01.2017 16:06
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.