I've been looking around and cant seem to find any of the help I need for my program
I need it so when I click a specific button(F9) It hides the program from taskbar. After its hidden from taskbar I need to be able to click a button(F10) to make it Show in task bar again. Currently when I run it F9 Hides it but F10 wont show it
private void Menu_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F9)
{
SecHiden.PerformClick();
}
if (e.KeyCode == Keys.F10)
{
SecShow.PerformClick();
}
}
private void SecHiden_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
}
private void SecShow_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
}
}
}
EDIT: i've figured out the error just need help fixing it
I have to be tabbed into the program for the Keybinds to work is there a way to fix this? I would like to able to use the keybinds when im on Any specift tab(F10 Wouldnt show the tab because I wasnt tabbed onto the program to make the keybind work)
Related
This problem is happening when the FormBorderStyle = None and a button is used to set the WindowState. Chunks of the form turn invisible when the form is restored from a minimized state or is maximized from a normal state.
The code for maximizing and minimize:
private void MaximizeButton_Click(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Normal)
{
WindowState = FormWindowState.Maximized;
}
else
{
WindowState = FormWindowState.Normal;
}
}
private void minimize_button_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
}
I have failed to recreate this glitch in any other winform based application of mine.
I appreciate the help , hope you all are having a comfortable covid stay.
Simply refresh the window once its state becomes maximized. Unlike WPF, Winforms doesn't have a StateChanged event, so use SizeChanged to detect if the window it's maximized, and refresh it.
private void Window_SizeChanged(object sender, EventArgs e)
{
if(WindowState == FormWindowState.Maximized)
Refresh();
}
I'm working on a Win Forms project where I'm trying to create an button to toggle full screen on/off every time i click the button,so if you click once, it becomes full screen, if you click again, it becomes normal again.
please tell me how to do that.
I am not sure about the exact requirements but this should help you.
Add Form1_Load and button1_Click events.
private void Form1_Load(object sender, EventArgs e)
{
// Normal when the form opens
WindowState = FormWindowState.Normal;
}
private void button1_Click(object sender, EventArgs e)
{
// Toggle on a button click
WindowState = WindowState == FormWindowState.Normal ? FormWindowState.Maximized : FormWindowState.Normal;
}
I am trying to make my application minimize to task bar/tray
Here is my code so far that I have pulled together from other SO posts and other people seem to have it working but my app minimizes to the tray but when I click it in the tray it doesn't reopen.
private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(500);
this.Hide();
}
}
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Normal;
}
just to explain again the problem is the application minimizes to the tray but when I click on the icon it doesn't restore the app to normal. Instead it does nothing.
I found my problem.
what I didn't do was this
Set the NotifyIcon's visible property to false in the property editor. Now go to the property editor of Form1, click on the little lightning symbol to access the events, and double click on the Resize event, and change the code to:
and I also didn't do this
Finally we need the code to make the program show up again when the icon is double clicked. So double click on NotifyIcon1 in the designer,
I found this information here
Dreamincode
This is what I have used in the past but I fund a copy online at the link below
if (FormWindowState.Minimized == this.WindowState)
{
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(500);
this.Hide();
}
found here: http://www.codeproject.com/Articles/27599/Minimize-window-to-system-tray
I cannot figure this out
i'm making a windows form application with visual basic in c#
i have a scan button and it scans everything in the folder and lists all of the files in the listbox
if you click it another time the list of files appear again
how can you make it so you can only press the scan button once, and then you can press it again if you click the browse button?
the browse button is to select the folder you want to scan
thanks
This is pretty trivial
private void ScanButtonClick(object sender, EventArgs e)
{
// do something
(sender as Button).Enabled = false;
}
private void BrowseButtonClick(object sender, EventArgs e)
{
ScanButton.Enabled = true;
}
Its a bit unclear if you're writing in C# or vb.net, but since the question is tagged as C#...
private void btnScan_Click(object sender, EventArgs e) {
btnScan.Enabled = false;
// other code here
}
private void btnBrowse_Click(object sender, EventArgs e) {
btnScan.Enabled = true;
//other code here
}
I tried this in my windows form application in C# and it works fine!
private void button3_Click_1(object sender, EventArgs e)
{
int count = 0;
count++;
//add your code here
if (count == 1) {
button3.Enabled = false;
//only one click allowed
}
}
I'm new with c# but know c++ and c, my problem is that I can't get my form to show up again after it got minimized to the system tray.
That's the code I used to hide it:
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
bool cursorNotInBar = Screen.GetWorkingArea(this).Contains(Cursor.Position);
if (this.WindowState == FormWindowState.Minimized && cursorNotInBar)
{
this.ShowInTaskbar = false;
notifyIcon.Visible = true;
this.Hide();
}
}
You need to undo the changes you made to the form to make it hide...to make it display again:
private void notifyIcon_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
this.Show();
this.ShowInTaskbar = true;
this.WindowState = FormWindowState.Normal;
notifyIcon.Visible = false;
}
}
on notifyIcon click event try:
this.Show();
(I'm not sure but this one could work too: this.Visible = true)
by the way try to handle OnClosing event on your form instead of OnResize
(I have suitable code in home, when i got there ill share it)
You can use this.Show() to show the form again after minimized. If this is not working, just tell me, will provide another solution.