2016-09-12 3 views
1

Я пытаюсь поставить виртуальную клавиатуру Win 10 Borderless Но не знаю, почему она не работает.Виртуальная клавиатура Без полей Win 10

Я пробовал с NotePad, и он работает.

(я сделал debug.log, чтобы проверить, если IntPtr не равно нулю и в обоих случаях она возвращает истину)

Вот что я сделал

using UnityEngine; 
using System; 
using System.Runtime.InteropServices; 

public class test : MonoBehaviour 
{ 
[DllImport("user32.dll")] 
public static extern IntPtr FindWindow(string className, string windowName); 

[DllImport("USER32.DLL")] 
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); 

[DllImport("USER32.DLL")] 
public static extern int GetWindowLong(IntPtr hWnd, int nIndex); 

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] 
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); 

const int WS_BORDER = 8388608; 
const int WS_DLGFRAME = 4194304; 
const int WS_CAPTION = WS_BORDER | WS_DLGFRAME; 
const int WS_SYSMENU = 524288; 
const int WS_THICKFRAME = 262144; 
const int WS_MINIMIZE = 536870912; 
const int WS_MAXIMIZEBOX = 65536; 
const int GWL_STYLE = -16; 
const int GWL_EXSTYLE = -20; 
const int WS_EX_DLGMODALFRAME = 0x1; 
const int SWP_NOMOVE = 0x2; 
const int SWP_NOSIZE = 0x1; 
const int SWP_FRAMECHANGED = 0x20; 
const uint MF_BYPOSITION = 0x400; 
const uint MF_REMOVE = 0x1000; 

private void Borderless() { 

    // IntPtr hWnd = FindWindow(null,"On-Screen Keyboard"); // <----- Not Working 
    IntPtr hWnd = FindWindow(null,"Untitled - NotePad"); // <----- Working 

    if (hWnd != IntPtr.Zero) 
    { 
     int Style = 0; 

     Style = GetWindowLong(hWnd, GWL_STYLE); 
     Style = Style & ~WS_CAPTION; 
     Style = Style & ~WS_SYSMENU; 
     Style = Style & ~WS_THICKFRAME; 
     Style = Style & ~WS_MINIMIZE; 
     Style = Style & ~WS_MAXIMIZEBOX; 

     SetWindowLong(hWnd, GWL_STYLE, Style); 
     Style = GetWindowLong(hWnd, GWL_EXSTYLE); 
     SetWindowLong(hWnd, GWL_EXSTYLE, Style | WS_EX_DLGMODALFRAME); 
     SetWindowPos(hWnd, new IntPtr(0), 50, 0, 150, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); 
    } 
    else 
    { 
     Debug.LogWarning("Borderless() failed, hWnd is 0!"); 
    } 
} 

void Start() 
{ 
    Borderless(); 
} 

}

спасибо Ребят;)

ответ

0

Хорошо, я получаю другое решение, возможно, лучшее.

On-Screen Keyboard on Unity

Я знаю, что это не реальный ответ, так что если кто-нибудь знает, почему выше код не работает, я буду рад узнать;)

Смежные вопросы