Windows Form (C#) -- Clicking buttons without leaving mouse click - c#

I'm trying to build an application using C#, which will visualize some graph searching algorithms.
For that, I opened a Windows Form and inserted 50X50 buttons to it.
I know how to make the buttons do something specific everytime I click it.
But the problem that I encounter is, I want to press the mouse-clickbutton ONCE, and without leaving the mouse-clickbutton, I want EVERY BUTTON I PASS ON to be pressed.
For example, I want to press the whole first line of buttons.
I can press each button separately, but instead, I want to click one of the buttons, and without leaving my mouse button pressed, I want to pass by all the buttons and make them clicked.
I want that my mouse click would mark as many buttons as its pressed, and if my mouse button is not pressed, nothing would happen.
I hope my question is understandable. Can anyone please point me where I can find this solution? I googled my vision but couldn't find anyone getting to understand my idea.
Thanks in advance!

Related

How to check if LeftClick is pressed C#

I need to check if a user has left click being held anyone know how I would need to accomplish this?
I already tried messing around with System.Windows.Input but I couldn't figure it out
This is a windows forms app but I need it to work outside of the form I prefer a simpler answer
Alot of useful answers on Stack overflow.
Try this >> c# Detect mouse clicks anywhere (Inside and Outside the Form)
This should allow you to detect left clicks in or outside your program.
If you want an event for a control in your form, try the .Click event.

Is there a way to visibly simulate a mouseclick with just a button itself?

I've seen here: How to make a button appear as if it is pressed? how to make a button in a winforms application look pressed (and that it stays pressed) in 2008.
In my application I travel a similar route there but what I'm trying to do is to get more a feel like a mouse has clicked the button. Thus it becomes pressed for a second and then unpressed again (just like with a regular mouse click).
What I'm wondering there is if in 2017+ that Checkbox Workaround is still the best Approach even for this route (and it Needs to be "checked" and "unchecked") or if there is a better approach there (thus also one possible with the button itself)?

Faking A Keyboard or Mouse Event

I've been trying to figure out how to fake, not simulate, keyboard and mouse input. By this I mean the system goes through the process as if the actual event occurred, such as a mouse click, but does not actually perform the event, such as clicking the mouse.
Or if you wanted to make the system think your mouse had moved even though it did not. Sort of a "virtual" move that doesn't actually happen/effect the mouse.
Is it possible to override the simulated mouse clicks and events to make them not actually click while the system thinks they have?
Here is a nice project that wraps the keyboard and mouse. Here is the mouse input simulator file for reference. To see the lower level work, navigate to the WindowsInput.Native namespace in that project.
Thanks guys for all of your help. I was finally able to achieve what I wanted via lrb's answer.
I used that library to fake input and in the grand scheme of things I was trying to make a mouse jiggler but not actually effecting the user's mouse in case the application was running while the user was using the mouse. Which is why I wanted to "fake" the mouse rather than move the actual mouse. Thanks again for everything this was amazing.
Icemanind I'm still curious about your idea with subscribing an event rather than having an event handler. This would allow me to induce something like a mouse click without actually clicking correct?

Dismiss drop down control and click a button in one mouse click

I have a control with multiple inputs in a drop down box. If the drop down control is engaged, then I click off it on another button on the panel, it uses the first click to dismiss the previous control, and basically takes two clicks to hit the button I wanted to hit with the first click. Can anyone give me a work around for this?
Winforms C#
09/06/2012: Still unanswered, I've tried Googling this, I'm not sure why it hasn't come up more often?

Change default arrangement of Save and Cancel buttons in SaveFileDialog

I m coding in c# and I want to change the default arrangement of 'Save' and 'Cancel' buttons in SaveFileDialog. The default arrangement is that the 'Save' button is above the 'Cancel' button.
What I want is to place 'Cancel' button on the right hand side of the 'Save' button.
I searched over the web and found that the text on these buttons can be changed(to which the answer was on stackoverflow itself) and nothing found on changing their arrangements (locations).
Please give me a solution if any of you have experienced this so far....
thank you
Please don't do this.
The user is used to where these buttons appear. If you try to change their layout then you will just make you app feel wrong.
If you have to do this then should make sure you use the legacy file dialogs (which will make your dialogs look even more odd on Vista/7). Use the lpfnHook field in the OPENFILENAME struct to obtain hooks in to the dialog procedure. Respond to the CDN_INITDONE notification and move the buttons around with MoveWindow or SetWindowPos. You'll have to hunt for the button window handles.
But really, please don't do this, you'll just make your app worse.
That rings a bell. When you have the code to change the text of the button then you have the handle of the button window. Which you can then use when you pinvoke GetWindowRect and MoveWindow to move the button somewhere else. Visit pinvoke.net for the declarations.
Beware that the dialog changed in every Windows version. The next one might well break your program. Your customer is not going to be disappointed when you don't do this.

Categories

Resources