Click here to Skip to main content
16,006,845 members
Home / Discussions / C#
   

C#

 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 18:09
protectorChristian Graus20-Jul-05 18:09 
AnswerRe: VB6 (eek!) to VB.net to C#????? Pin
Dave Doknjas20-Jul-05 16:13
Dave Doknjas20-Jul-05 16:13 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus20-Jul-05 17:41
protectorChristian Graus20-Jul-05 17:41 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Dave Doknjas20-Jul-05 19:24
Dave Doknjas20-Jul-05 19:24 
GeneralRe: VB6 (eek!) to VB.net to C#????? Pin
Christian Graus21-Jul-05 13:20
protectorChristian Graus21-Jul-05 13:20 
GeneralPrinting window form Pin
quangmogulasia20-Jul-05 12:57
quangmogulasia20-Jul-05 12:57 
GeneralFocus Pin
nc3b20-Jul-05 12:39
nc3b20-Jul-05 12:39 
GeneralRe: Focus Pin
Mark Greenwood20-Jul-05 18:07
Mark Greenwood20-Jul-05 18:07 
Ok in your app import the User32.dll function RegisterHotKey

[DllImport("user32.dll", SetLastError=true)]<br />
		public static extern bool RegisterHotKey( IntPtr hWnd, // handle to window    <br />
			int id, // hot key identifier    <br />
			KeyModifiers fsModifiers,  // key-modifier options    <br />
			Keys vk // virtual-key code    <br />
			);


Whilst Your at it - may as well import the Unregister one too

[DllImport("user32.dll", SetLastError=true)]<br />
		public static extern bool UnregisterHotKey( IntPtr hWnd, // handle to window    <br />
			int id // hot key identifier    <br />
			);


In your MainForm constructor - register the hot key

RegisterHotKey(Handle, 100, KeyModifiers.Control | KeyModifiers.Shift, Keys.L);

In this case it's ctrl, shift and L - anything you want really.

Then override the WndProc for the main form and handle the event

protected override void WndProc(ref Message m)<br />
		{<br />
			// Const for the WM_HOTKEY message<br />
			const int WM_HOTKEY = 0x0312;<br />
<br />
			// Switch on the message<br />
			switch(m.Msg)<br />
			{<br />
				case WM_HOTKEY:<br />
				{<br />
					// Process the hot key press here<br />
					break;<br />
				}<br />
			}<br />
<br />
			// Pass message onto base<br />
			base.WndProc (ref m);<br />
		}


Remember to also unregister the hot key in the Form.OnClosed method

private void Form1_Closed(object sender, System.EventArgs e)<br />
		{									<br />
			// Unregister the hot key<br />
			UnregisterHotKey(Handle, 100);<br />
		}



That should do what you want.

Mark. Smile | :)
GeneralRe: Focus Pin
nc3b21-Jul-05 0:01
nc3b21-Jul-05 0:01 
GeneralRe: Focus Pin
nc3b21-Jul-05 1:15
nc3b21-Jul-05 1:15 
GeneralRe: Focus Pin
[Marc]21-Jul-05 16:10
[Marc]21-Jul-05 16:10 
GeneralRe: Focus Pin
nc3b21-Jul-05 21:21
nc3b21-Jul-05 21:21 
GeneralRe: Focus Pin
[Marc]22-Jul-05 9:29
[Marc]22-Jul-05 9:29 
QuestionHow can i find the DataRow number in DataRowCollection Pin
m.rastgar20-Jul-05 12:30
m.rastgar20-Jul-05 12:30 
GeneralTransparent Overlapping Panels Problem... Pin
rcurrie20-Jul-05 12:25
rcurrie20-Jul-05 12:25 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]20-Jul-05 16:12
[Marc]20-Jul-05 16:12 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie21-Jul-05 6:35
rcurrie21-Jul-05 6:35 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie21-Jul-05 12:46
rcurrie21-Jul-05 12:46 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]21-Jul-05 15:56
[Marc]21-Jul-05 15:56 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie22-Jul-05 7:29
rcurrie22-Jul-05 7:29 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]22-Jul-05 9:00
[Marc]22-Jul-05 9:00 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie22-Jul-05 9:06
rcurrie22-Jul-05 9:06 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]22-Jul-05 9:28
[Marc]22-Jul-05 9:28 
GeneralRe: Transparent Overlapping Panels Problem... Pin
rcurrie25-Jul-05 14:02
rcurrie25-Jul-05 14:02 
GeneralRe: Transparent Overlapping Panels Problem... Pin
[Marc]26-Jul-05 7:55
[Marc]26-Jul-05 7:55 

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.