How do I change the MessageBox location?

前端 未结 5 1021
醉梦人生
醉梦人生 2020-12-11 01:22

I need to change the message box location. I don\'t want it to be in the center of the page.

MessageBox.Show(\"Hello\");
5条回答
  •  不知归路
    2020-12-11 02:15

    Since I already use AutoIt for several other tasks in my project so I just create another thread to move the Message box

    using System.Threading;
    using AutoIt;
    //Namespace, class, function stuffs
    //New thread BEFORE create message box - safety measure
    Thread autoItThread = new Thread(delegate ()
                    {
                        AutoItX.WinWait("New Message box");
                        AutoItX.WinMove("New Message box", "This box will be moved", 400, 300);
                    });
                    autoItThread.Start();
    MessageBox.Show("This box will be moved", "New Message box");
    

    Please note

    • The coordinate 400,300 is absolute. 0,0 will be top left corner.
    • This is screen-dependent. If you want to be exact, other code to determine location is needed
    • This task is to change the absolute position of the Message box rather than move it.
    • How to get/install AutoIt is not addressed here. Please look for instruction on that if you need to.

提交回复
热议问题