tags:

views:

41

answers:

2

Hi there,

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 application starts. However, I am not sure if this will work and how to do this.

Anyone that can point me in the right direction?

A: 

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.

Kaerber
That would indeed be a nice solution.Unfortunately in my specific situation the Program's Main executes a lot of internal logic, which in turn creates the mainForm. Besides, I cannot touch the actual solution and the internal code. I must approach it like i do not have the sources; however i am able to 'see' them.
Aphelion
+1  A: 

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.

Mark