How to prevent flickering when set focus on all controls.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a routine that sets focus to all the controls on the form so it can
run the validate event for each of them.
Is there a way to prevent the user from seeing the cursor go through all the
fields?
Thanks,
Vern
 
You should try using the HideCaret and ShowCaret function (API)

Regards,
 
That worked, thanks!

Here's the C# Code I used for this.

using System.Runtime.InteropServices;
public class MyCaret
{

[DllImport("user32.dll")]
public static extern int ShowCaret(IntPtr hwnd);

[DllImport("user32.dll")]
public static extern int HideCaret(IntPtr hwnd);


}

Then in my actual method that needed to hide the caret, I used:
MyCaret.HideCaret(CurrentForm.Handle);
MyCaret.ShowCaret(CurrentForm.Handle);
 
Excellent!

Regards,


--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://www.consein.com


Vern said:
That worked, thanks!

Here's the C# Code I used for this.

using System.Runtime.InteropServices;
public class MyCaret
{

[DllImport("user32.dll")]
public static extern int ShowCaret(IntPtr hwnd);

[DllImport("user32.dll")]
public static extern int HideCaret(IntPtr hwnd);


}

Then in my actual method that needed to hide the caret, I used:
MyCaret.HideCaret(CurrentForm.Handle);
MyCaret.ShowCaret(CurrentForm.Handle);



Angel J. Hernández M. said:
You should try using the HideCaret and ShowCaret function (API)

Regards,


--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://www.consein.com
 
Hi
sorry but i do not quite get the concept of this class.

how do i use it?

I have a button (derived from the usercontrol).
i use it 12 times on a form. On each of this buttons i place images for
various mouse events
i.e hover, leave, up, down, click. (so images change with each event). This
is causing quite a bit of flickers. so i used the code like this

private void btn_MouseLeave(object sender, EventArgs e)

{

Carets.HideCaret(this.Handle);

WACButton btn = (WACButton)sender;

btn.ImageIndex = 0;

Carets.ShowCaret(this.Handle);

}

private void btn_MouseEnter(object sender, EventArgs e)

{

Carets.HideCaret(this.Handle);

WACButton btn = (WACButton)sender;

btn.ImageIndex = 0;

Carets.ShowCaret(this.Handle);

}






is this the right way to use?

please give an example

thanks

raj
 
Back
Top