Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  1. #include "stdafx.h"
  2. #pragma hdrstop
  3. #if defined(UNICODE) && defined(ALLOW_WIN98)
  4. /* ***** BEGIN LICENSE BLOCK *****
  5.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6.  *
  7.  * The contents of this file are subject to the Mozilla Public License Version
  8.  * 1.1 (the "License"); you may not use this file except in compliance with
  9.  * the License. You may obtain a copy of the License at
  10.  * http://www.mozilla.org/MPL/
  11.  *
  12.  * Software distributed under the License is distributed on an "AS IS" basis,
  13.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14.  * for the specific language governing rights and limitations under the
  15.  * License.
  16.  *
  17.  * The Original Code is for Open Layer for Unicode (opencow).
  18.  *
  19.  * The Initial Developer of the Original Code is Brodie Thiesfield.
  20.  * Portions created by the Initial Developer are Copyright (C) 2004
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38. /************************************************************************
  39.  Copyright (C) 2009, 2010  by Russell J. Peters, Roger Aelbrecht
  40.  
  41.    This file is part of TZipMaster Version 1.9.
  42.  
  43.     TZipMaster is free software: you can redistribute it and/or modify
  44.     it under the terms of the GNU Lesser General Public License as published by
  45.     the Free Software Foundation, either version 3 of the License, or
  46.     (at your option) any later version.
  47.  
  48.     TZipMaster is distributed in the hope that it will be useful,
  49.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  50.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  51.     GNU Lesser General Public License for more details.
  52.  
  53.     You should have received a copy of the GNU Lesser General Public License
  54.     along with TZipMaster.  If not, see <http://www.gnu.org/licenses/>.
  55.  
  56.     contact: problems@delphizip.org (include ZipMaster in the subject).
  57.     updates: http://www.delphizip.org
  58.     DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
  59. ************************************************************************/
  60.  
  61. // define these symbols so that we don't get dllimport linkage
  62. // from the system headers
  63. #define _USER32_
  64.  
  65. //#include <windows.h>
  66. #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x0570)
  67. #include <crtdbg.h>
  68. #endif
  69.  
  70. #include "MbcsBuffer.h"
  71.  
  72. // ----------------------------------------------------------------------------
  73. // API
  74.  
  75. // AppendMenuW
  76. // BroadcastSystemMessageW
  77. // CallMsgFilterW
  78. // CallWindowProcA
  79. #if 0
  80. LRESULT WINAPI
  81. CallWindowProcW(
  82.     IN WNDPROC lpPrevWndFunc,
  83.     IN HWND hWnd,
  84.     IN UINT Msg,
  85.     IN WPARAM wParam,
  86.     IN LPARAM lParam
  87.     )
  88. {
  89.     //TODO: is this sufficient?                                      
  90. #ifdef __BORLANDC__             /* Borland C++ */
  91.     return ::CallWindowProcA((int(__stdcall*)())lpPrevWndFunc, hWnd, Msg, wParam, lParam);
  92. #else
  93.     return ::CallWindowProcA(lpPrevWndFunc, hWnd, Msg, wParam, lParam);
  94. #endif
  95. }
  96.  
  97. // ChangeDisplaySettingsExW
  98. // ChangeDisplaySettingsW
  99. // ChangeMenuW
  100.  
  101. DWORD
  102. WINAPI
  103. CharLowerBuffW(
  104.     IN OUT LPWSTR lpsz,
  105.     IN DWORD cchLength
  106.     )
  107. {
  108.     wchar_t c;
  109.     for (DWORD dwCount = 0; dwCount < cchLength; ++dwCount) {
  110.         c = lpsz[dwCount];
  111.         if (c >= 'A' && c <= 'Z')
  112.             lpsz[dwCount] = (unsigned short) ((c - 'A') + 'a');
  113.     }
  114.     return cchLength;
  115. }
  116. #endif
  117. //#if defined(__BORLANDC__) && (__BORLANDC__ < 0x0550)
  118. extern "C" LPWSTR WINAPI
  119. zCharLowerW(
  120.     IN OUT LPWSTR lpsz
  121.     )
  122. {
  123.     if (HIWORD(lpsz) == 0) {
  124.         wchar_t c = LOWORD(lpsz);
  125.         if (c >= 'A' && c <= 'Z')
  126.             c = (unsigned short) ((c - 'A') + 'a');
  127.         return (LPWSTR) c;
  128.     }
  129.     else {
  130.         wchar_t c;
  131.         for (wchar_t *pTemp = lpsz; *pTemp; ++pTemp) {
  132.             c = *pTemp;
  133.             if (c >= 'A' && c <= 'Z')
  134.                 *pTemp = (unsigned short) ((c - 'A') + 'a');
  135.         }
  136.         return lpsz;
  137.     }
  138. }
  139. //#endif
  140. #if 0
  141. LPWSTR WINAPI
  142. CharNextW(
  143.     IN LPCWSTR lpsz
  144.     )
  145. {
  146.     if (*lpsz)
  147.         ++lpsz;
  148.     return const_cast<LPWSTR>(lpsz);
  149. }
  150.  
  151. LPWSTR WINAPI
  152. CharPrevW(
  153.     IN LPCWSTR lpszStart,
  154.     IN LPCWSTR lpszCurrent
  155.     )
  156. {
  157.     if (lpszStart < lpszCurrent)
  158.         --lpszCurrent;
  159.     return const_cast<LPWSTR>(lpszCurrent);
  160. }
  161. #endif
  162. // CharToOemBuffW
  163.  
  164. // CharToOemW
  165. extern "C" BOOL WINAPI
  166. zCharToOemW(
  167.     IN  LPCWSTR lpszSrc,
  168.     IN  LPSTR lpszDst
  169. )
  170. {
  171.     CMbcsBuffer mbcsSrc;
  172.     if (!mbcsSrc.FromUnicode(lpszSrc))
  173.         return false;
  174.  
  175.     return ::CharToOemA(mbcsSrc, lpszDst);
  176. }
  177.  
  178. extern "C" DWORD WINAPI
  179. zCharUpperBuffW(
  180.     IN OUT LPWSTR lpsz,
  181.     IN DWORD cchLength
  182.     )
  183. {
  184.     wchar_t c;
  185.     for (DWORD dwCount = 0; dwCount < cchLength; ++dwCount) {
  186.         c = lpsz[dwCount];
  187.         if (c >= 'a' && c <= 'z')
  188.             lpsz[dwCount] = (unsigned short) ((c - 'a') + 'Z');
  189.     }
  190.     return cchLength;
  191. }
  192.    
  193. //#if defined(__BORLANDC__) && (__BORLANDC__ < 0x0550)
  194. extern "C" LPWSTR WINAPI
  195. zCharUpperW(
  196.     IN OUT LPWSTR lpsz
  197.     )
  198. {
  199.     if (HIWORD(lpsz) == 0) {
  200.         wchar_t c = LOWORD(lpsz);
  201.         if (c >= 'a' && c <= 'z')
  202.             c = (unsigned short) ((c - 'a') + 'A');
  203.         return (LPWSTR) c;
  204.     }
  205.     else {
  206.         wchar_t c;
  207.         for (wchar_t *pTemp = lpsz; *pTemp; ++pTemp) {
  208.             c = *pTemp;
  209.             if (c >= 'a' && c <= 'z')
  210.                 *pTemp = (unsigned short) ((c - 'a') + 'A');
  211.         }
  212.         return lpsz;
  213.     }
  214. }
  215. //#endif
  216. #if 0
  217. // CopyAcceleratorTableW
  218. // CreateAcceleratorTableW
  219. // CreateDialogIndirectParamW
  220. // CreateDialogParamW
  221. // CreateMDIWindowW
  222.  
  223. HWND WINAPI
  224. CreateWindowExW(
  225.     IN DWORD dwExStyle,
  226.     IN LPCWSTR lpClassName,
  227.     IN LPCWSTR lpWindowName,
  228.     IN DWORD dwStyle,
  229.     IN int X,
  230.     IN int Y,
  231.     IN int nWidth,
  232.     IN int nHeight,
  233.     IN HWND hWndParent,
  234.     IN HMENU hMenu,
  235.     IN HINSTANCE hInstance,
  236.     IN LPVOID lpParam
  237.     )
  238. {
  239.     // class name is only a string if the HIWORD is not 0
  240.     CMbcsBuffer mbcsClassName;
  241.     LPCSTR pmbcsClassName = (LPCSTR) lpClassName;
  242.     if (HIWORD(lpClassName) != 0) {
  243.         if (!mbcsClassName.FromUnicode(lpClassName))
  244.             return NULL;
  245.         pmbcsClassName = mbcsClassName;
  246.     }
  247.  
  248.     CMbcsBuffer mbcsWindowName;
  249.     if (!mbcsWindowName.FromUnicode(lpWindowName))
  250.         return NULL;
  251.  
  252.     return ::CreateWindowExA(dwExStyle, pmbcsClassName, mbcsWindowName,
  253.         dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
  254. }
  255.  
  256. // DdeConnect
  257. // DdeConnectList
  258. // DdeCreateStringHandleW
  259. // DdeInitializeW
  260. // DdeQueryConvInfo
  261. // DdeQueryStringW
  262. // DefDlgProcW
  263. // DefFrameProcW
  264. // DefMDIChildProcW
  265.  
  266. LRESULT WINAPI
  267. DefWindowProcW(
  268.     IN HWND hWnd,
  269.     IN UINT Msg,
  270.     IN WPARAM wParam,
  271.     IN LPARAM lParam
  272.     )
  273. {
  274.     //TODO: is this sufficient?
  275.     return ::DefWindowProcA(hWnd, Msg, wParam, lParam);
  276. }
  277.  
  278. // DialogBoxIndirectParamW
  279. // DialogBoxParamW
  280.  
  281. LRESULT WINAPI
  282. DispatchMessageW(
  283.     IN CONST MSG *lpMsg
  284.     )
  285. {
  286.     //TODO: is this sufficient?
  287.     return ::DispatchMessageA(lpMsg);
  288. }
  289.  
  290. // DlgDirListComboBoxW
  291. // DlgDirListW
  292. // DlgDirSelectComboBoxExW
  293. // DlgDirSelectExW
  294. // DrawStateW
  295. // DrawTextExW
  296. // DrawTextW
  297. // EnableWindow
  298. // EnumClipboardFormats
  299. // EnumDisplayDevicesW
  300. // EnumDisplaySettingsExW
  301. // EnumDisplaySettingsW
  302. // EnumPropsA
  303. // EnumPropsExA
  304. // EnumPropsExW
  305. // EnumPropsW
  306. // FindWindowExW
  307. // FindWindowW
  308. // GetAltTabInfoW
  309. // GetClassInfoExW
  310. // GetClassInfoW
  311. // GetClassLongW
  312.  
  313. int WINAPI
  314. GetClassNameW(
  315.     IN HWND hWnd,
  316.     OUT LPWSTR lpClassName,
  317.     IN int nMaxCount
  318.     )
  319. {
  320.     CMbcsBuffer mbcsClassName;
  321.     if (!mbcsClassName.SetCapacity(nMaxCount*2))
  322.         return 0;
  323.  
  324.     int nLen = ::GetClassNameA(hWnd, mbcsClassName, mbcsClassName.BufferSize());
  325.     if (nLen < 1)
  326.         return nLen;
  327.  
  328.     // truncate the returned string into the output buffer
  329.     ++nLen;
  330.     int nResult;
  331.     do {
  332.         nResult = ::MultiByteToWideChar(CP_ACP, 0, mbcsClassName, nLen--, lpClassName, nMaxCount);
  333.     }
  334.     while (nLen > 0 && nResult == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
  335.  
  336.     return nResult;
  337. }
  338.  
  339. // GetClipboardData
  340.  
  341. int WINAPI
  342. GetClipboardFormatNameW(
  343.     IN UINT format,
  344.     OUT LPWSTR lpszFormatName,
  345.     IN int cchMaxCount
  346.     )
  347. {
  348.     CMbcsBuffer mbcsFormatName;
  349.     if (!mbcsFormatName.SetCapacity(cchMaxCount))
  350.         return 0;
  351.  
  352.     int nLen = ::GetClipboardFormatNameA(format, mbcsFormatName, mbcsFormatName.BufferSize());
  353.     if (nLen < 1)
  354.         return nLen;
  355.  
  356.     // truncate the returned string into the output buffer
  357.     ++nLen;
  358.     int nResult;
  359.     do {
  360.         nResult = ::MultiByteToWideChar(CP_ACP, 0, mbcsFormatName, nLen--, lpszFormatName, cchMaxCount);
  361.     }
  362.     while (nLen > 0 && nResult == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
  363.  
  364.     return nResult;
  365. }
  366.  
  367. // GetDlgItemTextW
  368. // GetKeyNameTextW
  369. // GetKeyboardLayoutNameW
  370. // GetMenuItemInfoW
  371. // GetMenuStringW
  372.  
  373. BOOL WINAPI
  374. GetMessageW(
  375.     OUT LPMSG lpMsg,
  376.     IN HWND hWnd,
  377.     IN UINT wMsgFilterMin,
  378.     IN UINT wMsgFilterMax
  379.     )
  380. {
  381.     //TODO: is this sufficient?
  382.     return ::GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);
  383. }
  384. #endif
  385.  
  386. // GetMonitorInfoW
  387. // GetPropA
  388. // GetPropW
  389. // GetTabbedTextExtentW
  390. // GetWindowLongA
  391. // GetWindowLongW
  392. // GetWindowModuleFileNameW
  393. // GetWindowTextLengthW
  394. // GetWindowTextW
  395. // GrayStringW
  396. // InsertMenuItemW
  397. // InsertMenuW
  398. // IsCharAlphaNumericW
  399. // IsCharAlphaW
  400. // IsCharLowerW
  401. // IsCharUpperW
  402. // IsClipboardFormatAvailable
  403. // IsDialogMessageW
  404. // IsWindowUnicode
  405. // LoadAcceleratorsW
  406. // LoadBitmapW
  407. // LoadCursorFromFileW
  408. // LoadCursorW
  409. // LoadIconW
  410. // LoadImageW
  411. // LoadKeyboardLayoutW
  412. // LoadMenuIndirectW
  413. // LoadMenuW
  414.  
  415. // LoadStringW
  416. extern "C" int WINAPI
  417. zLoadStringW(
  418.     IN  HINSTANCE hInstance,
  419.     IN  UINT uID,
  420.     IN  LPWSTR lpBuffer,
  421.     IN  int nBufferMax
  422. )
  423. {
  424.  
  425.     CMbcsBuffer mbcsBuffer;
  426.     if (!mbcsBuffer.SetCapacity(nBufferMax))
  427.         return 0;
  428.  
  429.     int nLen = ::LoadStringA(hInstance, uID, mbcsBuffer, mbcsBuffer.BufferSize());
  430.     if (nLen < 1)
  431.         return nLen;
  432.  
  433.     // truncate the returned string into the output buffer
  434.     ++nLen;
  435.     int nResult;
  436.     do {
  437.         nResult = ::MultiByteToWideChar(CP_ACP, 0, mbcsBuffer, nLen--, lpBuffer, nBufferMax);
  438.     }
  439.     while (nLen > 0 && nResult == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
  440.  
  441.     return nResult;
  442. }
  443.  
  444. // MapVirtualKeyExW
  445. // MapVirtualKeyW
  446. #if 0
  447. int WINAPI
  448. MessageBoxExW(
  449.     IN HWND hWnd,
  450.     IN LPCWSTR lpText,
  451.     IN LPCWSTR lpCaption,
  452.     IN UINT uType,
  453.     IN WORD wLanguageId
  454.     )
  455. {
  456.     CMbcsBuffer mbcsText;
  457.     if (!mbcsText.FromUnicode(lpText))
  458.         return 0;
  459.  
  460.     CMbcsBuffer mbcsCaption;
  461.     if (!mbcsCaption.FromUnicode(lpCaption))
  462.         return 0;
  463.  
  464.     return ::MessageBoxExA(hWnd, mbcsText, mbcsCaption, uType, wLanguageId);
  465. }
  466. #endif
  467. // MessageBoxIndirectW
  468.  
  469. extern "C" int WINAPI
  470. zMessageBoxW(
  471.     IN HWND hWnd,
  472.     IN LPCWSTR lpText,
  473.     IN LPCWSTR lpCaption,
  474.     IN UINT uType
  475.     )
  476. {
  477.     CMbcsBuffer mbcsText;
  478.     if (!mbcsText.FromUnicode(lpText))
  479.         return 0;
  480.  
  481.     CMbcsBuffer mbcsCaption;
  482.     if (!mbcsCaption.FromUnicode(lpCaption))
  483.         return 0;
  484.  
  485.     return ::MessageBoxA(hWnd, mbcsText, mbcsCaption, uType);
  486. }
  487.  
  488. // ModifyMenuW
  489. // OemToCharBuffW
  490.  
  491. // OemToCharW
  492. extern "C" BOOL WINAPI
  493. zOemToCharW(
  494.     IN  LPCSTR lpszSrc,
  495.     IN  LPWSTR lpszDst
  496. )
  497. {
  498.     int MaxLen = lstrlenA(lpszSrc);
  499.     CMbcsBuffer mbcsDst;
  500.     if (!mbcsDst.SetCapacity(MaxLen))
  501.         return 0;
  502.  
  503.     BOOL result = ::OemToCharA(lpszSrc, mbcsDst);
  504.     if (!result)
  505.         return false;
  506. //    return mbcsDst.ToUnicode(lpszDst, MaxLen) > 0;
  507.     return ::MultiByteToWideChar(CP_ACP, 0, mbcsDst, -1, lpszDst, MaxLen) > 0;
  508. }
  509.  
  510. #if 0
  511. BOOL WINAPI
  512. PeekMessageW(
  513.     OUT LPMSG lpMsg,
  514.     IN HWND hWnd,
  515.     IN UINT wMsgFilterMin,
  516.     IN UINT wMsgFilterMax,
  517.     IN UINT wRemoveMsg
  518.     )
  519. {
  520.     //TODO: is this sufficient?
  521.     return ::PeekMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
  522. }
  523.  
  524. // PostMessageW
  525. // PostThreadMessageW
  526. // RegisterClassExW
  527.  
  528. ATOM WINAPI
  529. RegisterClassW(
  530.     IN CONST WNDCLASSW *lpWndClass
  531.     )
  532. {
  533.     WNDCLASSA wndClassA;
  534.     ::ZeroMemory(&wndClassA, sizeof(wndClassA));
  535.  
  536.     wndClassA.style         = lpWndClass->style;
  537.     wndClassA.lpfnWndProc   = lpWndClass->lpfnWndProc;
  538.     wndClassA.cbClsExtra    = lpWndClass->cbClsExtra;
  539.     wndClassA.cbWndExtra    = lpWndClass->cbWndExtra;
  540.     wndClassA.hInstance     = lpWndClass->hInstance;
  541.     wndClassA.hIcon         = lpWndClass->hIcon;
  542.     wndClassA.hCursor       = lpWndClass->hCursor;
  543.     wndClassA.hbrBackground = lpWndClass->hbrBackground;
  544.  
  545.     CMbcsBuffer mbcsMenuName;
  546.     if (lpWndClass->lpszMenuName) {
  547.         if (!mbcsMenuName.FromUnicode(lpWndClass->lpszMenuName))
  548.             return 0;
  549.         wndClassA.lpszMenuName = mbcsMenuName;
  550.     }
  551.  
  552.     // class name is only a string if the HIWORD is not 0
  553.     CMbcsBuffer mbcsClassName;
  554.     wndClassA.lpszClassName = (LPCSTR) lpWndClass->lpszClassName;
  555.     if (HIWORD(lpWndClass->lpszClassName) != 0) {
  556.         if (!mbcsClassName.FromUnicode(lpWndClass->lpszClassName))
  557.             return NULL;
  558.         wndClassA.lpszClassName = mbcsClassName;
  559.     }
  560.  
  561.     return ::RegisterClassA(&wndClassA);
  562. }
  563.  
  564. UINT WINAPI
  565. RegisterClipboardFormatW(
  566.     IN LPCWSTR lpszFormat
  567.     )
  568. {
  569.     CMbcsBuffer mbcsFormat;
  570.     if (!mbcsFormat.FromUnicode(lpszFormat))
  571.         return 0;
  572.  
  573.     return ::RegisterClipboardFormatA(mbcsFormat);
  574. }
  575.  
  576. // RegisterDeviceNotificationW
  577. // RegisterWindowMessageW
  578. // RemovePropA
  579. // RemovePropW
  580. // SendDlgItemMessageW
  581. // SendMessageCallbackW
  582.  
  583. LRESULT WINAPI
  584. SendMessageTimeoutW(
  585.     IN HWND hWnd,
  586.     IN UINT Msg,
  587.     IN WPARAM wParam,
  588.     IN LPARAM lParam,
  589.     IN UINT fuFlags,
  590.     IN UINT uTimeout,
  591.     OUT PDWORD_PTR lpdwResult
  592.     )
  593. {
  594.     // only the following message types have been verified, before using
  595.     // other message types ensure that they are implemented correctly
  596.     _ASSERTE(
  597.         Msg == WM_SETTEXT ||
  598.         Msg == WM_SETICON ||
  599.         Msg == WM_SETFONT ||
  600.         Msg == WM_SETTINGCHANGE );
  601.  
  602.     if (Msg == WM_SETTEXT) {
  603.         CMbcsBuffer mbcsString;
  604.         if (!mbcsString.FromUnicode((LPWSTR)lParam))
  605.             return ::SendMessageTimeoutA(hWnd, WM_SETTEXT, 0, 0,
  606.                 fuFlags, uTimeout, lpdwResult); // error value depends on hWnd
  607.  
  608.         return ::SendMessageTimeoutA(hWnd, WM_SETTEXT, wParam, (LPARAM) mbcsString.get(),
  609.             fuFlags, uTimeout, lpdwResult);
  610.     }
  611.  
  612.     if (Msg == WM_SETTINGCHANGE) {
  613.         CMbcsBuffer mbcsString;
  614.         if (!mbcsString.FromUnicode((LPWSTR)lParam))
  615.             mbcsString.SetNull();   // don't set the string
  616.         return ::SendMessageTimeoutA(hWnd, WM_SETTINGCHANGE, wParam, (LPARAM) mbcsString.get(),
  617.             fuFlags, uTimeout, lpdwResult);
  618.     }
  619.  
  620.     return ::SendMessageTimeoutA(hWnd, Msg, wParam, lParam,
  621.         fuFlags, uTimeout, lpdwResult);
  622. }
  623.  
  624. LRESULT WINAPI
  625. SendMessageW(
  626.     IN HWND hWnd,
  627.     IN UINT Msg,
  628.     IN WPARAM wParam,
  629.     IN LPARAM lParam
  630.     )
  631. {
  632.     // only the following message types have been verified, before using
  633.     // other message types ensure that they are implemented correctly
  634.     _ASSERTE(
  635.         Msg == WM_SETTEXT ||
  636.         Msg == WM_SETICON ||
  637.         Msg == WM_SETFONT ||
  638.         Msg == WM_SETTINGCHANGE );
  639.  
  640.     if (Msg == WM_SETTEXT) {
  641.         CMbcsBuffer mbcsString;
  642.         if (!mbcsString.FromUnicode((LPWSTR)lParam))
  643.             return ::SendMessageA(hWnd, WM_SETTEXT, 0, 0); // error value depends on hWnd
  644.  
  645.         return ::SendMessageA(hWnd, WM_SETTEXT, wParam, (LPARAM) mbcsString.get());
  646.     }
  647.  
  648.     if (Msg == WM_SETTINGCHANGE) {
  649.         CMbcsBuffer mbcsString;
  650.         if (!mbcsString.FromUnicode((LPWSTR)lParam))
  651.             mbcsString.SetNull();   // don't set the string
  652.         return ::SendMessageA(hWnd, WM_SETTINGCHANGE, wParam, (LPARAM) mbcsString.get());
  653.     }
  654.  
  655.     return ::SendMessageA(hWnd, Msg, wParam, lParam);
  656. }
  657.  
  658. // SendNotifyMessageW
  659. // SetClassLongW
  660. // SetDlgItemTextW
  661. // SetMenuItemInfoW
  662. // SetPropA
  663. // SetPropW
  664. // SetWindowLongA
  665. // SetWindowLongW
  666. // SetWindowTextW
  667. // SetWindowsHookExW
  668. // SetWindowsHookW
  669. // SystemParametersInfoW
  670. // TabbedTextOutW
  671. // TranslateAcceleratorW
  672.  
  673. BOOL WINAPI
  674. UnregisterClassW(
  675.     IN LPCWSTR lpClassName,
  676.     IN HINSTANCE hInstance
  677.     )
  678. {
  679.     // class name is only a string if the HIWORD is not 0
  680.     CMbcsBuffer mbcsClassName;
  681.     LPCSTR pmbcsClassName = (LPCSTR) lpClassName;
  682.     if (HIWORD(lpClassName) != 0) {
  683.         if (!mbcsClassName.FromUnicode(lpClassName))
  684.             return NULL;
  685.         pmbcsClassName = mbcsClassName;
  686.     }
  687.  
  688.     return ::UnregisterClassA(pmbcsClassName, hInstance);
  689. }
  690.  
  691. // VkKeyScanExW
  692. // VkKeyScanW
  693. // WinHelpW
  694. // wsprintfW
  695. // wvsprintfW
  696. #endif
  697.  
  698. #endif
  699.