我們希望我們的應用程序能夠在全屏模式下運行,並且Win CE 6.0驅動的設備上沒有標題欄。該應用程序正在使用.NET Compact Framework 3.5(C#)開發。任何示例代碼或指向文章的讚賞。如何使用.NET Compact Framework 3.5在Win CE 6.0中創建全屏應用程序?
4
A
回答
5
首先,您必須通過P/Invoke隱藏任務欄。這裏的C代碼,這應該是很容易to convert:
HWND hwndTaskbar = ::FindWindow(_T("HHTaskBar"), NULL);
::ShowWindow(hwndTaskbar, SW_HIDE);
一旦你這樣做,然後使用Screen.PrimaryScreen以確定您的顯示器有多大和調整您的表格,這些尺寸。
5
使用此代碼:
public class FullScreenEngine
{
// Fields
private IntPtr _hWndInputPanel;
private IntPtr _hWndSipButton;
private IntPtr _hWndTaskBar;
private Rectangle _desktopArea;
public FullScreenEngine()
{
Init();
}
public bool SetFullScreen(bool mode)
{
try
{
if (mode)
{
if (_hWndTaskBar.ToInt64() != 0L)
{
ShowWindow(_hWndTaskBar, SW_HIDE);
}
if (_hWndInputPanel.ToInt64() != 0L)
{
ShowWindow(_hWndInputPanel, SW_HIDE);
}
if (_hWndSipButton.ToInt64() != 0L)
{
ShowWindow(_hWndSipButton, SW_HIDE);
}
WorkArea.SetWorkArea(new RECT(Screen.PrimaryScreen.Bounds));
}
else
{
if (_hWndTaskBar.ToInt64() != 0L)
{
ShowWindow(_hWndTaskBar, SW_SHOW);
}
if (_hWndInputPanel.ToInt64() != 0L)
{
//ShowWindow(_hWndInputPanel, SW_SHOW);
}
if (_hWndSipButton.ToInt64() != 0L)
{
ShowWindow(_hWndSipButton, SW_SHOW);
}
WorkArea.SetWorkArea(new RECT(_desktopArea));
}
}
catch (Exception)
{
return false;
}
return true;
}
private bool Init()
{
try
{
_desktopArea = Screen.PrimaryScreen.WorkingArea;
_hWndInputPanel = FindWindowW("SipWndClass", null);
_hWndSipButton = FindWindowW("MS_SIPBUTTON", null);
_hWndTaskBar = FindWindowW("HHTaskBar", null);
}
catch (Exception)
{
return false;
}
return true;
}
private const uint SW_HIDE = 0;
private const uint SW_SHOW = 1;
[DllImport("coredll.dll")]
private static extern int ShowWindow(IntPtr hwnd, uint command);
[DllImport("coredll.dll")]
private static extern IntPtr FindWindowW(string lpClassName, string lpWindowName);
// Nested Types
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public RECT(Rectangle rect) : this()
{
Left = rect.Left;
Right = rect.Left+rect.Width;
Top = rect.Top;
Bottom = rect.Top + rect.Height;
}
}
private static class WorkArea
{
[DllImport("coredll.dll")]
private static extern bool SystemParametersInfo(uint uAction, uint uparam, ref RECT rect, uint fuWinIni);
private const uint WM_SETTINGCHANGE = 0x1a;
const uint SPI_GETWORKAREA = 48;
const uint SPI_SETWORKAREA = 47;
public static bool SetWorkArea(RECT rect)
{
return SystemParametersInfo(SPI_SETWORKAREA, 0, ref rect, WM_SETTINGCHANGE);
}
public static RECT GetWorkArea()
{
var rect = new RECT();
SystemParametersInfo(SPI_GETWORKAREA, 0, ref rect, 0);
return rect;
}
}
}
相關問題
- 1. Windows CE 6.0 SQL Server Compact 3.5
- 2. Sql Server CE 3.5和.NET Compact Framework 2.0 SP2
- 3. 在.NET Compact Framework 3.5下的ThreadPool.SetMinThreads
- 4. 啓動後立即在Win CE中執行.net應用程序
- 5. 如何創建一個WIN CE 6.0 LCD驅動程序?
- 6. .NET Compact Framework在ROM中使用2.0或在RAM中使用3.5?
- 7. .net Compact Framework callstack - 如何?
- 8. .NET Compact Framework應用程序安裝創建器
- 9. 將.Net Compact Framework 3.5轉換爲.Net Core
- 10. X509Certificate和.NET Compact Framework 3.5
- 11. .Net Compact Framework 2.0:部署應用程序
- 12. 應用程序在Windows Ce 6.0上的Compact Framework應用程序中拋出的錯誤
- 13. .NET 3.5 Compact Framework可以有全局錯誤處理程序嗎?
- 14. FlashPlayer For .net Compact Framework 3.5
- 15. 如何在.NET Compact Framework應用程序中嵌入廣告?
- 16. 事件在winform - .NET Compact Framework的3.5
- 17. 使用實體框架與.NET Compact Framework 2.0和SQL Compact 3.5
- 18. 在.NET Compact Framework 3.5中創建電子表格
- 19. Windows Mobile 6 - .net Socket建議[Compact Framework 3.5]
- 20. 如何部署.Net Compact Framework和SQL Server Compact Edition與應用程序
- 21. Windows CE/Compact Framework上的混合模式
- 22. 如何在.Net Compact Framework中播放.WAV(Datalogic Memor)Windows CE 5.0?
- 23. 熱門.NET Compact Framework開源應用程序/組件
- 24. 如何轉換在.NET Compact Framework中使用StandardInput和StandardOutput的C#應用程序?
- 25. 如何在我的Compact Framework應用程序中使用OpenStreetMap?
- 26. 使用.Net 2008應用程序自動安裝.NET Framework 3.5 SP1
- 27. .NET Compact Framework應用程序中的版本號
- 28. 使用.Net Compact Framework 3.5在DataGrid中進行條件格式化
- 29. Windows CE 6.0應用程序錯誤,然後應用程序凍結,但在Windows CE 5中工作5
- 30. Windows CE 5.0和Compact Framework 3.5上的System.Diagnostics.Trace/Debug
能否請您給一些C#調用這些API。對不起,我對P/Invoke不太瞭解。 – Gopinath 2009-12-10 07:18:35
如果你要編寫一個CF應用程序,你將不得不學習P/Invoke - 這是無法解決的。這些非常簡單,我給了一個鏈接,讓你開始。我沒有給你魚,只有釣竿。 – ctacke 2009-12-10 13:57:15
謝謝。我開始學習P/Invoke :) – Gopinath 2009-12-10 15:47:56