开发者

Adding a border (Fixed3D) to an existing borderless application

开发者 https://www.devze.com 2022-12-25 15:44 出处:网络
I have an .NET application that always starts itself with its border style to \'None\', as it is supposed to be an full-screen application with a fixed resolution.

I have an .NET application that always starts itself with its border style to 'None', as it is supposed to be an full-screen application with a fixed resolution.

However, i would like to add the window border (Fixed3D) to this window when the application starts so that I am able to move it around my desktop.

My first idea was to have a tray app running, monitoring event messages, and somehow change the window style when this specific applicat开发者_开发问答ion starts. However, I am not sure if this will work and how to do this.

Anyone that can point me in the right direction?


You should probably look into using the SetWindowLongPtr function of user32.dll.

You'll need to get the window handle associated with the application's main window. This could potentially be done using:

Process[] processes = Process.GetProcesses();
foreach (Process process in processes) {
    if (process.MainModule.FileName == @"C:\Program Files\App\app.exe") {
        IntPtr handle = process.MainWindowHandle;
        // Call method to change window style here.
        break;
    }
}

You can then set the appropriate styles using the GWL_STYLE constant (value -16 in decimal) and SetWindowLongPtr.

Changing the Style of the Main Window should help you find the styles that you need.


You can inherit a class from a main class in the source code, and change its properties in the appropriate events. hat would be no modification of the source code, though it would be a different application.

0

精彩评论

暂无评论...
验证码 换一张
取 消