Click here to Skip to main content
15,907,281 members
Home / Discussions / C#
   

C#

 
QuestionDbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 3:25
professionalNathan Minier24-Jun-14 3:25 
AnswerRe: DbContext recreate with cache clear Pin
Dave Kreskowiak24-Jun-14 5:04
mveDave Kreskowiak24-Jun-14 5:04 
GeneralRe: DbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 5:52
professionalNathan Minier24-Jun-14 5:52 
GeneralRe: DbContext recreate with cache clear Pin
Dave Kreskowiak24-Jun-14 6:00
mveDave Kreskowiak24-Jun-14 6:00 
GeneralRe: DbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 6:22
professionalNathan Minier24-Jun-14 6:22 
GeneralRe: DbContext recreate with cache clear Pin
Dave Kreskowiak24-Jun-14 6:54
mveDave Kreskowiak24-Jun-14 6:54 
GeneralRe: DbContext recreate with cache clear Pin
Nathan Minier24-Jun-14 9:49
professionalNathan Minier24-Jun-14 9:49 
QuestionProgramming Visio streams on a local computer and hosted on a remote server using c# Pin
orélle23-Jun-14 22:25
orélle23-Jun-14 22:25 
AnswerRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Kornfeld Eliyahu Peter23-Jun-14 22:38
professionalKornfeld Eliyahu Peter23-Jun-14 22:38 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
orélle23-Jun-14 23:20
orélle23-Jun-14 23:20 
AnswerRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Kornfeld Eliyahu Peter23-Jun-14 23:23
professionalKornfeld Eliyahu Peter23-Jun-14 23:23 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
orélle24-Jun-14 1:03
orélle24-Jun-14 1:03 
AnswerRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Kornfeld Eliyahu Peter24-Jun-14 1:21
professionalKornfeld Eliyahu Peter24-Jun-14 1:21 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
orélle24-Jun-14 2:20
orélle24-Jun-14 2:20 
AnswerRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Kornfeld Eliyahu Peter24-Jun-14 2:29
professionalKornfeld Eliyahu Peter24-Jun-14 2:29 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Dave Kreskowiak24-Jun-14 1:39
mveDave Kreskowiak24-Jun-14 1:39 
SuggestionRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Richard Deeming24-Jun-14 0:38
mveRichard Deeming24-Jun-14 0:38 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
OriginalGriff24-Jun-14 1:06
mveOriginalGriff24-Jun-14 1:06 
GeneralRe: Programming Visio streams on a local computer and hosted on a remote server using c# Pin
Mycroft Holmes25-Jun-14 0:39
professionalMycroft Holmes25-Jun-14 0:39 
QuestionHow to convert a text file in unicode format to excel file Pin
botngot8323-Jun-14 20:54
botngot8323-Jun-14 20:54 
SuggestionRe: How to convert a text file in unicode format to excel file Pin
Nathan Minier24-Jun-14 3:12
professionalNathan Minier24-Jun-14 3:12 
QuestionConnect to MySQL using MySQL Connector.NET and SharpSsh Pin
Jassim Rahma23-Jun-14 20:24
Jassim Rahma23-Jun-14 20:24 
QuestionSetting A Global Hot Key On A Second Form Pin
rfresh23-Jun-14 18:55
rfresh23-Jun-14 18:55 
I created a WinForm app in C# using VS 2013 Express.

I added code to create a Global Hot Key on the main form. This works fine. My hot key is Ctrl-T. I can press the hot key and make the main form show and hide.

Then I created a second form (ChecklistForm) and now I want to press ctrl-T and make that form show and hide. I do not need the main form to do this any more. I just used the main form to test my Global Hot Key code.

So I'm having trouble getting the second form to respond to the hot key. When I put a break on the WndProc(), there is no break.

Thanks for any help.

re lang="c#">
public partial class MainForm : Form
{
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String sClassName, String AppName);

private IntPtr thisWindow;
private GlobalHotKeys hotkey;

public MainForm()
{
InitializeComponent();
}

private void MainForm_Load(object sender, EventArgs e)
{
ChecklistForm frm = new ChecklistForm();
frm.Show();
thisWindow = FindWindow(null, "ChecklistForm");
//thisWindow = FindWindow(null, "MainForm");
hotkey = new GlobalHotKeys(thisWindow);
hotkey.RegisterHotKeys();
}

private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
thisWindow = FindWindow(null, "ChecklistForm");
//thisWindow = FindWindow(null, "MainForm");
hotkey = new GlobalHotKeys(thisWindow);
hotkey.UnRegisterHotKeys();
}

protected override void WndProc(ref Message keyPressed)
{
if (keyPressed.Msg == 0x0312)
{
thisWindow = FindWindow(null, "ChecklistForm");
//thisWindow = FindWindow(null, "MainForm");
IntPtr i = keyPressed.WParam; // not being used
ShowChecklist ShowChkList = new ShowChecklist(thisWindow);
ShowChkList.execute();
}
base.WndProc(ref keyPressed);
}
}



class GlobalHotKeys // CLASS FILE *********************
{
public enum fsModifiers
{
Alt = 0x0001,
Control = 0x0002,
Shift = 0x0004,
Window = 0x0008
}

private IntPtr _hWnd;

public GlobalHotKeys(IntPtr hWnd)
{
this._hWnd = hWnd;
}
public void RegisterHotKeys()
{
RegisterHotKey(_hWnd, 1, (uint)fsModifiers.Control, (uint)Keys.T);
}

public void UnRegisterHotKeys()
{
UnregisterHotKey(_hWnd, 1);
}

#region WindowsAPI
[DllImport("user32.dll")]
public static extern IntPtr RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);

[DllImport("user32.dll")]
public static extern IntPtr UnregisterHotKey(IntPtr hWnd, int id);
#endregion

}




class ShowChecklist // CLASS FILE *********************
{
public enum nCmdShow
{
NORMAL = 1,
MIN = 2,
MAX = 3
}

private IntPtr _hWnd;

public ShowChecklist(IntPtr hWnd)
{
_hWnd = hWnd;
}

public void execute()
{
ShowWindowAsync(_hWnd, (int)nCmdShow.NORMAL);
}

#region WindowsAPI
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
#endregion
}



AnswerRe: Setting A Global Hot Key On A Second Form Pin
Eddy Vluggen24-Jun-14 0:34
professionalEddy Vluggen24-Jun-14 0:34 
GeneralRe: Setting A Global Hot Key On A Second Form Pin
rfresh24-Jun-14 3:21
rfresh24-Jun-14 3:21 

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.