User control and resizes

  • Thread starter Thread starter Rodrigo Ferreira
  • Start date Start date
R

Rodrigo Ferreira

I have an user control and inside him i have one label and 1 textbox!

My problem is:

When i'am in design mode (a new project with this user control), i want to:

- If i resize the user control with the left ctrl key down the size of the
label increses/decrease.
- If i resize the control with the right ctrl key down the size og the
textbox change!

Any ideias to do that?
 
Rodrigo,

In your event handler for the resize event, you will have to call the
GetKeyState API function through the P/Invoke layer, in order to determine
the state of the VK_LCONTROL and VK_RCONTROL keys (which correspond to the
left and right control keys).

You can find the declaration for GetKeyState in winuser.h, or possibly
on http://www.pinvoke.net, as well as the values for the constants.

Hope this helps.
 
It works!

But this code also works fine:
System.Windows.Forms.Control.ModifierKeys == Keys.Alt)

Nicholas Paldino said:
Rodrigo,

In your event handler for the resize event, you will have to call the
GetKeyState API function through the P/Invoke layer, in order to determine
the state of the VK_LCONTROL and VK_RCONTROL keys (which correspond to the
left and right control keys).

You can find the declaration for GetKeyState in winuser.h, or possibly
on http://www.pinvoke.net, as well as the values for the constants.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Rodrigo Ferreira said:
I have an user control and inside him i have one label and 1 textbox!

My problem is:

When i'am in design mode (a new project with this user control), i want
to:

- If i resize the user control with the left ctrl key down the size of
the label increses/decrease.
- If i resize the control with the right ctrl key down the size og the
textbox change!

Any ideias to do that?
 
Back
Top