
宣告太多就不都貼了,這些都是網上找的代碼
代碼如下
public enum appStyle {
FullScreen = 0,
WindowedFullScreen = 1,
Windowed = 2,
WindowedWithoutBorder = 3,
}
public appStyle AppWindowStyle = appStyle.WindowedFullScreen;
public enum zDepth {
Normal = 0,
Top = 1,
TopMost = 2,
}
public zDepth ScreenDepth = zDepth.Normal;
public int windowLeft = 10;
public int windowTop = 10;
public int windowWidth = 800;
public int windowHeight = 600;
const uint SWP_NOMOVE = 0x0002;
const uint SWP_FRAMECHANGED = 0x0020;
const uint SWP_SHOWWINDOW = 0x0040;
const int GWL_STYLE = -16;
const int WS_BORDER = 1;
private Rect screenPosition;
private const int GWL_EXSTYLE = (-20);
private const int WS_CAPTION = 0xC00000;
private const int WS_POPUP = 0x800000;
IntPtr HWND_TOP = new IntPtr(0);
IntPtr HWND_TOPMOST = new IntPtr(-1);
IntPtr HWND_NORMAL = new IntPtr(-2);
private const int SM_CXSCREEN = 0x00000000;
private const int SM_CYSCREEN = 0x00000001;
int Xscreen;
int Yscreen;
void Start ()
{
Xscreen = (int)GetSystemMetrics(SM_CXSCREEN);
Yscreen = (int)GetSystemMetrics(SM_CYSCREEN);
//這種情況
if((int)AppWindowStyle == 1)
{
Screen.SetResolution(Xscreen-1,Yscreen-60,false);
screenPosition = new Rect(0,0,Xscreen-1,Yscreen-1);
}
}
int i = 0;
void Update () {
//然后我不明白為什么要在Update設定,直接在Start設定不好嗎?
//我調了很多引數發現都改不了視窗的位置,而且我的目的是在單屏情況和雙屏情況都視窗全屏顯示在第一個螢屏上
if (i < 5)
{
if ((int)AppWindowStyle == 1)
{
if ((int)ScreenDepth == 2)
SetWindowPos(GetForegroundWindow(), HWND_TOPMOST, (int)screenPosition.x, (int)screenPosition.y, (int)screenPosition.width, (int)screenPosition.height, SWP_SHOWWINDOW);
ShowWindow(GetForegroundWindow(), 3);
}
}
i++;
}
uj5u.com熱心網友回復:
一直用雙屏,還沒有遇到過這種情況,你新建個工程,不寫一行代碼試試。實在不行判斷全屏時,設定self.Left=0
uj5u.com熱心網友回復:
沒遇到過,請檢查你的視窗是否最大化了,還是指定了大小。另外再注意一個Form的屬性:Position,當值是poDesktopCenter,而且視窗不是最大化就會出現你這種情況。poScreenCenter:在某個顯示幕中央
poDesktopCenter:在多個顯示幕組成的大桌面的中央
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/61644.html
標籤:語言基礎/算法/系統設計
上一篇:win7下 Delphi
