Mercurial > projects > dwt-win
diff dwt/internal/win32/OS.d @ 19:ded98545bb1f
Device
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 26 Jan 2008 14:06:27 +0100 |
parents | 1bea9f0c6f63 |
children | f5482da87ed8 |
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d Sat Jan 26 10:22:58 2008 +0100 +++ b/dwt/internal/win32/OS.d Sat Jan 26 14:06:27 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -66,7 +66,7 @@ public static const int VER_PLATFORM_WIN32_WINDOWS = 1; public static const int VER_PLATFORM_WIN32_NT = 2; public static const int VER_PLATFORM_WIN32_CE = 3; - + /* Forward references */ public static const int HEAP_ZERO_MEMORY = 0x8; public static const int ACTCTX_FLAG_RESOURCE_NAME_VALID = 0x00000008; @@ -110,7 +110,7 @@ * and then the ANSI version. The UNICODE version * is present on all versions of Windows but is not * implemented on Win95/98/ME. - * + * * NOTE: The value of OSVERSIONINFO.sizeof cannot * be static final because it relies on the Windows * platform version to be initialized and IsUnicode @@ -139,7 +139,7 @@ IsWinCE = (info.dwPlatformId is VER_PLATFORM_WIN32_CE); IsSP_ = IsSP(); IsPPC_ = IsPPC(); - IsHPC = IsWinCE && !IsPPC && !IsSP; + IsHPC = IsWinCE && !IsPPC && !IsSP; WIN32_MAJOR = info.dwMajorVersion; WIN32_MINOR = info.dwMinorVersion; WIN32_VERSION = VERSION (WIN32_MAJOR, WIN32_MINOR); @@ -156,7 +156,7 @@ int /*long*/ hHeap = OS.GetProcessHeap (); int byteCount = buffer.length () * TCHAR.sizeof; int /*long*/ pszText = OS.HeapAlloc (hHeap, HEAP_ZERO_MEMORY, byteCount); - OS.MoveMemory (pszText, buffer, byteCount); + OS.MoveMemory (pszText, buffer, byteCount); ACTCTX pActCtx = new ACTCTX (); pActCtx.cbSize = ACTCTX.sizeof; pActCtx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_SET_PROCESS_DEFAULT; @@ -173,7 +173,7 @@ */ } } - + /* Make the process DPI aware for Windows Vista */ if (OS.WIN32_VERSION >= OS.VERSION (6, 0)) OS.SetProcessDPIAware (); @@ -181,7 +181,7 @@ BOOL dbcsEnabled = OS.GetSystemMetrics (SM_DBCSENABLED) !is 0; BOOL immEnabled = OS.GetSystemMetrics (SM_IMMENABLED) !is 0; IsDBLocale = dbcsEnabled || immEnabled; - + /* * Bug in Windows. On Korean Windows XP when the Text * Services Framework support for legacy applications @@ -190,7 +190,7 @@ * to move the composition window outside of the client * area, Windows crashes. The fix is to disable legacy * support. - * + * * Note: The bug is fixed in Service Pack 2. */ if (!OS.IsWinCE && OS.WIN32_VERSION is OS.VERSION (5, 1)) { @@ -206,7 +206,7 @@ } } } - + /* Get the COMCTL32.DLL version */ static this() { DLLVERSIONINFO dvi = new DLLVERSIONINFO (); @@ -229,7 +229,7 @@ COMCTL32_MINOR = dvi.dwMinorVersion; COMCTL32_VERSION = VERSION (COMCTL32_MAJOR, COMCTL32_MINOR); } - + /* Get the Shell32.DLL version */ static { DLLVERSIONINFO dvi = new DLLVERSIONINFO (); @@ -257,7 +257,7 @@ static const int SYS_COLOR_INDEX_FLAG = OS.IsWinCE ? 0x40000000 : 0x0; /* - * NOTE: There is a bug in JVM 1.2 where loading + * NOTE: There is a bug in JVM 1.2 where loading * a class with a large number of constants causes * a segment fault to occur sometime later after * the class is loaded. The fix is to break the @@ -324,7 +324,7 @@ public static const int BFFM_VALIDATEFAILED = IsUnicode ? 0x4 : 0x3; public static const int BFFM_VALIDATEFAILEDW = 0x4; public static const int BFFM_VALIDATEFAILEDA = 0x3; - public static const int BF_ADJUST = 0x2000; + public static const int BF_ADJUST = 0x2000; public static const int BF_LEFT = 0x0001; public static const int BF_TOP = 0x0002; public static const int BF_RIGHT = 0x0004; @@ -597,7 +597,7 @@ public static const int DT_VCENTER = 4; public static const int DT_WORDBREAK = 0x10; public static const int DTM_FIRST = 0x1000; - public static const int DTM_GETSYSTEMTIME = DTM_FIRST + 1; + public static const int DTM_GETSYSTEMTIME = DTM_FIRST + 1; public static const int DTM_SETFORMAT = IsUnicode ? DTM_FIRST + 50 : DTM_FIRST + 5; public static const int DTM_SETSYSTEMTIME = DTM_FIRST + 2; public static const int DTN_FIRST = 0xFFFFFD08; @@ -686,7 +686,7 @@ public static const int FCONTROL = 0x8; public static const int FE_FONTSMOOTHINGCLEARTYPE = 0x0002; public static const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21; - public static const int FILE_ATTRIBUTE_NORMAL = 0x00000080; + public static const int FILE_ATTRIBUTE_NORMAL = 0x00000080; public static const int FNERR_INVALIDFILENAME = 0x3002; public static const int FNERR_BUFFERTOOSMALL = 0x3003; public static const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; @@ -935,9 +935,9 @@ public static const int LOCALE_IDATE = 0x00000021; public static const int LOCALE_ITIME = 0x00000023; public static const int LOCALE_RETURN_NUMBER = 0x20000000; // #if(WINVER >= 0x0400) - public static const int LOCALE_S1159 = 0x00000028; - public static const int LOCALE_S2359 = 0x00000029; - public static const int LOCALE_SDECIMAL = 14; + public static const int LOCALE_S1159 = 0x00000028; + public static const int LOCALE_S2359 = 0x00000029; + public static const int LOCALE_SDECIMAL = 14; public static const int LOCALE_SISO3166CTRYNAME = 0x5a; public static const int LOCALE_SISO639LANGNAME = 0x59; public static const int LOCALE_SLONGDATE = 0x00000020; @@ -1109,7 +1109,7 @@ public static const int MCM_GETCURSEL = MCM_FIRST + 1; public static const int MCM_SETCURSEL = MCM_FIRST + 2; public static const int MCN_FIRST = 0xFFFFFD12; - public static const int MCN_SELCHANGE = MCN_FIRST + 1; + public static const int MCN_SELCHANGE = MCN_FIRST + 1; public static const int MCM_GETMINREQRECT = MCM_FIRST + 9; public static const int MCS_NOTODAY = 0x0010; public static const int MDIS_ALLCHILDSTYLES = 0x0001; @@ -1118,7 +1118,7 @@ public static const int MFS_GRAYED = 0x3; public static const int MFT_RADIOCHECK = 0x200; public static const int MFT_RIGHTJUSTIFY = 0x4000; - public static const int MFT_RIGHTORDER = 0x2000; + public static const int MFT_RIGHTORDER = 0x2000; public static const int MFT_SEPARATOR = 0x800; public static const int MFT_STRING = 0x0; public static const int MF_BYCOMMAND = 0x0; @@ -1155,12 +1155,12 @@ public static const int MONITORINFOF_PRIMARY = 0x1; public static const char[] MONTHCAL_CLASS = "SysMonthCal32"; //$NON-NLS-1$ public static const int MOUSEEVENTF_ABSOLUTE = 0x8000; - public static const int MOUSEEVENTF_LEFTDOWN = 0x0002; - public static const int MOUSEEVENTF_LEFTUP = 0x0004; - public static const int MOUSEEVENTF_MIDDLEDOWN = 0x0020; - public static const int MOUSEEVENTF_MIDDLEUP = 0x0040; + public static const int MOUSEEVENTF_LEFTDOWN = 0x0002; + public static const int MOUSEEVENTF_LEFTUP = 0x0004; + public static const int MOUSEEVENTF_MIDDLEDOWN = 0x0020; + public static const int MOUSEEVENTF_MIDDLEUP = 0x0040; public static const int MOUSEEVENTF_MOVE = 0x0001; - public static const int MOUSEEVENTF_RIGHTDOWN = 0x0008; + public static const int MOUSEEVENTF_RIGHTDOWN = 0x0008; public static const int MOUSEEVENTF_RIGHTUP = 0x0010; public static const int MOUSEEVENTF_VIRTUALDESK = 0x4000; public static const int MOUSEEVENTF_WHEEL = 0x0800; @@ -1253,7 +1253,7 @@ public static const int PBS_VERTICAL = 0x4; public static const int PBS_NORMAL = 1; public static const int PBS_HOT = 2; - public static const int PBS_PRESSED = 3; + public static const int PBS_PRESSED = 3; public static const int PBS_DISABLED = 4; public static const int PBS_DEFAULTED = 5; public static const int PBST_NORMAL = 0x0001; @@ -1570,7 +1570,7 @@ public static const int TBSTYLE_DROPDOWN = 0x8; public static const int TBSTATE_ENABLED = 0x4; public static const int TBSTYLE_AUTOSIZE = 0x10; - public static const int TBSTYLE_EX_DOUBLEBUFFER = 0x80; + public static const int TBSTYLE_EX_DOUBLEBUFFER = 0x80; public static const int TBSTYLE_EX_DRAWDDARROWS = 0x1; public static const int TBSTYLE_EX_HIDECLIPPEDBUTTONS = 0x10; public static const int TBSTYLE_EX_MIXEDBUTTONS = 0x8; @@ -1713,7 +1713,7 @@ public static const int TTM_DELTOOL = IsUnicode ? 0x433 : 0x405; public static const int TTM_GETTOOLINFO = 0x400 + (IsUnicode ? 53 : 8); public static const int TTM_NEWTOOLRECT = 0x400 + (IsUnicode ? 52 : 6); - public static const int TTM_POP = 0x400 + 28; + public static const int TTM_POP = 0x400 + 28; public static const int TTM_SETDELAYTIME = 0x400 + 3; public static const int TTM_SETMAXTIPWIDTH = 0x418; public static const int TTM_SETTITLEA = 0x400 + 32; @@ -1949,7 +1949,7 @@ public static const int WM_COMMAND = 0x111; public static const int WM_CONTEXTMENU = 0x7b; public static const int WM_COPY = 0x301; - public static const int WM_CREATE = 0x0001; + public static const int WM_CREATE = 0x0001; public static const int WM_CTLCOLORBTN = 0x135; public static const int WM_CTLCOLORDLG = 0x136; public static const int WM_CTLCOLOREDIT = 0x133; @@ -2079,7 +2079,7 @@ public static const int WM_XBUTTONDBLCLK = 0x020D; public static const int XBUTTON1 = 0x1; public static const int XBUTTON2 = 0x2; - + //PORTING_LEFT /++ @@ -2278,7 +2278,7 @@ if (IsUnicode) { char [] lpClassName1 = lpClassName is null ? null : lpClassName.chars; char [] lpWindowName1 = lpWindowName is null ? null : lpWindowName.chars; - return FindWindowW (lpClassName1, lpWindowName1); + return FindWindowW (lpClassName1, lpWindowName1); } byte [] lpClassName1 = lpClassName is null ? null : lpClassName.bytes; byte [] lpWindowName1 = lpWindowName is null ? null : lpWindowName.bytes; @@ -2287,7 +2287,7 @@ public static final int FormatMessage (int dwFlags, int /*long*/ lpSource, int dwMessageId, int dwLanguageId, int[] lpBuffer, int nSize, int /*long*/ Arguments) { if (IsUnicode) { - return FormatMessageW (dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments); + return FormatMessageW (dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments); } return FormatMessageA (dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments); } @@ -2303,7 +2303,7 @@ return GetCharacterPlacementW (hdc, lpString1, nCount, nMaxExtent, lpResults, dwFlags); } byte [] lpString1 = lpString is null ? null : lpString.bytes; - return GetCharacterPlacementA (hdc, lpString1, nCount, nMaxExtent, lpResults, dwFlags); + return GetCharacterPlacementA (hdc, lpString1, nCount, nMaxExtent, lpResults, dwFlags); } public static final BOOL GetCharWidth (int /*long*/ hdc, int iFirstChar, int iLastChar, int [] lpabc) { @@ -2479,7 +2479,7 @@ return GetTextExtentPoint32W (hdc, lpString1, cbString, lpSize); } byte [] lpString1 = lpString is null ? null : lpString.bytes; - return GetTextExtentPoint32A (hdc, lpString1, cbString, lpSize); + return GetTextExtentPoint32A (hdc, lpString1, cbString, lpSize); } public static final BOOL GetTextMetrics (int /*long*/ hdc, TEXTMETRIC lptm) { @@ -2566,7 +2566,7 @@ return InsertMenuW (hMenu, uPosition, uFlags, uIDNewItem, lpNewItem1); } byte [] lpNewItem1 = lpNewItem is null ? null : lpNewItem.bytes; - return InsertMenuA (hMenu, uPosition, uFlags, uIDNewItem, lpNewItem1); + return InsertMenuA (hMenu, uPosition, uFlags, uIDNewItem, lpNewItem1); } public static final BOOL InsertMenuItem (int /*long*/ hMenu, int uItem, BOOL fByPosition, MENUITEMINFO lpmii) { @@ -3085,7 +3085,7 @@ public static final native short CharLowerA (short ch); public static final native short CharUpperW (short ch); public static final native short CharUpperA (short ch); -public static final native BOOL CheckMenuItem (int /*long*/ hmenu, int uIDCheckItem, int uCheck); +public static final native BOOL CheckMenuItem (int /*long*/ hmenu, int uIDCheckItem, int uCheck); public static final native BOOL ChooseColorW (CHOOSECOLOR lpcc); public static final native BOOL ChooseColorA (CHOOSECOLOR lpcc); public static final native BOOL ChooseFontW (CHOOSEFONT chooseFont); @@ -3107,7 +3107,7 @@ public static final native BOOL CommandBar_Show (int /*long*/ hwndCB, BOOL fShow); public static final native int CommDlgExtendedError (); public static final native int /*long*/ CopyImage (int /*long*/ hImage, int uType, int cxDesired, int cyDesired, int fuFlags); -public static final native int /*long*/ CreateAcceleratorTableW (byte [] lpaccl, int cEntries); +public static final native int /*long*/ CreateAcceleratorTableW (byte [] lpaccl, int cEntries); public static final native int /*long*/ CreateAcceleratorTableA (byte [] lpaccl, int cEntries); public static final native int /*long*/ CreateActCtxW (ACTCTX pActCtx); public static final native int /*long*/ CreateActCtxA (ACTCTX pActCtx); @@ -3116,8 +3116,8 @@ public static final native int /*long*/ CreateCompatibleBitmap (int /*long*/ hdc, int nWidth, int nHeight); public static final native int /*long*/ CreateCompatibleDC (int /*long*/ hdc); public static final native int /*long*/ CreateCursor (int /*long*/ hInst, int xHotSpot, int yHotSpot, int nWidth, int nHeight, byte [] pvANDPlane, byte [] pvXORPlane); -public static final native int /*long*/ CreateDCW (char [] lpszDriver, char [] lpszDevice, int /*long*/ lpszOutput, int /*long*/ lpInitData); -public static final native int /*long*/ CreateDCA (byte [] lpszDriver, byte [] lpszDevice, int /*long*/ lpszOutput, int /*long*/ lpInitData); +public static final native int /*long*/ CreateDCW (char [] lpszDriver, char [] lpszDevice, int /*long*/ lpszOutput, int /*long*/ lpInitData); +public static final native int /*long*/ CreateDCA (byte [] lpszDriver, byte [] lpszDevice, int /*long*/ lpszOutput, int /*long*/ lpInitData); public static final native int /*long*/ CreateDIBSection(int /*long*/ hdc, byte[] pbmi, int iUsage, int /*long*/[] ppvBits, int /*long*/ hSection, int dwOffset); public static final native int /*long*/ CreateFontIndirectW (int /*long*/ lplf); public static final native int /*long*/ CreateFontIndirectA (int /*long*/ lplf); @@ -3174,7 +3174,7 @@ public static final native int DrawThemeIcon (int /*long*/ hTheme, int /*long*/ hdc, int iPartId, int iStateId, RECT pRect, int /*long*/ himl, int iImageIndex); public static final native int DrawThemeParentBackground (int /*long*/ hwnd, int /*long*/ hdc, RECT prc); public static final native int DrawThemeText (int /*long*/ hTheme, int /*long*/ hdc, int iPartId, int iStateId, char[] pszText, int iCharCount, int dwTextFlags, int dwTextFlags2, RECT pRect); -public static final native int DwmExtendFrameIntoClientArea (int /*long*/ hWnd, MARGINS pMarInset); +public static final native int DwmExtendFrameIntoClientArea (int /*long*/ hWnd, MARGINS pMarInset); public static final native BOOL Ellipse (int /*long*/ hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect); public static final native BOOL EnableMenuItem (int /*long*/ hMenu, int uIDEnableItem, int uEnable); public static final native BOOL EnableScrollBar (int /*long*/ hWnd, int wSBflags, int wArrows); @@ -3403,7 +3403,7 @@ public static final native void ImageList_EndDrag (); public static final native int /*long*/ ImageList_GetDragImage (POINT ppt, POINT pptHotspot); public static final native int /*long*/ ImageList_GetIcon (int /*long*/ himl, int i, int flags); -public static final native BOOL ImageList_GetIconSize (int /*long*/ himl, int [] cx, int [] cy); +public static final native BOOL ImageList_GetIconSize (int /*long*/ himl, int [] cx, int [] cy); public static final native int ImageList_GetImageCount (int /*long*/ himl); public static final native BOOL ImageList_Remove (int /*long*/ himl, int i); public static final native BOOL ImageList_Replace (int /*long*/ himl, int i, int /*long*/ hbmImage, int /*long*/ hbmMask); @@ -3591,8 +3591,8 @@ public static final native int RegisterClassA (WNDCLASS lpWndClass); public static final native int RegisterWindowMessageW (char [] lpString); public static final native int RegisterWindowMessageA (byte [] lpString); -public static final native int RegisterClipboardFormatA (byte[] lpszFormat); -public static final native int RegisterClipboardFormatW (char[] lpszFormat); +public static final native int RegisterClipboardFormatA (byte[] lpszFormat); +public static final native int RegisterClipboardFormatW (char[] lpszFormat); public static final native int RegOpenKeyExW (int /*long*/ hKey, char[] lpSubKey, int ulOptions, int samDesired, int /*long*/[] phkResult); public static final native int RegOpenKeyExA (int /*long*/ hKey, byte[] lpSubKey, int ulOptions, int samDesired, int /*long*/[] phkResult); public static final native int RegQueryInfoKeyW (int /*long*/ hKey, int /*long*/ lpClass, int[] lpcbClass, int /*long*/ lpReserved, int[] lpSubKeys, int[] lpcbMaxSubKeyLen, int[] lpcbMaxClassLen, int[] lpcValues, int[] lpcbMaxValueNameLen, int[] lpcbMaxValueLen, int[] lpcbSecurityDescriptor, int /*long*/ lpftLastWriteTime); @@ -3812,6 +3812,7 @@ /** Ansi/Unicode wrappers */ // Unicode/Ansi alias version(ANSI) { + alias WINAPI.AddFontResourceExA AddFontResourceEx; alias WINAPI.CallWindowProcA CallWindowProc; alias WINAPI.CharLowerA CharLower; alias WINAPI.CharUpperA CharUpper; @@ -3903,6 +3904,7 @@ alias WINAPI.UnregisterClassA UnregisterClass; alias WINAPI.VkKeyScanA VkKeyScan; }else{ + alias WINAPI.AddFontResourceExW AddFontResourceEx; alias WINAPI.CallWindowProcW CallWindowProc; alias WINAPI.CharLowerW CharLower; alias WINAPI.CharUpperW CharUpper; @@ -3994,12 +3996,12 @@ alias WINAPI.UnregisterClassW UnregisterClass; alias WINAPI.VkKeyScanW VkKeyScan; } - - - - - - + + + + + + /** All Natives */ alias WINAPI.AbortDoc AbortDoc; alias WINAPI.ActivateKeyboardLayout ActivateKeyboardLayout; @@ -4350,7 +4352,7 @@ alias WINAPI.RealizePalette RealizePalette; alias WINAPI.RectInRegion RectInRegion; // <Shawn> Renamed : may conflict with dwt.graphics.rectangle.Rectangle -alias WINAPI.Rectangle _Rectangle; +alias WINAPI.Rectangle _Rectangle; alias WINAPI.RedrawWindow RedrawWindow; alias WINAPI.RegCloseKey RegCloseKey; alias WINAPI.RegEnumKeyExA RegEnumKeyExA; @@ -4511,11 +4513,11 @@ TCHAR[] buffer = new TCHAR[nSize]; int result = _GetProfileString(.StrToTCHARz(lpAppName), .StrToTCHARz(lpKeyName), .StrToTCHARz(lpDefault), buffer.ptr, nSize); lpReturnedString = .TCHARzToStr(buffer.ptr); - return result; + return result; } static char[] GetWindowText(HWND hwnd){ - assert(hwnd); + assert(hwnd); int len = GetWindowTextLength(hwnd); if(len > 0){ TCHAR[] buffer = new TCHAR[len + 1]; @@ -4531,11 +4533,11 @@ return _GetWindowText(hWnd, lpString, nMaxCount); } -// <Shawn Liu> added this method, copied from ATL : atlwin.h +// <Shawn Liu> added this method, copied from ATL : atlwin.h static int CenterWindow(HWND m_hWnd, HWND hWndCenter = null) { assert(m_hWnd); - + // determine owner window to center against uint dwStyle = OS.GetWindowLong(m_hWnd, OS.GWL_STYLE); if(hWndCenter is null) @@ -4554,7 +4556,7 @@ HWND hWndParent; if(!(dwStyle & OS.WS_CHILD)) { - // don't center against invisible or minimized WINAPI + // don't center against invisible or minimized WINAPI if(hWndCenter !is null) { uint dwStyleCenter = OS.GetWindowLong(hWndCenter, OS.GWL_STYLE); @@ -4601,7 +4603,7 @@ // map screen coordinates to child coordinates return OS.SetWindowPos(m_hWnd, null, xLeft, yTop, -1, -1, - OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE); + OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE); } static int OleInitialize(LPVOID reserved = null){ @@ -4614,7 +4616,7 @@ } // END of OS -private import tango.sys.win32.CodePage; +private import tango_sys_win32.CodePage; private import tango.text.convert.Utf; private import tango.stdc.stringz; @@ -4625,7 +4627,7 @@ try{ foreach (char c; sc){ if (c >= 0x80) - { + { char[] result; int i; wchar[] ws = .toString16(sc); @@ -4651,7 +4653,7 @@ } char[] dst; dst.length = sc.length; - return toStringz( tango.sys.win32.CodePage.CodePage.into( sc, dst )); + return toStringz( tango_sys_win32.CodePage.CodePage.into( sc, dst )); }catch(Exception e){ // do nothing ret = ""; @@ -4666,7 +4668,7 @@ ret = toString16(sc); }catch(Exception e){ // do nothing - ret = ""; + ret = ""; } return ret; @@ -4685,16 +4687,16 @@ if(_length == -1){ _length = 0; while(*(pString + _length)) - ++_length; + ++_length; } // convert MBCS to UTF-8 if(_length == 0) return null; - + wchar[] wcs = _mbcszToWs(pString, _length, codepage); char[] result; try{ - result = .toString(wcs); + result = .toString(wcs); }catch(Exception e){ } return result; @@ -4710,13 +4712,13 @@ if(_length == -1){ _length = 0; while(*(pString + _length)) - ++_length; + ++_length; } if(_length == 0) return null; // convert wchar* to UTF-8 wchar[] wcs = pString[0.._length]; - + char[] result; try{ result = .toString(wcs); @@ -4726,16 +4728,16 @@ return result; } -/** +/** * <Shawn> difference between WCHARzToStr(pwstr, -1) : - * BSTRToStr() internally call WCHARzToStr(pwstr, length) with length set, - * instead to determine the null ended, this mean BSTRToStr() can get string + * BSTRToStr() internally call WCHARzToStr(pwstr, length) with length set, + * instead to determine the null ended, this mean BSTRToStr() can get string * which has embedded null characters. */ version(OLE_COM) -{ -// BSTR is aliased to wchar* +{ +// BSTR is aliased to wchar* // Note : Free the "bstr" memory if freeTheString is true, default false static char[] BSTRToStr(/*BSTR*/ inout wchar* bstr, bool freeTheString = false){ if(bstr is null) return null; @@ -4754,24 +4756,24 @@ public static wchar[] _mbcszToWs(char* pMBCS, int len, uint codepage = 0) { wchar[] wbuf; - // Convert MBCS to unicode + // Convert MBCS to unicode wbuf.length = OS.MultiByteToWideChar(codepage, 0, pMBCS, len, null, 0); int n = OS.MultiByteToWideChar(codepage, 0, pMBCS, len, wbuf.ptr, wbuf.length); assert(n == wbuf.length); return wbuf; -} +} // static methods public int _tcslen(TCHAR* pString){ int _length = 0; while(*(pString + _length)) - ++_length; - - return _length; + ++_length; + + return _length; } /** - * There is a bug in Phobos std.string.toupper() to lower() with + * There is a bug in Phobos std.string.toupper() to lower() with std.string.toupper() and std.string.tolower() give a wrong result when deal with a mixture of upper/lower English and Chinese characters. e.g. char[] a = "AbCd中文eFgH"; char[] b = std.string.toupper(a); @@ -4789,7 +4791,7 @@ TCHAR* ps2 = OS.CharUpper(ps); return TCHARzToStr(ps2); } - + version(ANSI){ alias StrToMBCS StrToTCHARs; alias StrToMBCSz StrToTCHARz;