T
T
TechNOIR2018-03-02 22:06:33
C++ / C#
TechNOIR, 2018-03-02 22:06:33

C#. How to reassign the program close button (cross in the corner)?

Good afternoon.
Please tell me how to reassign the program close button (cross in the corner)?
I want to put another action on it.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Bashinsky, 2018-03-02
@TechNOIR

I 'll add to the mindtester post
There is an easier option, subscribe to the OnClosing event
in it, you do all the actions when that button is pressed and you need to cancel the closing itself
It seems so, I don’t remember exactly :)

#
#, 2018-03-02
@mindtester

dig in the direction of user32.dll (I'm tired in the evening .. I won't say anything more intelligible yet)
ps I
'll have to comprehend what win32 api is, the window handle, the attribute [DllImport("USER32.DLL")] .. and a bunch of all sorts of incidental nuances. good luck..
ps I obviously reflected on my old experience))
.. on the words "redefinition" and the cross - remove the window title, redefine the contents of the window menu , remove the cross .. that's what I thought
.. but OnClosing of the main form .. not what I didn’t know, I just always used it for actions before closing the program ..
.. I already managed to figure out a typical scenario - minimizing to the tray, and I had experience with the tray, I just chose the strategy of writing a lightweight agent for the tray, and it was not in my practice to cancel the closing, that is, it didn’t close again ) ))
.. well, make allowance for age )).. I'm 52 .. and already a half )) .. nevertheless - I code, and still, not rarely, for money ;)))
pps nevertheless - colleagues gave the correct answer ... and I will also take it in my piggy bank ... alternative to the "tray-tray agent" - minimized and hidden application, does not require time to reactivate ... depending on the task, this may be the right solution
.. but if you need to save memory , and the main form is light - then a lightweight, autonomous tray agent can be better
thanks to everyone! good luck to all! ))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question