Click here to Skip to main content
13,149,073 members (55,576 online)
Rate this:
Please Sign up or sign in to vote.
So basically my problem is that i work in unity3D, and it sadly don't have a "FullScreen Maximized" option... but i've heard/seen that you can do some DLLImport with "using System.Runtime.InteropServices;" but im not sure of what functions i need and what values i should assign to different field.

So how can i remove any window's Border (all of it) only using pure code/DLLImport?

- Thanks Jackie
Posted 1-Jul-12 14:23pm
Why P/Invoke? What do you think is not available with regular .NET API?
Do you need full screen or remove border? border is not removed in full screen, did you know that?
Jackie00100 2-Jul-12 8:26am
.NET API is due to sources from unity3D not compatible... one source said that you could use DLLImport as mentioned, and i need to remove the borders to have the "Fullscreen maximized window" effect (like seen in lots of game) where you can have windows above your actual "fullscreen" window (windowed maximized mode) i did know that fullscreen still have borders but some how they're "hidden"
Those borders are hidden only because they go out of the visible screen. I developed the desktop manager where I moved all windows on a low-level, so I could clearly see it. I'm less sure about Unity, but have some reasons to suspect the situation is exactly the same...
Jackie00100 2-Jul-12 18:03pm
So do you know any way of doing this then?
Sorry, never tried Unity, so I'm not sure... otherwise I would put an answer, not just comments.
Jackie00100 2-Jul-12 20:48pm
well I'm thinking of a more overall way to do it like DLLImport which i know you can use in unity and I've got some finger points that i should do this but the problem is i cant find the functions and values needed to import to get the wished result so if someone knew what to import and stuff that would help me out a lot

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

okay fixed this my self after finding the right imports...


Source code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace border_removal_test
    public partial class Form1 : Form
        //Import window changing function
        public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
        //Import find window function
        [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
        static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
        //Import force window draw function
        static extern bool DrawMenuBar(IntPtr hWnd);
        [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
        public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);

        private readonly string WINDOW_NAME = "Form1";  //name of the window
        private const int GWL_STYLE = -16;              //hex constant for style changing
        private const int WS_BORDER = 0x00800000;       //window with border
        private const int WS_CAPTION = 0x00C00000;      //window with a title bar
        private const int WS_SYSMENU = 0x00080000;      //window with no borders etc.
        private const int WS_MINIMIZEBOX = 0x00020000;  //window with minimizebox
        public Form1()
        private void Form1_Load(object sender, EventArgs e)
        private void button1_Click(object sender, EventArgs e)
            IntPtr window = FindWindowByCaption(IntPtr.Zero, WINDOW_NAME);
            SetWindowLong(window, GWL_STYLE, WS_SYSMENU);
            SetWindowPos(window, -2, 0, 0, 800, 600, 0x0040);
            //this.WindowState = FormWindowState.Maximized;
        private void button2_Click(object sender, EventArgs e)
            IntPtr window = FindWindowByCaption(IntPtr.Zero, WINDOW_NAME);
            this.WindowState = FormWindowState.Normal;
        private void button3_Click(object sender, EventArgs e)

a simple google search on each import function will let you know how they works...
barneyman 8-Jul-12 22:12pm
Do you want to explain how? That way, this becomes an answer someone else can use!
Jackie00100 9-Jul-12 9:52am
Yaeh was to tired yester day to do anything and now im lazy so just uploading source code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170924.2 | Last Updated 9 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100