|
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
}
|
|
|
|
|
You should not need set a hotkey for each form anew; if the hotkey is used to open your app quickly, then I'd recommend setting a global hotkey. Easiest way is to assign a shortcut to the app[^] to start it, check if it is running, and if yes, bring the other instance to the front.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I don't want a global hot key to START my forms. I stated: "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."
I want to show and hide my second form with a global hot key and my code above isn't working to do that.
Thank you...
|
|
|
|
|
rfresh wrote: <layer>I don't want a global hot key to START my forms. I know; you want to show "a" form from your project when the user presses a specific key.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello everyone
In my WPF project I have created a UserControl (this is called Applic.xaml), and within this usercontrol I have placed another UserControl (this is called PasswordScreen.xaml). Here is the xaml design code:
<UserControl xmlns:my2="clr-namespace:iPosCloud.com.iposcloud.uiC_.views"
x:Class="iPosCloud.com.iposcloud.main.Applic"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my0="clr-namespace:iPosCloud.com.iposcloud.main"
xmlns:Intersoft="http://intersoft.clientui.com/schemas"
xmlns:my1="clr-namespace:Intersoft.Client.UI.Controls;assembly=Intersoft.Client.UI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="1024" xmlns:my="http://schemas.microsoft.com/surface/2008">
<UserControl.Background>
<ImageBrush ImageSource="/iPosCloud;component/images/HoneyComb.png" Stretch="Fill" TileMode="Tile" Viewport="0,0,46,25" ViewportUnits="Absolute" />
</UserControl.Background>
<UserControl.Resources>
<DropShadowEffect x:Key="DropShadowEffect" ShadowDepth="0.1" Direction="360" BlurRadius="3" Opacity=".5" />
</UserControl.Resources>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="MainGridApplic">
<Border BorderThickness="2" HorizontalAlignment="Left" Name="border1" VerticalAlignment="Stretch" Margin="4" BorderBrush="{x:Null}">
<Border.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="360" ShadowDepth="10" Opacity=".5" Softness="9" />
</Border.BitmapEffect>
<Intersoft:UXGridPanel Margin="2" Column="1" Row="1" ItemHeight="220" ItemWidth="1190" Name="UXGridPanelLeft">
<Image Name="image1" Source="/iPosCloud;component/images/Logo.png" Width="1000" HorizontalAlignment="Left" />
</Intersoft:UXGridPanel>
</Border>
<Grid Margin="2" HorizontalAlignment="Right">
<my2:PasswordScreen /> "HERE IS THE UserControl THAT I PLACED..."
</Grid>
</Grid>
</UserControl>
In PasswordScreen.xaml there is a button (called Login). On click event when clicked I want to call another xmal file called SwitchboardView.xaml but not firing nothing and the code behind this button is:
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
SwitchboardView sbv = new SwitchboardView();
Applic ap = new Applic();
ap.MainGridApplic.Children.Add(sbv);
}
Could someone please help me solve this problem (what am I doing wrong...)
Kind regards
Lapeci
|
|
|
|
|
|
Hi, I have more than one applications. Have to install using single installer. Using Inno or WIX.
Ex:App1 App2 App2 into single installer AllSetup. Please help me.
|
|
|
|
|
|
Thanks Maciej Los, I am trying to do with these.
|
|
|
|
|
In control panel i am able to see only one application and desktop shortcut is also only one, can you please resolve this issues.
|
|
|
|
|
Hi,
I developed an application in C# vs2010, and I need to install it to client System
1stly I installed the dot net framework4.0 on the System and then the application
but it showing an error unable to find a version of the runtime
|
|
|
|
|
Check your app: look at the version of the .NET framework it is targeting.
VS2010 supports up to V4.0, but MSDN does say:
"However, the .NET Framework 4 ends this layering approach, so apps built for 2.0. 3.0, or 3.5 will not work on version 4 or later."
http://msdn.microsoft.com/en-us/library/bb822049(v=vs.110).aspx[^]
So if your app is targeting V3.5 or below, then installing V4.0 of .NET will not allow it to run. Either change the target of you app and rebuild, or install .NET V3.5
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Hi guys am new to visual studio and c# programming stuff, tho have a good background knowledge of C and C++..
how do I go about having my entire source code in c # pasted to the visual studio , to run it from there??.I have a complete source code
|
|
|
|
|
If you have the complete source, then you probably want to open the .SLN file - it's a Visual Studio solution which should load the whole source correctly into Visual Studio ready for you to inspect / compile / run as you need.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
You can not convert C/C++ code to C# without effort even your original C/C++ code was under the .NET framework. You will have to actually rewrite a part of your code...
If it was a Win32 API application you have even more work to do...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I don't really understand. You said you have a good background knowledge of C and C++.
Does it mean you have knowledge or do you really have good experience and knows all the in and outs?
However, there is no way(as far as I know) of converting the C or C++ to C#. further if you are new to C# and Visual studio I recommend, to Spend few days in understanding the technology and learn the C#.
|
|
|
|
|
*.cs files open in Visual Studio if you mean you already have C# code. Else you'll have quite some fun rewriting everything. Although similar in syntax C/C++ are quite different than C#. If your C/C++ code also uses libraries it's even worse.
If the code base is not too large, analyze the code and note all the things that can be better. Then start from scratch rewriting the code in C#. This is very boring work, but it does advance pretty quickly.
|
|
|
|
|
Hii all, i'am trouble to create cryptanalysis algorithm RC5 application. can help in me about it and please solution here to C# 2008 language. Thanks
|
|
|
|
|
Member 10899694 wrote: Hii all, i'am trouble
Yes we've realized that and we'll take appropriate measures.
Hang on just a moment and we'll relieve you from your suffering!
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
Thanks, big helpful for this moment
|
|
|
|
|
Yeah, that's not a chance in hell that's going to happen.
|
|
|
|
|
ofcourse now implement 12-round RC5 (with 64-bit blocks) is susceptible to a differential attack using 2^44 chosen plaintexts in c# to find the key. do you have a pseudo code or code implement to GUI in visual c#.
|
|
|
|
|
Again, that's your research project, not ours.
Considering the dubious nature of what you're asking, you're not going to get anyone here to write this for you or even give you a hint about it.
|
|
|
|
|
thank you for taking the time to small discuss
|
|
|
|
|
KaKoten wrote: or code implement to GUI in visual c# www.youtube.com/watch?v=hkDD03yeLnU[^]
I'm still not sure exactly what you're doing, but I can almost guarantee you that a GUI will be completely irrelevant.
|
|
|
|