✅ How can i disable maximizing the form
Hi! I am using C# .netframework 4.7.2 and i was trying to disable maximizing and my FormBorderStyle is None, im using my own buttons but actual problem is when i press Win + Up it maximizes again how can i disable this?
75 Replies
have you also disabled maximize button?
yes
I think the simplest solution would be to set your Form's MaximumSize value.
ok i made it its works fine but another problem is when i press Win + Up it goes top left side its need to be do nothing
how can i remove win + up combination on form
i cant pull down
Change the
FormBorderStyle
to FixedSingle
with no Text
value.there is no way to make in None?
i dont wanna see FixedSingle's tabs
What tabs?
sorry for my bad english this thing
Set the Form's
Text
property to nothingits still there
Also check if
ControlBox
is set to falsewhy it has a border?
You have text and control box not set properly
wait
im still checking but text is blank and control box is false
look
And FormBorderStyle is FixedToolWindow?
wat
but you said fixed single
FixedSingle works for me as well
fixedtoolwindows works i think
it seems works but it has a little border
Your screenshot shows that there is still text for the form.
its label
Yeah, if you don't want the small border, you have to use FormBorderStyle None. You'll need to use the code from https://stackoverflow.com/questions/3213606/how-to-suppress-task-switch-keys-winkey-alt-tab-alt-esc-ctrl-esc-using-low
Stack Overflow
How to Suppress task switch keys (winkey, alt-tab, alt-esc, ctrl-es...
Can anyone please tell me how to disable the task switch keys using c#
i was using None first time
You can change the
objKeyInfo.key
checks for the keys you care about.
You have to hook into low level keyboard input events to disable the winkey stuff.
You probably only need if (objKeyInfo.key == Keys.RWin || objKeyInfo.key == Keys.LWin)
instead of the others as those deal with Alt-Tab and other combinations.well which ones i need to paste in my project
You shouldn't just paste code in. You should read it and try to understand what it's doing.
the thing is i cant understand very well
example what is it
What does the comment above that section say?
i dont know what is this dll do
//System level functions to be used for hook and unhook keyboard input
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SetWindowsHookEx(int id, LowLevelKeyboardProc callback, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool UnhookWindowsHookEx(IntPtr hook);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr CallNextHookEx(IntPtr hook, int nCode, IntPtr wp, IntPtr lp);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr GetModuleHandle(string name);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern short GetAsyncKeyState(Keys key);
//Declaring Global objects
private IntPtr ptrHook;
private LowLevelKeyboardProc objKeyboardProcess;
this dlls needs to be in my project folder?
ok forget what i said
where am i need to write this?It needs to be accessed from the code in your Form_Load event, so probably somewhere in the Form.cs.
but its gave me too much errors
Where did you put the code?
in Form_Load event
my form name is ggg
k i put other code
it says
The stackoverflow post shows two sections of code. The second says it goes in the Form_Load(). The first does not go in the Form_Load()
Chatset isnt found
i think i need to put some using thing
System.Runtime.InteropServices
and
this thing
?
i found it
Diagnostics
its works veryyy well but i need to change something
win + up isnt working at all but
i want to make alt tab
alt tab is good shortcut
damn i cant do it when i was discord
NOO
That's all handled by the section labled
// Disabling Windows keys
of the captureKey
function
You choose which keys and/or combination of keys to ignore.ok thanks im going to test it
its like a virus u cant use any windows thing
damn
wait but
when i try to change it its allows win + up
and i cant make win + r
to open "run"
i just need to disable win + up
If you only want to disable Win+Up I think something like
if ((objKeyInfo.Key == Keys.Rwin && Keys.Up) || (objKeyInfo.Key == Keys.Lwin && Keys.Up))
but I haven't tested it.I don't speak.. Turkish? So I have no idea what those errors are saying.
oh
hm
wait
i cant change vs's lang but i have translate
Severity Code Description Project File Line Hide Status
Error CS1061 'GGG.KBDLLHOOKSTRUCT' does not contain a definition of 'Key' and there is no accessible 'Key' expansion method that accepts a first argument of type 'GGG.KBDLLHOOKSTRUCT' (maybe you're missing a using folders or tutorial?)
i solve the problem but
its still allow
wait
Did you add the code from the second stackoverflow post to your form_load?
yep
i forgot to change it with your code
wait
im trying to solve this problem
CS0019 The '&&' operator cannot be applied to operands of type 'bool' and 'Keys'.
I did my code directly in discord so Im sure it has some typos. LIke I said, I didn't test it.
i changed your code like this
if (objKeyInfo.key == Keys.RWin && Keys.Up || objKeyInfo.key == Keys.LWin && Keys.Up && (ModifierKeys & Keys.Control) == Keys.Control)
its says you cannot use bool's && symbol on Keys
i think
i translated very well 😄
the problem is which thing we need to use to add new combo like win + up, the code errors when we use &&From testing it also seems like the Win Key combination isn't sent as a combination of keys. I think I found a solution that I'm testing.
ow
good luck
Here's the code that I think should work.
bro
you are the best coder ive ever seen
thanks
BTW, if you're just starting learning, it might be better to swtich away from WinForms. It's old tech and not really being updated/used. WPF is more current.
you'r right but for now im making simple programs. Btw im going to add new help i think because i need to make daily log system for this project my opinion is when my dad's customers came in our place and when my dad isn't there i have to note it on paper but i dont wanna note it because it tooks too long for me thats why im doing this i have to log it in txt but i need to make like this. Example today is 06.25.2023 right? folder name is 06.25.2023 inside of the folder is need to log.txt its need to change everyday when the date is changed and when the program was started its need to create a new folder
but first i need to go wc
soo see u later and thanks for helping me 💜
Good luck!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.