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
EricL said:
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.