Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows Interop service API , +
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 15:23pm
Comments
Sergey Alexandrovich Kryukov at 1-Jul-12 23:56pm
   
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?
--SA
Jackie00100 at 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"
Sergey Alexandrovich Kryukov at 2-Jul-12 15:25pm
   
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...
--SA
Jackie00100 at 2-Jul-12 18:03pm
   
So do you know any way of doing this then?
Sergey Alexandrovich Kryukov at 2-Jul-12 18:14pm
   
Sorry, never tried Unity, so I'm not sure... otherwise I would put an answer, not just comments.
--SA
Jackie00100 at 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
good
Please Sign up or sign in to vote.

Solution 1

okay fixed this my self after finding the right imports...
 
EDIT:
 
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
        [DllImport("USER32.DLL")]
        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
        [DllImport("user32.dll")]
        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()
        {
            InitializeComponent();
        }
 
        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;
            DrawMenuBar(window);
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            IntPtr window = FindWindowByCaption(IntPtr.Zero, WINDOW_NAME);
            SetWindowLong(window, GWL_STYLE, WS_CAPTION | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX);
            this.WindowState = FormWindowState.Normal;
            DrawMenuBar(window);
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
 
a simple google search on each import function will let you know how they works...
  Permalink  
v2
Comments
barneyman at 8-Jul-12 22:12pm
   
Do you want to explain how? That way, this becomes an answer someone else can use!
Jackie00100 at 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
0 Sergey Alexandrovich Kryukov 535
1 Kornfeld Eliyahu Peter 407
2 Maciej Los 369
3 DamithSL 221
4 OriginalGriff 218
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 9 Jul 2012
Copyright © CodeProject, 1999-2014
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