how to redraw controls ?

I made a method that “shakes” bevel buttons when the user clicks on them.
This is for giving a visual clue that he shoudnt have selected that answer.
Basically the button moves a few pixels out of his original position and goes back with a quick interval using wend and ticks “trick” tha most of you know.
The problem is that the bevel button shrinks during the shaking and the borders disappear

Is there any way to redraw the control to prevent this ?

thanks

Any idea how can I redraw controls to prevent these problems ?

Post your code.

For WINDOWS:

Method Shakebev(i as integer)
My intentio is to shake the bevel button in order to give a visual clue for the user, the problem is that the control is not redrawn
in the for-nect cycle, instead it gets smaller and disappears.
Is there any workaround for this ? Thanks

   'win is the main window
  'bev is a bevel button control
  'parameter i is the index of bevel button control set
  
  dim x,y,k as integer
  dim sleep as integer
  
  x=win.bev(i).left'memorize the initial positions of bevel 
  y=win.bev(i).top
  
  for k=0 to 10
    win.bev(i).left=x+randomizer.InRange(-20,20)' randomizer is a global variable of random type
    win.bev(i).top=y+randomizer.InRange(-20,20)
    
    sleep=ticks+5
    While ticks < sleep 'pause
    Wend
    
    win.bev(i).left=x 'restore initial positions
    win.bev(i).top=y
  next
  

I would recommend to disable the control, if one should not click on it.

Anyway that’s what I use for a dialog, where the user enters a wrong password:

Sub Quiver(Extends win As Window) win.Left = win.Left - 5 win.Refresh() win.Left = win.Left + 10 win.Refresh() win.Left = win.Left - 10 win.Refresh() win.Left = win.Left + 10 win.Refresh() win.Left = win.Left - 5 End Sub

I added bev(i).REFRESH into my method and now it looks a lot better, but still not perfect bc the borders disappear but at least is much better than without “refresh”

Redraw the changed area?

But I agree with Eli, if you shouldn’t be able to click on a control then that control should be disabled.

Otherwise you lie to the user by saying “you can click here”, and the shaking is the equivalent of a Nelson “HaHa!”

I’m working on a sort of game, so going Nelson is right for me in this case, otherwise I would have just made the control unselectable

The problem is the while/wend. It prevents normal drawing. Put your “shake” code in a timer. But don’t loop. Do one move each time the timer fires. That will allow the screen to redraw normally.

I found the solution.
refresh command needs to be put INSIDE the loop, problem solved

Peace out