Eric,
You could use interoperablity services to get at some features available in
the user32.dll. Look at the following code for some ideas. The public
methods below allow you to control the appearance of focus effects on
controls.
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using namespace DllImports
{
public class User32DllImports
{
public User32DllImports()
{}
protected const int WM_CHANGEUISTATE = 0x00000127;
protected const int UIS_SET = 1;
protected const int UIS_CLEAR = 2;
protected const short UISF_HIDEFOCUS = 0x0001;
protected const short UISF_HIDEACCEL = 0x0002;
protected const short UISF_ACTIVE = 0x0004;
[DllImport( "user32.dll" )]
public extern static int SendMessage( IntPtr hWnd, int wMsg, int
wParam, int lParam );
public static void MakeAcceleratorsVisible( Control c )
{
SendMessage( c.Handle, WM_CHANGEUISTATE, MAKELONG(UIS_CLEAR,
UISF_HIDEACCEL), 0 );
}
public static void MakeAcceleratorsInvisible( Control c )
{
SendMessage( c.Handle, WM_CHANGEUISTATE, MAKELONG(UIS_SET,
UISF_HIDEACCEL), 0 );
}
public static void MakeFocusVisible( Control c )
{
SendMessage( c.Handle, WM_CHANGEUISTATE, MAKELONG(UIS_CLEAR,
UISF_HIDEFOCUS), 0 );
}
public static void MakeFocusInvisible( Control c )
{
SendMessage( c.Handle, WM_CHANGEUISTATE, MAKELONG(UIS_SET,
UISF_HIDEFOCUS), 0 );
}
public static void MakeActiveVisible( Control c )
{
SendMessage( c.Handle, WM_CHANGEUISTATE, MAKELONG(UIS_SET,
UISF_ACTIVE), 0 );
}
public static void MakeActiveInvisible( Control c )
{
SendMessage( c.Handle, WM_CHANGEUISTATE, MAKELONG(UIS_CLEAR,
UISF_ACTIVE), 0 );
}
private static short LOWORD( int dw )
{
short loWord = 0;
ushort andResult = (ushort)(dw & 0x00007FFF);
ushort mask = 0x8000;
if ( (dw & 0x8000) != 0 )
{
loWord = (short)( mask | andResult );
}
else
{
loWord = (short)andResult;
}
return loWord;
}
private static int MAKELONG( int wLow, int wHigh )
{
int low = (int)LOWORD( wLow );
short high = LOWORD( wHigh );
int product = 0x00010000 * (int)high;
int makeLong = (int)( low | product );
return makeLong;
}
}
}
Hope that helps,
Dave
[quoted text, click to view] "EricL" wrote:
> Yes, thank you. I had tried that.
>
> But that's not enough.
>
> I'd also like to avoid seeing the small dots signifying focus, appear on the
> button when I click on it.
>
> Is that possible?
>
> Thanks.
>
> "Norman Yuan" <NotReal@NotReal.not> wrote in message
> news:%23rHofyJGGHA.1124@TK2MSFTNGP10.phx.gbl...
> > You simply need to set TabIndex and/or TabStop property of a control (in
> > Properties Window, or menu "View->Tab Order").
> >
> > "EricL" <eric@lescasse.com> wrote in message
> > news:43c83012$0$27867$afc38c87@news.easynet.fr...
> >> C# question:
> >>
> >> Is there a way to prevent a button from getting the focus and from being
> >> painted with a rectangle of small dots when clicking on it?
> >>
> >> Specifically, I have a form with 2 TextBox and a Button: say I am in the
> >> first TextBox and the Button is the next control in the form.
> >>
> >> What do I have to do so that tabbing out of the first TextBox skips the
> >> Button over and sets focus to the second Textbox?
> >>
> >> Thanks for help.
> >>
> >> Eric
> >>
> >
> >
>
>