Click here to Skip to main content
15,909,440 members
Home / Discussions / C#
   

C#

 
AnswerRe: Center Text on Custom Button Pin
Ian Shlasko22-May-07 10:34
Ian Shlasko22-May-07 10:34 
GeneralRe: Center Text on Custom Button Pin
PHDENG8123-May-07 0:45
PHDENG8123-May-07 0:45 
GeneralRe: Center Text on Custom Button Pin
Ian Shlasko24-May-07 3:40
Ian Shlasko24-May-07 3:40 
GeneralRe: Center Text on Custom Button Pin
PHDENG8124-May-07 4:38
PHDENG8124-May-07 4:38 
QuestionDisabling controls without changing appearance Pin
Ian Shlasko22-May-07 6:13
Ian Shlasko22-May-07 6:13 
AnswerRe: Disabling controls without changing appearance Pin
Dave Herren22-May-07 6:33
Dave Herren22-May-07 6:33 
GeneralRe: Disabling controls without changing appearance Pin
Ian Shlasko22-May-07 7:42
Ian Shlasko22-May-07 7:42 
GeneralRe: Disabling controls without changing appearance (Solved!) Pin
Ian Shlasko22-May-07 10:05
Ian Shlasko22-May-07 10:05 
Bingo. Switching controls would have been too intrusive to the design, but you gave me the winning idea. It's a little odd, but it works like a charm...

First, the lock routine goes through the control tree of the form, and finds the highest-level controls possible without including the exceptions, and locks those only. Fun little algorithm, but not the point, so onward...

I knew I couldn't override the WndProc, and totally eat mouse messages, without subclassing, right? Well, that doesn't stop me from adding an extra container.
Form
|
|-Panel1
   \-Something
\-Panel2
   |-Something
   \-CancelButton

Becomes...
Form
|
|-LockPanel
|  \-Panel1
|     \-Something
\-Panel2
   |-LockPanel
   |  \-Something
   \-CancelButton

The LockPanel instances are empty panels that basically swallow the member control. They set their location/size/dock to the control, set their backcolor to the parent, insert themselves in place of the control, and Dock.Fill the control into themselves. Basically, it adds a controllable layer without affecting the form's logic.

Why, though?

protected override void WndProc(ref Message m)
{
    /*
     * When we receive a mouse activation, deny it.
     * This prevents any child controls from being clicked.
     */
    // WM_MOUSEACTIVATE
    if (m.Msg == 0x0021)
        m.Result = new IntPtr(4); // MA_NOACTIVATEANDEAT
    else
        base.WndProc(ref m);
}


This, along with a KeyDown hook that sets Handled and SuppressKeyPress to true, makes the controls react to hover-type events (They light up, highlight borders, etc), but not to clicks of any sort. As for the keyboard, you can <tab> into them, but can't actually affect the contents.
GeneralRe: Disabling controls without changing appearance (Solved!) Pin
Martin#22-May-07 21:43
Martin#22-May-07 21:43 
GeneralRe: Disabling controls without changing appearance (Solved!) Pin
Ian Shlasko23-May-07 6:13
Ian Shlasko23-May-07 6:13 
GeneralRe: Disabling controls without changing appearance (Solved!) Pin
Martin#23-May-07 7:04
Martin#23-May-07 7:04 
AnswerRe: Disabling controls without changing appearance Pin
Dave Herren22-May-07 6:38
Dave Herren22-May-07 6:38 
AnswerRe: Disabling controls without changing appearance Pin
Dan Neely22-May-07 7:20
Dan Neely22-May-07 7:20 
Questionrun .exe from command prompt in c#...help please Pin
lavy288322-May-07 5:22
lavy288322-May-07 5:22 
AnswerRe: run .exe from command prompt in c#...help please Pin
Bekjong22-May-07 5:44
Bekjong22-May-07 5:44 
AnswerRe: run .exe from command prompt in c#...help please Pin
Mike DiRenzo22-May-07 9:16
Mike DiRenzo22-May-07 9:16 
AnswerRe: run .exe from command prompt in c#...help please Pin
Nouman Bhatti23-May-07 0:49
Nouman Bhatti23-May-07 0:49 
AnswerRe: run .exe from command prompt in c#...help please Pin
Hamid_RT23-May-07 2:18
Hamid_RT23-May-07 2:18 
QuestionHow to acess Website from windows Forms Pin
Rahul8322-May-07 4:57
Rahul8322-May-07 4:57 
AnswerRe: How to acess Website from windows Forms [modified*2] Pin
Tarakeshwar Reddy22-May-07 5:02
professionalTarakeshwar Reddy22-May-07 5:02 
GeneralRe: How to acess Website from windows Forms Pin
Rahul8322-May-07 5:07
Rahul8322-May-07 5:07 
GeneralRe: How to acess Website from windows Forms Pin
Manoj Kumar Rai22-May-07 5:46
professionalManoj Kumar Rai22-May-07 5:46 
GeneralRe: How to acess Website from windows Forms Pin
Tarakeshwar Reddy22-May-07 5:57
professionalTarakeshwar Reddy22-May-07 5:57 
QuestionSolution Explorer Icons (VS2005) Pin
Copper2622-May-07 3:02
Copper2622-May-07 3:02 
AnswerRe: Solution Explorer Icons (VS2005) Pin
girm22-May-07 3:34
girm22-May-07 3:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.