473,396 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to prevent flickering when set focus on all controls.

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
Nov 17 '05 #1
6 3810
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
"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
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

Nov 17 '05 #2
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." wrote:
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
"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
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


Nov 17 '05 #3
Excellent!

Regards,
--
Angel J. Hernández M.
MCP - MCAD - MCSD - MCDBA
http://groups.msn.com/desarrolladoresmiranda
http://www.consein.com
"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:83**********************************@microsof t.com...
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." wrote:
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
"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
>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


Nov 17 '05 #4
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
Nov 17 '05 #5
wouldn't the BeginUpdate() and EndUpdate() calls wrapped around your focus
code prevent the screen from repainting?

Robert

"Vern" wrote:
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

Nov 17 '05 #6
wouldn't the BeginUpdate() and EndUpdate() calls wrapped around your focus
code prevent the screen from repainting?

Robert

"Vern" wrote:
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

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Morten Wennevik | last post by:
I'm pretty sure this has been mentioned a few times, but so far I haven't found anything. I am trying to "lock" a program to always focus, non closable etc, but overriding OnDeactivate and...
1
by: Andrew Ducker | last post by:
If I select an item (or row) in my listview and then change to a different control, the selected items stop being coloured blue. Is there any way to get them to keep their colour, so that I can...
1
by: Solx37 | last post by:
I am trying to figure out how to prevent scrolling when I append text. It scrolls to the bottom whenever I use AppendText. It jumps to the top whenever I += text to the Text property.
1
by: H5N1 | last post by:
Hello I'm displaying report on a gridview through object data source which gets some parameters from ddl controls. Using sql profiler I've found out that even when controls are not yet set (by...
1
by: =?Utf-8?B?U3RldmUgUmFuZGFsbA==?= | last post by:
I have a form with a number of panel controls on it. I have overriden the paint event (of the panel controls) to provide custom painting. What I have done is to use the Paint event to paint the...
1
by: Jeff Williams | last post by:
I have a form with several tabs and I want to dynamically change the opacity of it while shown. Is there a way to stop the form updating on screen until all controls have change opacity then allow...
3
by: viral123 | last post by:
Hi all, does any one know how to get the functionality of get focus and lost focus using ASP.Net like VB.Net I want to change the textbox back ground color when it has the focus. I used...
0
by: ag46677 | last post by:
Hi All, I have a web based application and i want to have focus on a text box on click of a button i have been trying the below solution but unfortunately its working in my test application but...
0
by: mike | last post by:
Hi guys, I have a windows form and on load event I dynamically created a panel and dynamically create/add pictureboxes to panel and added a panel to the form with docking with fill. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.