mirror of https://github.com/adamdruppe/arsd.git
unicode window title
This commit is contained in:
parent
53525181d4
commit
ecf04589d0
|
@ -7261,18 +7261,19 @@ version(Windows) {
|
||||||
HBITMAP buffer;
|
HBITMAP buffer;
|
||||||
|
|
||||||
void setTitle(string title) {
|
void setTitle(string title) {
|
||||||
SetWindowTextA(hwnd, toStringz(title));
|
WCharzBuffer bfr = WCharzBuffer(title);
|
||||||
|
SetWindowTextW(hwnd, bfr.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
string getTitle() {
|
string getTitle() {
|
||||||
auto len = GetWindowTextLengthA(hwnd);
|
auto len = GetWindowTextLengthW(hwnd);
|
||||||
if (!len)
|
if (!len)
|
||||||
return null;
|
return null;
|
||||||
char[] buffer = new char[len];
|
wchar[256] tmpBuffer;
|
||||||
auto len2 = GetWindowTextA(hwnd, buffer.ptr, cast(int) buffer.length);
|
wchar[] buffer = (len <= tmpBuffer.length) ? tmpBuffer[] : new wchar[len];
|
||||||
if (len != len2)
|
auto len2 = GetWindowTextW(hwnd, buffer.ptr, cast(int) buffer.length);
|
||||||
throw new Exception("Window title changed while checking");
|
auto str = buffer[0 .. len2];
|
||||||
return cast(string)buffer;
|
return makeUtf8StringFromWindowsString(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void move(int x, int y) {
|
void move(int x, int y) {
|
||||||
|
|
Loading…
Reference in New Issue