[MSPAINT] Adapt to Unicode and <strsafe.h> (#5882)

- TCHAR --> WCHAR
- LPTSTR --> LPWSTR
- LPCTSTR --> LPCWSTR
- CString --> CStringW
- TEXT("...") --> L"..."
- _T("...") --> L"..."
- ::SendMessage( --> ::SendMessageW(
- ::GetWindowText( --> ::GetWindowTextW(
- ::SetWindowText( --> ::SetWindowTextW(
- Replace _tcscat with StringCchCatW.
- Replace _tcslen with wcslen.
etc. CORE-19094
This commit is contained in:
Katayama Hirofumi MZ 2023-11-04 19:25:45 +09:00 committed by GitHub
parent d7e1bd2705
commit 640d67d12a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 320 additions and 327 deletions

View file

@ -69,7 +69,7 @@ public:
return TRUE; return TRUE;
} }
HRESULT LoadDx(LPCTSTR pszFileName, float *pxDpi, float *pyDpi) throw() HRESULT LoadDx(LPCWSTR pszFileName, float *pxDpi, float *pyDpi) throw()
{ {
using namespace Gdiplus; using namespace Gdiplus;
@ -111,7 +111,7 @@ public:
return (status == Ok ? S_OK : E_FAIL); return (status == Ok ? S_OK : E_FAIL);
} }
HRESULT SaveDx(LPCTSTR pszFileName, REFGUID guidFileType = GUID_NULL, HRESULT SaveDx(LPCWSTR pszFileName, REFGUID guidFileType = GUID_NULL,
float xDpi = 0, float yDpi = 0) throw() float xDpi = 0, float yDpi = 0) throw()
{ {
using namespace Gdiplus; using namespace Gdiplus;
@ -141,7 +141,7 @@ public:
CLSID clsid; CLSID clsid;
if (::IsEqualGUID(guidFileType, GUID_NULL)) if (::IsEqualGUID(guidFileType, GUID_NULL))
{ {
CString strExt(PathFindExtension(pszFileName)); CStringW strExt(PathFindExtensionW(pszFileName));
clsid = FindCodecForExtension(strExt, pEncoders, cEncoders); clsid = FindCodecForExtension(strExt, pEncoders, cEncoders);
} }
else else
@ -300,23 +300,23 @@ protected:
// CImage::FindCodecForExtension is private. We have to duplicate it at here... // CImage::FindCodecForExtension is private. We have to duplicate it at here...
static CLSID static CLSID
FindCodecForExtension(LPCTSTR dotext, const Gdiplus::ImageCodecInfo *pCodecs, UINT nCodecs) FindCodecForExtension(LPCWSTR dotext, const Gdiplus::ImageCodecInfo *pCodecs, UINT nCodecs)
{ {
for (UINT i = 0; i < nCodecs; ++i) for (UINT i = 0; i < nCodecs; ++i)
{ {
CString strSpecs(pCodecs[i].FilenameExtension); CStringW strSpecs(pCodecs[i].FilenameExtension);
int ichOld = 0, ichSep; int ichOld = 0, ichSep;
for (;;) for (;;)
{ {
ichSep = strSpecs.Find(TEXT(';'), ichOld); ichSep = strSpecs.Find(L';', ichOld);
CString strSpec; CStringW strSpec;
if (ichSep < 0) if (ichSep < 0)
strSpec = strSpecs.Mid(ichOld); strSpec = strSpecs.Mid(ichOld);
else else
strSpec = strSpecs.Mid(ichOld, ichSep - ichOld); strSpec = strSpecs.Mid(ichOld, ichSep - ichOld);
int ichDot = strSpec.ReverseFind(TEXT('.')); int ichDot = strSpec.ReverseFind(L'.');
if (ichDot >= 0) if (ichDot >= 0)
strSpec = strSpec.Mid(ichDot); strSpec = strSpec.Mid(ichDot);

View file

@ -321,7 +321,7 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
{ {
m_ptOrig = pt; m_ptOrig = pt;
SetCapture(); SetCapture();
::SetCursor(::LoadCursor(g_hinstExe, MAKEINTRESOURCE(IDC_HANDDRAG))); ::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_HANDDRAG)));
return 0; return 0;
} }
@ -450,10 +450,10 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
RECT rcImage; RECT rcImage;
GetImageRect(rcImage); GetImageRect(rcImage);
CString strCoord; CStringW strCoord;
if (::PtInRect(&rcImage, pt)) if (::PtInRect(&rcImage, pt))
strCoord.Format(_T("%ld, %ld"), pt.x, pt.y); strCoord.Format(L"%ld, %ld", pt.x, pt.y);
::SendMessage(g_hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord); ::SendMessageW(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCWSTR)strCoord);
} }
} }
@ -511,9 +511,9 @@ LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
cyImage = min(MAXWORD, cyImage); cyImage = min(MAXWORD, cyImage);
// Display new size // Display new size
CString strSize; CStringW strSize;
strSize.Format(_T("%d x %d"), cxImage, cyImage); strSize.Format(L"%d x %d", cxImage, cyImage);
::SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize); ::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)(LPCWSTR)strSize);
// Dragging now... Fix the position... // Dragging now... Fix the position...
CRect rcResizing = { 0, 0, cxImage, cyImage }; CRect rcResizing = { 0, 0, cxImage, cyImage };
@ -559,7 +559,7 @@ LRESULT CCanvasWindow::OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
m_drawing = FALSE; m_drawing = FALSE;
toolsModel.OnButtonUp(bLeftButton, pt.x, pt.y); toolsModel.OnButtonUp(bLeftButton, pt.x, pt.y);
Invalidate(FALSE); Invalidate(FALSE);
::SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)_T("")); ::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)L"");
return 0; return 0;
} }
else if (m_hitSelection != HIT_NONE && bLeftButton) else if (m_hitSelection != HIT_NONE && bLeftButton)
@ -625,7 +625,7 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
if (m_nMouseDownMsg == WM_MBUTTONDOWN) if (m_nMouseDownMsg == WM_MBUTTONDOWN)
{ {
::SetCursor(::LoadCursor(g_hinstExe, MAKEINTRESOURCE(IDC_HANDDRAG))); ::SetCursor(::LoadCursorW(g_hinstExe, MAKEINTRESOURCEW(IDC_HANDDRAG)));
return 0; return 0;
} }
@ -646,7 +646,7 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
if (hitSelection != HIT_NONE) if (hitSelection != HIT_NONE)
{ {
if (!setCursorOnSizeBox(hitSelection)) if (!setCursorOnSizeBox(hitSelection))
::SetCursor(::LoadCursor(NULL, IDC_SIZEALL)); ::SetCursor(::LoadCursorW(NULL, (LPCWSTR)IDC_SIZEALL));
return 0; return 0;
} }
@ -659,22 +659,22 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
switch (toolsModel.GetActiveTool()) switch (toolsModel.GetActiveTool())
{ {
case TOOL_FILL: case TOOL_FILL:
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_FILL))); ::SetCursor(::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDC_FILL)));
break; break;
case TOOL_COLOR: case TOOL_COLOR:
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_COLOR))); ::SetCursor(::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDC_COLOR)));
break; break;
case TOOL_ZOOM: case TOOL_ZOOM:
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_ZOOM))); ::SetCursor(::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDC_ZOOM)));
break; break;
case TOOL_PEN: case TOOL_PEN:
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_PEN))); ::SetCursor(::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDC_PEN)));
break; break;
case TOOL_AIRBRUSH: case TOOL_AIRBRUSH:
::SetCursor(::LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDC_AIRBRUSH))); ::SetCursor(::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDC_AIRBRUSH)));
break; break;
default: default:
::SetCursor(::LoadCursor(NULL, IDC_CROSS)); ::SetCursor(::LoadCursorW(NULL, (LPCWSTR)IDC_CROSS));
} }
return 0; return 0;
} }
@ -711,12 +711,12 @@ LRESULT CCanvasWindow::OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
LRESULT CCanvasWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CCanvasWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
return ::SendMessage(GetParent(), nMsg, wParam, lParam); return ::SendMessageW(GetParent(), nMsg, wParam, lParam);
} }
LRESULT CCanvasWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CCanvasWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
::SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)_T("")); ::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)L"");
return 0; return 0;
} }

View file

@ -10,7 +10,7 @@
class CCanvasWindow : public CWindowImpl<CCanvasWindow> class CCanvasWindow : public CWindowImpl<CCanvasWindow>
{ {
public: public:
DECLARE_WND_CLASS_EX(_T("ReactOSPaintCanvas"), CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, DECLARE_WND_CLASS_EX(L"ReactOSPaintCanvas", CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
COLOR_APPWORKSPACE) COLOR_APPWORKSPACE)
BEGIN_MSG_MAP(CCanvasWindow) BEGIN_MSG_MAP(CCanvasWindow)

View file

@ -113,22 +113,21 @@ LRESULT CAttributesDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam,
if (g_isAFile) if (g_isAFile)
{ {
TCHAR date[100]; WCHAR date[100], temp[100];
TCHAR temp[100]; GetDateFormatW(LOCALE_USER_DEFAULT, 0, &g_fileTime, NULL, date, _countof(date));
GetDateFormat(LOCALE_USER_DEFAULT, 0, &g_fileTime, NULL, date, _countof(date)); GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &g_fileTime, NULL, temp, _countof(temp));
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &g_fileTime, NULL, temp, _countof(temp)); StringCchCatW(date, _countof(date), L" ");
_tcscat(date, _T(" ")); StringCchCatW(date, _countof(date), temp);
_tcscat(date, temp); CStringW strSize;
CString strSize;
strSize.Format(IDS_FILESIZE, g_fileSize); strSize.Format(IDS_FILESIZE, g_fileSize);
SetDlgItemText(IDD_ATTRIBUTESTEXT6, date); SetDlgItemText(IDD_ATTRIBUTESTEXT6, date);
SetDlgItemText(IDD_ATTRIBUTESTEXT7, strSize); SetDlgItemText(IDD_ATTRIBUTESTEXT7, strSize);
} }
CString strUnit; CStringW strUnit;
GetDlgItemText(IDD_ATTRIBUTESTEXT8, strUnit); GetDlgItemText(IDD_ATTRIBUTESTEXT8, strUnit);
CString strRes; CStringW strRes;
if (strUnit == L"dpi") if (strUnit == L"dpi")
strRes.Format(IDS_PRINTRES, ROUND(g_xDpi), ROUND(g_yDpi)); strRes.Format(IDS_PRINTRES, ROUND(g_xDpi), ROUND(g_yDpi));
else else
@ -173,10 +172,10 @@ LRESULT CAttributesDialog::OnRadioButton1(WORD wNotifyCode, WORD wID, HWND hWndC
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1) != BST_CHECKED) if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1) != BST_CHECKED)
return 0; return 0;
CString strNum; CStringW strNum;
strNum.Format(_T("%.3lf"), newWidth / g_xDpi); strNum.Format(L"%.3lf", newWidth / g_xDpi);
SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum); SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum);
strNum.Format(_T("%.3lf"), newHeight / g_yDpi); strNum.Format(L"%.3lf", newHeight / g_yDpi);
SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum); SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum);
return 0; return 0;
} }
@ -186,10 +185,10 @@ LRESULT CAttributesDialog::OnRadioButton2(WORD wNotifyCode, WORD wID, HWND hWndC
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2) != BST_CHECKED) if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2) != BST_CHECKED)
return 0; return 0;
CString strNum; CStringW strNum;
strNum.Format(_T("%.3lf"), newWidth / PpcmFromDpi(g_xDpi)); strNum.Format(L"%.3lf", newWidth / PpcmFromDpi(g_xDpi));
SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum); SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum);
strNum.Format(_T("%.3lf"), newHeight / PpcmFromDpi(g_yDpi)); strNum.Format(L"%.3lf", newHeight / PpcmFromDpi(g_yDpi));
SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum); SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum);
return 0; return 0;
} }
@ -208,21 +207,21 @@ LRESULT CAttributesDialog::OnEdit1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
{ {
if (Edit_GetModify(hWndCtl)) if (Edit_GetModify(hWndCtl))
{ {
TCHAR tempS[100]; WCHAR tempS[100];
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1)) if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1))
{ {
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS)); GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
newWidth = max(1, (int) (_tcstod(tempS, NULL) * g_xDpi)); newWidth = max(1, (int)(wcstod(tempS, NULL) * g_xDpi));
} }
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2)) else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2))
{ {
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS)); GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
newWidth = max(1, (int) (_tcstod(tempS, NULL) * PpcmFromDpi(g_xDpi))); newWidth = max(1, (int)(wcstod(tempS, NULL) * PpcmFromDpi(g_xDpi)));
} }
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3)) else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3))
{ {
GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS)); GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, _countof(tempS));
newWidth = max(1, _tstoi(tempS)); newWidth = max(1, _wtoi(tempS));
} }
Edit_SetModify(hWndCtl, FALSE); Edit_SetModify(hWndCtl, FALSE);
} }
@ -233,21 +232,21 @@ LRESULT CAttributesDialog::OnEdit2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOO
{ {
if (Edit_GetModify(hWndCtl)) if (Edit_GetModify(hWndCtl))
{ {
TCHAR tempS[100]; WCHAR tempS[100];
if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1)) if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1))
{ {
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS)); GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
newHeight = max(1, (int) (_tcstod(tempS, NULL) * g_yDpi)); newHeight = max(1, (int)(wcstod(tempS, NULL) * g_yDpi));
} }
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2)) else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2))
{ {
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS)); GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
newHeight = max(1, (int) (_tcstod(tempS, NULL) * PpcmFromDpi(g_yDpi))); newHeight = max(1, (int)(wcstod(tempS, NULL) * PpcmFromDpi(g_yDpi)));
} }
else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3)) else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3))
{ {
GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS)); GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, _countof(tempS));
newHeight = max(1, _tstoi(tempS)); newHeight = max(1, _wtoi(tempS));
} }
Edit_SetModify(hWndCtl, FALSE); Edit_SetModify(hWndCtl, FALSE);
} }
@ -273,9 +272,7 @@ LRESULT CStretchSkewDialog::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
LRESULT CStretchSkewDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) LRESULT CStretchSkewDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{ {
CString strrcIntNumbers; CStringW strrcIntNumbers, strrcPercentage, strrcAngle;
CString strrcPercentage;
CString strrcAngle;
BOOL tr1, tr2, tr3, tr4; BOOL tr1, tr2, tr3, tr4;
strrcIntNumbers.LoadString(g_hinstExe, IDS_INTNUMBERS); strrcIntNumbers.LoadString(g_hinstExe, IDS_INTNUMBERS);
@ -305,11 +302,11 @@ LRESULT CStretchSkewDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, B
} }
static INT CALLBACK static INT CALLBACK
EnumFontFamProc(ENUMLOGFONT *lpelf, NEWTEXTMETRIC *lpntm, INT FontType, LPARAM lParam) EnumFontFamProc(ENUMLOGFONTW *lpelf, NEWTEXTMETRICW *lpntm, INT FontType, LPARAM lParam)
{ {
CSimpleArray<CString>& arrFontNames = *reinterpret_cast<CSimpleArray<CString>*>(lParam); CSimpleArray<CStringW>& arrFontNames = *reinterpret_cast<CSimpleArray<CStringW>*>(lParam);
LPTSTR name = lpelf->elfLogFont.lfFaceName; LPWSTR name = lpelf->elfLogFont.lfFaceName;
if (name[0] == TEXT('@')) // Vertical fonts if (name[0] == L'@') // Vertical fonts
return TRUE; return TRUE;
for (INT i = 0; i < arrFontNames.GetSize(); ++i) for (INT i = 0; i < arrFontNames.GetSize(); ++i)
@ -331,24 +328,24 @@ CFontsDialog::CFontsDialog()
void CFontsDialog::InitFontNames() void CFontsDialog::InitFontNames()
{ {
// List the fonts // List the fonts
CSimpleArray<CString> arrFontNames; CSimpleArray<CStringW> arrFontNames;
HDC hDC = CreateCompatibleDC(NULL); HDC hDC = CreateCompatibleDC(NULL);
if (hDC) if (hDC)
{ {
EnumFontFamilies(hDC, NULL, (FONTENUMPROC)EnumFontFamProc, EnumFontFamiliesW(hDC, NULL, (FONTENUMPROCW)EnumFontFamProc,
reinterpret_cast<LPARAM>(&arrFontNames)); reinterpret_cast<LPARAM>(&arrFontNames));
DeleteDC(hDC); ::DeleteDC(hDC);
} }
// Actually add them to the combobox // Actually add them to the combobox
HWND hwndNames = GetDlgItem(IDD_FONTSNAMES); HWND hwndNames = GetDlgItem(IDD_FONTSNAMES);
SendMessage(hwndNames, CB_RESETCONTENT, 0, 0); ::SendMessageW(hwndNames, CB_RESETCONTENT, 0, 0);
for (INT i = 0; i < arrFontNames.GetSize(); ++i) for (INT i = 0; i < arrFontNames.GetSize(); ++i)
{ {
ComboBox_AddString(hwndNames, arrFontNames[i]); ComboBox_AddString(hwndNames, arrFontNames[i]);
} }
::SetWindowText(hwndNames, registrySettings.strFontName); ::SetWindowTextW(hwndNames, registrySettings.strFontName);
} }
void CFontsDialog::InitFontSizes() void CFontsDialog::InitFontSizes()
@ -373,26 +370,26 @@ void CFontsDialog::InitFontSizes()
if (ComboBox_GetCurSel(hwndSizes) == CB_ERR) if (ComboBox_GetCurSel(hwndSizes) == CB_ERR)
{ {
StringCchPrintfW(szText, _countof(szText), L"%d", (INT)registrySettings.PointSize); StringCchPrintfW(szText, _countof(szText), L"%d", (INT)registrySettings.PointSize);
::SetWindowText(hwndSizes, szText); ::SetWindowTextW(hwndSizes, szText);
} }
} }
void CFontsDialog::InitToolbar() void CFontsDialog::InitToolbar()
{ {
HWND hwndToolbar = GetDlgItem(IDD_FONTSTOOLBAR); HWND hwndToolbar = GetDlgItem(IDD_FONTSTOOLBAR);
SendMessage(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); ::SendMessageW(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
SendMessage(hwndToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(16, 16)); ::SendMessageW(hwndToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(16, 16));
SendMessage(hwndToolbar, TB_SETBUTTONWIDTH, 0, MAKELPARAM(20, 20)); ::SendMessageW(hwndToolbar, TB_SETBUTTONWIDTH, 0, MAKELPARAM(20, 20));
TBADDBITMAP AddBitmap; TBADDBITMAP AddBitmap;
AddBitmap.hInst = g_hinstExe; AddBitmap.hInst = g_hinstExe;
AddBitmap.nID = IDB_FONTSTOOLBAR; AddBitmap.nID = IDB_FONTSTOOLBAR;
SendMessage(hwndToolbar, TB_ADDBITMAP, 4, (LPARAM)&AddBitmap); ::SendMessageW(hwndToolbar, TB_ADDBITMAP, 4, (LPARAM)&AddBitmap);
HIMAGELIST himl = ImageList_LoadImage(g_hinstExe, MAKEINTRESOURCE(IDB_FONTSTOOLBAR), HIMAGELIST himl = ImageList_LoadImage(g_hinstExe, MAKEINTRESOURCEW(IDB_FONTSTOOLBAR),
16, 8, RGB(255, 0, 255), IMAGE_BITMAP, 16, 8, RGB(255, 0, 255), IMAGE_BITMAP,
LR_CREATEDIBSECTION); LR_CREATEDIBSECTION);
SendMessage(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM)himl); ::SendMessageW(hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM)himl);
TBBUTTON buttons[] = TBBUTTON buttons[] =
{ {
@ -401,11 +398,11 @@ void CFontsDialog::InitToolbar()
{ 2, IDM_UNDERLINE, TBSTATE_ENABLED, TBSTYLE_CHECK }, { 2, IDM_UNDERLINE, TBSTATE_ENABLED, TBSTYLE_CHECK },
{ 3, IDM_VERTICAL, 0, TBSTYLE_CHECK }, // TODO: { 3, IDM_VERTICAL, 0, TBSTYLE_CHECK }, // TODO:
}; };
SendMessage(hwndToolbar, TB_ADDBUTTONS, _countof(buttons), (LPARAM)&buttons); ::SendMessageW(hwndToolbar, TB_ADDBUTTONS, _countof(buttons), (LPARAM)&buttons);
SendMessage(hwndToolbar, TB_CHECKBUTTON, IDM_BOLD, registrySettings.Bold); ::SendMessageW(hwndToolbar, TB_CHECKBUTTON, IDM_BOLD, registrySettings.Bold);
SendMessage(hwndToolbar, TB_CHECKBUTTON, IDM_ITALIC, registrySettings.Italic); ::SendMessageW(hwndToolbar, TB_CHECKBUTTON, IDM_ITALIC, registrySettings.Italic);
SendMessage(hwndToolbar, TB_CHECKBUTTON, IDM_UNDERLINE, registrySettings.Underline); ::SendMessageW(hwndToolbar, TB_CHECKBUTTON, IDM_UNDERLINE, registrySettings.Underline);
} }
LRESULT CFontsDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CFontsDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
@ -441,7 +438,7 @@ void CFontsDialog::OnFontName(UINT codeNotify)
HWND hwndNames = GetDlgItem(IDD_FONTSNAMES); HWND hwndNames = GetDlgItem(IDD_FONTSNAMES);
INT iItem = CB_ERR; INT iItem = CB_ERR;
UINT cch; UINT cch;
TCHAR szText[LF_FACESIZE]; WCHAR szText[LF_FACESIZE];
switch (codeNotify) switch (codeNotify)
{ {
@ -449,9 +446,7 @@ void CFontsDialog::OnFontName(UINT codeNotify)
iItem = ComboBox_GetCurSel(hwndNames); iItem = ComboBox_GetCurSel(hwndNames);
cch = ComboBox_GetLBTextLen(hwndNames, iItem); cch = ComboBox_GetLBTextLen(hwndNames, iItem);
if (iItem != CB_ERR && 0 < cch && cch < _countof(szText)) if (iItem != CB_ERR && 0 < cch && cch < _countof(szText))
{
ComboBox_GetLBText(hwndNames, iItem, szText); ComboBox_GetLBText(hwndNames, iItem, szText);
}
break; break;
case CBN_EDITCHANGE: case CBN_EDITCHANGE:
@ -482,13 +477,13 @@ void CFontsDialog::OnFontSize(UINT codeNotify)
if (iItem != CB_ERR && 0 < cch && cch < _countof(szText)) if (iItem != CB_ERR && 0 < cch && cch < _countof(szText))
{ {
ComboBox_GetLBText(hwndSizes, iItem, szText); ComboBox_GetLBText(hwndSizes, iItem, szText);
PointSize = _ttoi(szText); PointSize = _wtoi(szText);
} }
break; break;
case CBN_EDITCHANGE: case CBN_EDITCHANGE:
::GetWindowText(hwndSizes, szText, _countof(szText)); ::GetWindowTextW(hwndSizes, szText, _countof(szText));
PointSize = _ttoi(szText); PointSize = _wtoi(szText);
break; break;
} }
@ -504,7 +499,7 @@ LRESULT CFontsDialog::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
UINT id = LOWORD(wParam); UINT id = LOWORD(wParam);
UINT codeNotify = HIWORD(wParam); UINT codeNotify = HIWORD(wParam);
HWND hwndToolbar = GetDlgItem(IDD_FONTSTOOLBAR); HWND hwndToolbar = GetDlgItem(IDD_FONTSTOOLBAR);
BOOL bChecked = (BOOL)::SendMessage(hwndToolbar, TB_ISBUTTONCHECKED, id, 0); BOOL bChecked = (BOOL)::SendMessageW(hwndToolbar, TB_ISBUTTONCHECKED, id, 0);
switch (id) switch (id)
{ {
@ -548,14 +543,14 @@ LRESULT CFontsDialog::OnNotify(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
NMHDR *pnmhdr = reinterpret_cast<NMHDR *>(lParam); NMHDR *pnmhdr = reinterpret_cast<NMHDR *>(lParam);
if (pnmhdr->code == TTN_NEEDTEXT) if (pnmhdr->code == TTN_NEEDTEXT)
{ {
LPTOOLTIPTEXT pToolTip = reinterpret_cast<LPTOOLTIPTEXT>(lParam); LPTOOLTIPTEXTW pToolTip = reinterpret_cast<LPTOOLTIPTEXTW>(lParam);
pToolTip->hinst = g_hinstExe; pToolTip->hinst = g_hinstExe;
switch (pnmhdr->idFrom) switch (pnmhdr->idFrom)
{ {
case IDM_BOLD: pToolTip->lpszText = MAKEINTRESOURCE(IDS_BOLD); break; case IDM_BOLD: pToolTip->lpszText = MAKEINTRESOURCEW(IDS_BOLD); break;
case IDM_ITALIC: pToolTip->lpszText = MAKEINTRESOURCE(IDS_ITALIC); break; case IDM_ITALIC: pToolTip->lpszText = MAKEINTRESOURCEW(IDS_ITALIC); break;
case IDM_UNDERLINE: pToolTip->lpszText = MAKEINTRESOURCE(IDS_UNDERLINE); break; case IDM_UNDERLINE: pToolTip->lpszText = MAKEINTRESOURCEW(IDS_UNDERLINE); break;
case IDM_VERTICAL: pToolTip->lpszText = MAKEINTRESOURCE(IDS_VERTICAL); break; case IDM_VERTICAL: pToolTip->lpszText = MAKEINTRESOURCEW(IDS_VERTICAL); break;
default: default:
break; break;
@ -604,29 +599,29 @@ LRESULT CFontsDialog::OnDrawItem(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
if (pDrawItem->itemID == (UINT)-1) if (pDrawItem->itemID == (UINT)-1)
return TRUE; return TRUE;
SetBkMode(pDrawItem->hDC, TRANSPARENT); ::SetBkMode(pDrawItem->hDC, TRANSPARENT);
HWND hwndItem = pDrawItem->hwndItem; HWND hwndItem = pDrawItem->hwndItem;
RECT rcItem = pDrawItem->rcItem; RECT rcItem = pDrawItem->rcItem;
if (pDrawItem->itemState & ODS_SELECTED) if (pDrawItem->itemState & ODS_SELECTED)
{ {
FillRect(pDrawItem->hDC, &rcItem, GetSysColorBrush(COLOR_HIGHLIGHT)); ::FillRect(pDrawItem->hDC, &rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
SetTextColor(pDrawItem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); ::SetTextColor(pDrawItem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
} }
else else
{ {
FillRect(pDrawItem->hDC, &rcItem, GetSysColorBrush(COLOR_WINDOW)); ::FillRect(pDrawItem->hDC, &rcItem, GetSysColorBrush(COLOR_WINDOW));
SetTextColor(pDrawItem->hDC, GetSysColor(COLOR_WINDOWTEXT)); ::SetTextColor(pDrawItem->hDC, GetSysColor(COLOR_WINDOWTEXT));
} }
TCHAR szText[LF_FACESIZE]; WCHAR szText[LF_FACESIZE];
if ((UINT)ComboBox_GetLBTextLen(hwndItem, pDrawItem->itemID) < _countof(szText)) if ((UINT)ComboBox_GetLBTextLen(hwndItem, pDrawItem->itemID) < _countof(szText))
{ {
szText[0] = 0; szText[0] = 0;
ComboBox_GetLBText(hwndItem, pDrawItem->itemID, szText); ComboBox_GetLBText(hwndItem, pDrawItem->itemID, szText);
rcItem.left += 24; rcItem.left += 24;
DrawText(pDrawItem->hDC, szText, -1, &rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE); ::DrawTextW(pDrawItem->hDC, szText, -1, &rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
} }
if (pDrawItem->itemState & ODS_FOCUS) if (pDrawItem->itemState & ODS_FOCUS)

View file

@ -87,7 +87,7 @@ CreateColorDIB(int width, int height, COLORREF rgb)
HBITMAP CopyMonoImage(HBITMAP hbm, INT cx, INT cy) HBITMAP CopyMonoImage(HBITMAP hbm, INT cx, INT cy)
{ {
BITMAP bm; BITMAP bm;
if (!GetObject(hbm, sizeof(bm), &bm)) if (!::GetObjectW(hbm, sizeof(bm), &bm))
return NULL; return NULL;
if (cx == 0 || cy == 0) if (cx == 0 || cy == 0)
@ -96,19 +96,19 @@ HBITMAP CopyMonoImage(HBITMAP hbm, INT cx, INT cy)
cy = bm.bmHeight; cy = bm.bmHeight;
} }
HBITMAP hbmNew = CreateBitmap(cx, cy, 1, 1, NULL); HBITMAP hbmNew = ::CreateBitmap(cx, cy, 1, 1, NULL);
if (!hbmNew) if (!hbmNew)
return NULL; return NULL;
HDC hdc1 = CreateCompatibleDC(NULL); HDC hdc1 = ::CreateCompatibleDC(NULL);
HDC hdc2 = CreateCompatibleDC(NULL); HDC hdc2 = ::CreateCompatibleDC(NULL);
HGDIOBJ hbm1Old = SelectObject(hdc1, hbm); HGDIOBJ hbm1Old = ::SelectObject(hdc1, hbm);
HGDIOBJ hbm2Old = SelectObject(hdc2, hbmNew); HGDIOBJ hbm2Old = ::SelectObject(hdc2, hbmNew);
StretchBlt(hdc2, 0, 0, cx, cy, hdc1, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); ::StretchBlt(hdc2, 0, 0, cx, cy, hdc1, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
SelectObject(hdc1, hbm1Old); ::SelectObject(hdc1, hbm1Old);
SelectObject(hdc2, hbm2Old); ::SelectObject(hdc2, hbm2Old);
DeleteDC(hdc1); ::DeleteDC(hdc1);
DeleteDC(hdc2); ::DeleteDC(hdc2);
return hbmNew; return hbmNew;
} }
@ -120,7 +120,7 @@ HBITMAP CachedBufferDIB(HBITMAP hbm, int minimalWidth, int minimalHeight)
minimalHeight = 1; minimalHeight = 1;
BITMAP bm; BITMAP bm;
if (!GetObject(hbm, sizeof(bm), &bm)) if (!GetObjectW(hbm, sizeof(bm), &bm))
hbm = NULL; hbm = NULL;
if (hbm && minimalWidth <= bm.bmWidth && minimalHeight <= bm.bmHeight) if (hbm && minimalWidth <= bm.bmWidth && minimalHeight <= bm.bmHeight)
@ -136,7 +136,7 @@ int
GetDIBWidth(HBITMAP hBitmap) GetDIBWidth(HBITMAP hBitmap)
{ {
BITMAP bm; BITMAP bm;
GetObject(hBitmap, sizeof(BITMAP), &bm); ::GetObjectW(hBitmap, sizeof(BITMAP), &bm);
return bm.bmWidth; return bm.bmWidth;
} }
@ -144,7 +144,7 @@ int
GetDIBHeight(HBITMAP hBitmap) GetDIBHeight(HBITMAP hBitmap)
{ {
BITMAP bm; BITMAP bm;
GetObject(hBitmap, sizeof(BITMAP), &bm); ::GetObjectW(hBitmap, sizeof(BITMAP), &bm);
return bm.bmHeight; return bm.bmHeight;
} }
@ -211,8 +211,8 @@ void SetFileInfo(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isAFile)
} }
// set title // set title
CString strTitle; CStringW strTitle;
strTitle.Format(IDS_WINDOWTITLE, PathFindFileName(g_szFileName)); strTitle.Format(IDS_WINDOWTITLE, PathFindFileNameW(g_szFileName));
mainWindow.SetWindowText(strTitle); mainWindow.SetWindowText(strTitle);
// update file info and recent // update file info and recent
@ -258,7 +258,7 @@ HBITMAP DoLoadImageFile(HWND hwnd, LPCWSTR name, BOOL fIsMainFile)
CWaitCursor waitCursor; CWaitCursor waitCursor;
// find the file // find the file
WIN32_FIND_DATA find; WIN32_FIND_DATAW find;
HANDLE hFind = ::FindFirstFileW(name, &find); HANDLE hFind = ::FindFirstFileW(name, &find);
if (hFind == INVALID_HANDLE_VALUE) // does not exist if (hFind == INVALID_HANDLE_VALUE) // does not exist
{ {
@ -358,7 +358,7 @@ HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical, BOOL bMono)
const double eTan = tan(abs(nDegree) * M_PI / 180); const double eTan = tan(abs(nDegree) * M_PI / 180);
BITMAP bm; BITMAP bm;
GetObjectW(hbm, sizeof(bm), &bm); ::GetObjectW(hbm, sizeof(bm), &bm);
INT cx = bm.bmWidth, cy = bm.bmHeight, dx = 0, dy = 0; INT cx = bm.bmWidth, cy = bm.bmHeight, dx = 0, dy = 0;
if (bVertical) if (bVertical)
dy = INT(cx * eTan); dy = INT(cx * eTan);
@ -384,9 +384,9 @@ HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical, BOOL bMono)
{ {
INT delta = INT(x * eTan); INT delta = INT(x * eTan);
if (nDegree > 0) if (nDegree > 0)
BitBlt(hDC2, x, (dy - delta), 1, cy, hDC1, x, 0, SRCCOPY); ::BitBlt(hDC2, x, (dy - delta), 1, cy, hDC1, x, 0, SRCCOPY);
else else
BitBlt(hDC2, x, delta, 1, cy, hDC1, x, 0, SRCCOPY); ::BitBlt(hDC2, x, delta, 1, cy, hDC1, x, 0, SRCCOPY);
} }
} }
else else
@ -395,9 +395,9 @@ HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical, BOOL bMono)
{ {
INT delta = INT(y * eTan); INT delta = INT(y * eTan);
if (nDegree > 0) if (nDegree > 0)
BitBlt(hDC2, (dx - delta), y, cx, 1, hDC1, 0, y, SRCCOPY); ::BitBlt(hDC2, (dx - delta), y, cx, 1, hDC1, 0, y, SRCCOPY);
else else
BitBlt(hDC2, delta, y, cx, 1, hDC1, 0, y, SRCCOPY); ::BitBlt(hDC2, delta, y, cx, 1, hDC1, 0, y, SRCCOPY);
} }
} }
@ -416,7 +416,7 @@ HGLOBAL BitmapToClipboardDIB(HBITMAP hBitmap)
CWaitCursor waitCursor; CWaitCursor waitCursor;
BITMAP bm; BITMAP bm;
if (!GetObject(hBitmap, sizeof(BITMAP), &bm)) if (!GetObjectW(hBitmap, sizeof(BITMAP), &bm))
return NULL; return NULL;
BITMAPINFODX bmi; BITMAPINFODX bmi;
@ -600,7 +600,7 @@ HBITMAP ConvertToBlackAndWhite(HBITMAP hbm)
CWaitCursor waitCursor; CWaitCursor waitCursor;
BITMAP bm; BITMAP bm;
if (!::GetObject(hbm, sizeof(bm), &bm)) if (!::GetObjectW(hbm, sizeof(bm), &bm))
return NULL; return NULL;
BITMAPINFOEX bmi; BITMAPINFOEX bmi;

View file

@ -253,38 +253,37 @@ RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
} }
void void
Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCTSTR lpchText, HFONT font, LONG style) Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCWSTR lpchText, HFONT font, LONG style)
{ {
INT iSaveDC = SaveDC(hdc); // We will modify the clipping region. Save now. INT iSaveDC = ::SaveDC(hdc); // We will modify the clipping region. Save now.
RECT rc; RECT rc;
SetRect(&rc, x1, y1, x2, y2); ::SetRect(&rc, x1, y1, x2, y2);
if (style == 0) // Transparent if (style == 0) // Transparent
{ {
SetBkMode(hdc, TRANSPARENT); ::SetBkMode(hdc, TRANSPARENT);
GetBkColor(hdc);
} }
else // Opaque else // Opaque
{ {
SetBkMode(hdc, OPAQUE); ::SetBkMode(hdc, OPAQUE);
SetBkColor(hdc, bg); ::SetBkColor(hdc, bg);
HBRUSH hbr = CreateSolidBrush(bg); HBRUSH hbr = ::CreateSolidBrush(bg);
FillRect(hdc, &rc, hbr); // Fill the background ::FillRect(hdc, &rc, hbr); // Fill the background
DeleteObject(hbr); ::DeleteObject(hbr);
} }
IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom); IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
HGDIOBJ hFontOld = SelectObject(hdc, font); HGDIOBJ hFontOld = ::SelectObject(hdc, font);
SetTextColor(hdc, fg); ::SetTextColor(hdc, fg);
const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP | const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
DT_EXPANDTABS | DT_WORDBREAK; DT_EXPANDTABS | DT_WORDBREAK;
DrawText(hdc, lpchText, -1, &rc, uFormat); ::DrawTextW(hdc, lpchText, -1, &rc, uFormat);
SelectObject(hdc, hFontOld); ::SelectObject(hdc, hFontOld);
RestoreDC(hdc, iSaveDC); // Restore ::RestoreDC(hdc, iSaveDC); // Restore
} }
BOOL BOOL

View file

@ -31,7 +31,7 @@ void Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG sty
void RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2); void RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2);
void Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCTSTR lpchText, HFONT font, LONG style); void Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCWSTR lpchText, HFONT font, LONG style);
BOOL BOOL
ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,

View file

@ -22,8 +22,8 @@ HWND CFullscreenWindow::DoCreate()
LRESULT CFullscreenWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CFullscreenWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
SendMessage(WM_SETICON, ICON_BIG, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON))); SendMessage(WM_SETICON, ICON_BIG, (LPARAM)::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON))); SendMessage(WM_SETICON, ICON_SMALL, (LPARAM)::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
return 0; return 0;
} }

View file

@ -10,7 +10,7 @@
class CFullscreenWindow : public CWindowImpl<CFullscreenWindow> class CFullscreenWindow : public CWindowImpl<CFullscreenWindow>
{ {
public: public:
DECLARE_WND_CLASS_EX(_T("FullscreenWindow"), CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, DECLARE_WND_CLASS_EX(L"FullscreenWindow", CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
COLOR_BACKGROUND) COLOR_BACKGROUND)
BEGIN_MSG_MAP(CFullscreenWindow) BEGIN_MSG_MAP(CFullscreenWindow)

View file

@ -15,7 +15,7 @@ extern POINT g_ptStart, g_ptEnd;
extern HINSTANCE g_hinstExe; extern HINSTANCE g_hinstExe;
extern TCHAR g_szFileName[MAX_LONG_PATH]; extern WCHAR g_szFileName[MAX_LONG_PATH];
extern BOOL g_isAFile; extern BOOL g_isAFile;
extern BOOL g_imageSaved; extern BOOL g_imageSaved;
extern BOOL g_showGrid; extern BOOL g_showGrid;

View file

@ -179,7 +179,7 @@ void ImageModel::Crop(int nWidth, int nHeight, int nOffsetX, int nOffsetY)
NotifyImageChanged(); NotifyImageChanged();
} }
void ImageModel::SaveImage(LPCTSTR lpFileName) void ImageModel::SaveImage(LPCWSTR lpFileName)
{ {
SaveDIBToFile(m_hBms[m_currInd], lpFileName, TRUE); SaveDIBToFile(m_hBms[m_currInd], lpFileName, TRUE);
} }
@ -266,7 +266,7 @@ void ImageModel::RotateNTimes90Degrees(int iN)
case 2: case 2:
{ {
PushImageForUndo(); PushImageForUndo();
StretchBlt(m_hDrawingDC, GetWidth() - 1, GetHeight() - 1, -GetWidth(), -GetHeight(), ::StretchBlt(m_hDrawingDC, GetWidth() - 1, GetHeight() - 1, -GetWidth(), -GetHeight(),
m_hDrawingDC, 0, 0, GetWidth(), GetHeight(), SRCCOPY); m_hDrawingDC, 0, 0, GetWidth(), GetHeight(), SRCCOPY);
break; break;
} }

View file

@ -25,7 +25,7 @@ public:
void Redo(void); void Redo(void);
void ClearHistory(void); void ClearHistory(void);
void Crop(int nWidth, int nHeight, int nOffsetX = 0, int nOffsetY = 0); void Crop(int nWidth, int nHeight, int nOffsetX = 0, int nOffsetY = 0);
void SaveImage(LPCTSTR lpFileName); void SaveImage(LPCWSTR lpFileName);
BOOL IsImageSaved() const; BOOL IsImageSaved() const;
void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0); void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0);
int GetWidth() const; int GetWidth() const;

View file

@ -13,7 +13,7 @@
POINT g_ptStart, g_ptEnd; POINT g_ptStart, g_ptEnd;
BOOL g_askBeforeEnlarging = FALSE; // TODO: initialize from registry BOOL g_askBeforeEnlarging = FALSE; // TODO: initialize from registry
HINSTANCE g_hinstExe = NULL; HINSTANCE g_hinstExe = NULL;
TCHAR g_szFileName[MAX_LONG_PATH] = { 0 }; WCHAR g_szFileName[MAX_LONG_PATH] = { 0 };
WCHAR g_szMailTempFile[MAX_LONG_PATH] = { 0 }; WCHAR g_szMailTempFile[MAX_LONG_PATH] = { 0 };
BOOL g_isAFile = FALSE; BOOL g_isAFile = FALSE;
BOOL g_imageSaved = FALSE; BOOL g_imageSaved = FALSE;
@ -37,18 +37,18 @@ void ShowOutOfMemory(void)
// get file name extension from filter string // get file name extension from filter string
static BOOL static BOOL
FileExtFromFilter(LPTSTR pExt, OPENFILENAME *pOFN) FileExtFromFilter(LPWSTR pExt, OPENFILENAME *pOFN)
{ {
LPTSTR pchExt = pExt; LPWSTR pchExt = pExt;
*pchExt = 0; *pchExt = 0;
DWORD nIndex = 1; DWORD nIndex = 1;
for (LPCTSTR pch = pOFN->lpstrFilter; *pch; ++nIndex) for (LPCWSTR pch = pOFN->lpstrFilter; *pch; ++nIndex)
{ {
pch += lstrlen(pch) + 1; pch += lstrlen(pch) + 1;
if (pOFN->nFilterIndex == nIndex) if (pOFN->nFilterIndex == nIndex)
{ {
for (++pch; *pch && *pch != _T(';'); ++pch) for (++pch; *pch && *pch != L';'; ++pch)
{ {
*pchExt++ = *pch; *pchExt++ = *pch;
} }
@ -66,12 +66,12 @@ static UINT_PTR APIENTRY
OFNHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) OFNHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
HWND hParent; HWND hParent;
OFNOTIFY *pon; OFNOTIFYW *pon;
WCHAR Path[MAX_PATH]; WCHAR Path[MAX_PATH];
switch (uMsg) switch (uMsg)
{ {
case WM_NOTIFY: case WM_NOTIFY:
pon = (OFNOTIFY *)lParam; pon = (OFNOTIFYW *)lParam;
if (pon->hdr.code == CDN_TYPECHANGE) if (pon->hdr.code == CDN_TYPECHANGE)
{ {
hParent = GetParent(hwnd); hParent = GetParent(hwnd);
@ -195,21 +195,21 @@ BOOL OpenMailer(HWND hWnd, LPCWSTR pszPathName)
return FALSE; // Failure return FALSE; // Failure
} }
BOOL CMainWindow::GetOpenFileName(IN OUT LPTSTR pszFile, INT cchMaxFile) BOOL CMainWindow::GetOpenFileName(IN OUT LPWSTR pszFile, INT cchMaxFile)
{ {
static OPENFILENAME ofn = { 0 }; static OPENFILENAMEW ofn = { 0 };
static CString strFilter; static CStringW strFilter;
if (ofn.lStructSize == 0) if (ofn.lStructSize == 0)
{ {
// The "All Files" item text // The "All Files" item text
CString strAllPictureFiles; CStringW strAllPictureFiles;
strAllPictureFiles.LoadString(g_hinstExe, IDS_ALLPICTUREFILES); strAllPictureFiles.LoadString(g_hinstExe, IDS_ALLPICTUREFILES);
// Get the import filter // Get the import filter
CSimpleArray<GUID> aguidFileTypesI; CSimpleArray<GUID> aguidFileTypesI;
CImage::GetImporterFilterString(strFilter, aguidFileTypesI, strAllPictureFiles, CImage::GetImporterFilterString(strFilter, aguidFileTypesI, strAllPictureFiles,
CImage::excludeDefaultLoad, _T('\0')); CImage::excludeDefaultLoad, UNICODE_NULL);
// Initializing the OPENFILENAME structure for GetOpenFileName // Initializing the OPENFILENAME structure for GetOpenFileName
ZeroMemory(&ofn, sizeof(ofn)); ZeroMemory(&ofn, sizeof(ofn));
@ -223,20 +223,20 @@ BOOL CMainWindow::GetOpenFileName(IN OUT LPTSTR pszFile, INT cchMaxFile)
ofn.lpstrFile = pszFile; ofn.lpstrFile = pszFile;
ofn.nMaxFile = cchMaxFile; ofn.nMaxFile = cchMaxFile;
return ::GetOpenFileName(&ofn); return ::GetOpenFileNameW(&ofn);
} }
BOOL CMainWindow::GetSaveFileName(IN OUT LPTSTR pszFile, INT cchMaxFile) BOOL CMainWindow::GetSaveFileName(IN OUT LPWSTR pszFile, INT cchMaxFile)
{ {
static OPENFILENAME sfn = { 0 }; static OPENFILENAMEW sfn = { 0 };
static CString strFilter; static CStringW strFilter;
if (sfn.lStructSize == 0) if (sfn.lStructSize == 0)
{ {
// Get the export filter // Get the export filter
CSimpleArray<GUID> aguidFileTypesE; CSimpleArray<GUID> aguidFileTypesE;
CImage::GetExporterFilterString(strFilter, aguidFileTypesE, NULL, CImage::GetExporterFilterString(strFilter, aguidFileTypesE, NULL,
CImage::excludeDefaultSave, _T('\0')); CImage::excludeDefaultSave, UNICODE_NULL);
// Initializing the OPENFILENAME structure for GetSaveFileName // Initializing the OPENFILENAME structure for GetSaveFileName
ZeroMemory(&sfn, sizeof(sfn)); ZeroMemory(&sfn, sizeof(sfn));
@ -266,7 +266,7 @@ BOOL CMainWindow::GetSaveFileName(IN OUT LPTSTR pszFile, INT cchMaxFile)
sfn.lpstrFile = pszFile; sfn.lpstrFile = pszFile;
sfn.nMaxFile = cchMaxFile; sfn.nMaxFile = cchMaxFile;
return ::GetSaveFileName(&sfn); return ::GetSaveFileNameW(&sfn);
} }
BOOL CMainWindow::ChooseColor(IN OUT COLORREF *prgbColor) BOOL CMainWindow::ChooseColor(IN OUT COLORREF *prgbColor)
@ -298,9 +298,9 @@ BOOL CMainWindow::ChooseColor(IN OUT COLORREF *prgbColor)
HWND CMainWindow::DoCreate() HWND CMainWindow::DoCreate()
{ {
::LoadString(g_hinstExe, IDS_DEFAULTFILENAME, g_szFileName, _countof(g_szFileName)); ::LoadStringW(g_hinstExe, IDS_DEFAULTFILENAME, g_szFileName, _countof(g_szFileName));
CString strTitle; CStringW strTitle;
strTitle.Format(IDS_WINDOWTITLE, PathFindFileName(g_szFileName)); strTitle.Format(IDS_WINDOWTITLE, PathFindFileName(g_szFileName));
RECT& rc = registrySettings.WindowPlacement.rcNormalPosition; RECT& rc = registrySettings.WindowPlacement.rcNormalPosition;
@ -309,7 +309,7 @@ HWND CMainWindow::DoCreate()
// entry point // entry point
INT WINAPI INT WINAPI
_tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, INT nCmdShow) wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow)
{ {
g_hinstExe = hInstance; g_hinstExe = hInstance;
@ -325,7 +325,7 @@ _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, INT nC
// Create the main window // Create the main window
if (!mainWindow.DoCreate()) if (!mainWindow.DoCreate())
{ {
MessageBox(NULL, TEXT("Failed to create main window."), NULL, MB_ICONERROR); MessageBox(NULL, L"Failed to create main window.", NULL, MB_ICONERROR);
return 1; return 1;
} }
@ -337,7 +337,7 @@ _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, INT nC
mainWindow.ShowWindow(registrySettings.WindowPlacement.showCmd); mainWindow.ShowWindow(registrySettings.WindowPlacement.showCmd);
// Load the access keys // Load the access keys
HACCEL hAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(800)); HACCEL hAccel = ::LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(800));
// The message loop // The message loop
MSG msg; MSG msg;
@ -346,7 +346,7 @@ _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, INT nC
if (fontsDialog.IsWindow() && fontsDialog.IsDialogMessage(&msg)) if (fontsDialog.IsWindow() && fontsDialog.IsDialogMessage(&msg))
continue; continue;
if (::TranslateAccelerator(mainWindow, hAccel, &msg)) if (::TranslateAcceleratorW(mainWindow, hAccel, &msg))
continue; continue;
::TranslateMessage(&msg); ::TranslateMessage(&msg);

View file

@ -36,8 +36,8 @@ HWND CMiniatureWindow::DoCreate(HWND hwndParent)
(LONG)(registrySettings.ThumbYPos + registrySettings.ThumbHeight) (LONG)(registrySettings.ThumbYPos + registrySettings.ThumbHeight)
}; };
TCHAR strTitle[100]; WCHAR strTitle[100];
::LoadString(g_hinstExe, IDS_MINIATURETITLE, strTitle, _countof(strTitle)); ::LoadStringW(g_hinstExe, IDS_MINIATURETITLE, strTitle, _countof(strTitle));
DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME; DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME;
return Create(hwndParent, rc, strTitle, style, WS_EX_PALETTEWINDOW); return Create(hwndParent, rc, strTitle, style, WS_EX_PALETTEWINDOW);

View file

@ -11,7 +11,7 @@
class CMiniatureWindow : public CWindowImpl<CMiniatureWindow> class CMiniatureWindow : public CWindowImpl<CMiniatureWindow>
{ {
public: public:
DECLARE_WND_CLASS_EX(_T("MiniatureWindow"), CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, DECLARE_WND_CLASS_EX(L"MiniatureWindow", CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
COLOR_BTNFACE) COLOR_BTNFACE)
BEGIN_MSG_MAP(CMiniatureWindow) BEGIN_MSG_MAP(CMiniatureWindow)

View file

@ -703,7 +703,7 @@ struct TextTool : ToolBase
void draw(HDC hdc) void draw(HDC hdc)
{ {
CString szText; CStringW szText;
textEditWindow.GetWindowText(szText); textEditWindow.GetWindowText(szText);
RECT rc; RECT rc;

View file

@ -14,7 +14,7 @@
class CPaletteWindow : public CWindowImpl<CPaletteWindow> class CPaletteWindow : public CWindowImpl<CPaletteWindow>
{ {
public: public:
DECLARE_WND_CLASS_EX(_T("Palette"), CS_DBLCLKS, COLOR_BTNFACE) DECLARE_WND_CLASS_EX(L"Palette", CS_DBLCLKS, COLOR_BTNFACE)
BEGIN_MSG_MAP(CPaletteWindow) BEGIN_MSG_MAP(CPaletteWindow)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)

View file

@ -15,18 +15,18 @@ RegistrySettings registrySettings;
/* FUNCTIONS ********************************************************/ /* FUNCTIONS ********************************************************/
static void ReadDWORD(CRegKey &key, LPCTSTR lpName, DWORD &dwValue) static void ReadDWORD(CRegKey &key, LPCWSTR lpName, DWORD &dwValue)
{ {
DWORD dwTemp; DWORD dwTemp;
if (key.QueryDWORDValue(lpName, dwTemp) == ERROR_SUCCESS) if (key.QueryDWORDValue(lpName, dwTemp) == ERROR_SUCCESS)
dwValue = dwTemp; dwValue = dwTemp;
} }
static void ReadString(CRegKey &key, LPCTSTR lpName, CString &strValue, LPCTSTR lpDefault = TEXT("")) static void ReadString(CRegKey &key, LPCWSTR lpName, CStringW &strValue, LPCWSTR lpDefault = L"")
{ {
CString strTemp; CStringW strTemp;
ULONG nChars = MAX_PATH; ULONG nChars = MAX_PATH;
LPTSTR psz = strTemp.GetBuffer(nChars); LPWSTR psz = strTemp.GetBuffer(nChars);
LONG error = key.QueryStringValue(lpName, psz, &nChars); LONG error = key.QueryStringValue(lpName, psz, &nChars);
strTemp.ReleaseBuffer(); strTemp.ReleaseBuffer();
@ -36,15 +36,15 @@ static void ReadString(CRegKey &key, LPCTSTR lpName, CString &strValue, LPCTSTR
strValue = lpDefault; strValue = lpDefault;
} }
void RegistrySettings::SetWallpaper(LPCTSTR szFileName, RegistrySettings::WallpaperStyle style) void RegistrySettings::SetWallpaper(LPCWSTR szFileName, RegistrySettings::WallpaperStyle style)
{ {
CRegKey desktop; CRegKey desktop;
if (desktop.Open(HKEY_CURRENT_USER, _T("Control Panel\\Desktop")) == ERROR_SUCCESS) if (desktop.Open(HKEY_CURRENT_USER, L"Control Panel\\Desktop") == ERROR_SUCCESS)
{ {
desktop.SetStringValue(_T("Wallpaper"), szFileName); desktop.SetStringValue(L"Wallpaper", szFileName);
desktop.SetStringValue(_T("WallpaperStyle"), (style == RegistrySettings::STRETCHED) ? _T("2") : _T("0")); desktop.SetStringValue(L"WallpaperStyle", (style == RegistrySettings::STRETCHED) ? L"2" : L"0");
desktop.SetStringValue(_T("TileWallpaper"), (style == RegistrySettings::TILED) ? _T("1") : _T("0")); desktop.SetStringValue(L"TileWallpaper", (style == RegistrySettings::TILED) ? L"1" : L"0");
} }
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID) szFileName, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID) szFileName, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
@ -77,8 +77,8 @@ void RegistrySettings::LoadPresets(INT nCmdShow)
Bar1ID = BAR1ID_TOP; Bar1ID = BAR1ID_TOP;
Bar2ID = BAR2ID_LEFT; Bar2ID = BAR2ID_LEFT;
LOGFONT lf; LOGFONTW lf;
GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf); ::GetObjectW(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
strFontName = lf.lfFaceName; strFontName = lf.lfFaceName;
ZeroMemory(&WindowPlacement, sizeof(WindowPlacement)); ZeroMemory(&WindowPlacement, sizeof(WindowPlacement));
@ -94,33 +94,33 @@ void RegistrySettings::Load(INT nCmdShow)
LoadPresets(nCmdShow); LoadPresets(nCmdShow);
CRegKey paint; CRegKey paint;
if (paint.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint"), KEY_READ) != ERROR_SUCCESS) if (paint.Open(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint", KEY_READ) != ERROR_SUCCESS)
return; return;
CRegKey view; CRegKey view;
if (view.Open(paint, _T("View"), KEY_READ) == ERROR_SUCCESS) if (view.Open(paint, L"View", KEY_READ) == ERROR_SUCCESS)
{ {
ReadDWORD(view, _T("BMPHeight"), BMPHeight); ReadDWORD(view, L"BMPHeight", BMPHeight);
ReadDWORD(view, _T("BMPWidth"), BMPWidth); ReadDWORD(view, L"BMPWidth", BMPWidth);
ReadDWORD(view, _T("GridExtent"), GridExtent); ReadDWORD(view, L"GridExtent", GridExtent);
ReadDWORD(view, _T("NoStretching"), NoStretching); ReadDWORD(view, L"NoStretching", NoStretching);
ReadDWORD(view, _T("ShowThumbnail"), ShowThumbnail); ReadDWORD(view, L"ShowThumbnail", ShowThumbnail);
ReadDWORD(view, _T("SnapToGrid"), SnapToGrid); ReadDWORD(view, L"SnapToGrid", SnapToGrid);
ReadDWORD(view, _T("ThumbHeight"), ThumbHeight); ReadDWORD(view, L"ThumbHeight", ThumbHeight);
ReadDWORD(view, _T("ThumbWidth"), ThumbWidth); ReadDWORD(view, L"ThumbWidth", ThumbWidth);
ReadDWORD(view, _T("ThumbXPos"), ThumbXPos); ReadDWORD(view, L"ThumbXPos", ThumbXPos);
ReadDWORD(view, _T("ThumbYPos"), ThumbYPos); ReadDWORD(view, L"ThumbYPos", ThumbYPos);
ReadDWORD(view, _T("UnitSetting"), UnitSetting); ReadDWORD(view, L"UnitSetting", UnitSetting);
ReadDWORD(view, _T("ShowStatusBar"), ShowStatusBar); ReadDWORD(view, L"ShowStatusBar", ShowStatusBar);
ULONG pnBytes = sizeof(WINDOWPLACEMENT); ULONG pnBytes = sizeof(WINDOWPLACEMENT);
view.QueryBinaryValue(_T("WindowPlacement"), &WindowPlacement, &pnBytes); view.QueryBinaryValue(L"WindowPlacement", &WindowPlacement, &pnBytes);
} }
CRegKey files; CRegKey files;
if (files.Open(paint, _T("Recent File List"), KEY_READ) == ERROR_SUCCESS) if (files.Open(paint, L"Recent File List", KEY_READ) == ERROR_SUCCESS)
{ {
TCHAR szName[64]; WCHAR szName[64];
for (INT i = 0; i < MAX_RECENT_FILES; ++i) for (INT i = 0; i < MAX_RECENT_FILES; ++i)
{ {
StringCchPrintfW(szName, _countof(szName), L"File%u", i + 1); StringCchPrintfW(szName, _countof(szName), L"File%u", i + 1);
@ -129,41 +129,41 @@ void RegistrySettings::Load(INT nCmdShow)
} }
CRegKey text; CRegKey text;
if (text.Open(paint, _T("Text"), KEY_READ) == ERROR_SUCCESS) if (text.Open(paint, L"Text", KEY_READ) == ERROR_SUCCESS)
{ {
ReadDWORD(text, _T("Bold"), Bold); ReadDWORD(text, L"Bold", Bold);
ReadDWORD(text, _T("Italic"), Italic); ReadDWORD(text, L"Italic", Italic);
ReadDWORD(text, _T("Underline"), Underline); ReadDWORD(text, L"Underline", Underline);
ReadDWORD(text, _T("CharSet"), CharSet); ReadDWORD(text, L"CharSet", CharSet);
ReadDWORD(text, _T("PointSize"), PointSize); ReadDWORD(text, L"PointSize", PointSize);
ReadDWORD(text, _T("PositionX"), FontsPositionX); ReadDWORD(text, L"PositionX", FontsPositionX);
ReadDWORD(text, _T("PositionY"), FontsPositionY); ReadDWORD(text, L"PositionY", FontsPositionY);
ReadDWORD(text, _T("ShowTextTool"), ShowTextTool); ReadDWORD(text, L"ShowTextTool", ShowTextTool);
ReadString(text, _T("TypeFaceName"), strFontName, strFontName); ReadString(text, L"TypeFaceName", strFontName, strFontName);
} }
CRegKey bar1; CRegKey bar1;
if (bar1.Open(paint, _T("General-Bar1"), KEY_READ) == ERROR_SUCCESS) if (bar1.Open(paint, L"General-Bar1", KEY_READ) == ERROR_SUCCESS)
{ {
ReadDWORD(bar1, _T("BarID"), Bar1ID); ReadDWORD(bar1, L"BarID", Bar1ID);
} }
CRegKey bar2; CRegKey bar2;
if (bar2.Open(paint, _T("General-Bar2"), KEY_READ) == ERROR_SUCCESS) if (bar2.Open(paint, L"General-Bar2", KEY_READ) == ERROR_SUCCESS)
{ {
ReadDWORD(bar2, _T("BarID"), Bar2ID); ReadDWORD(bar2, L"BarID", Bar2ID);
} }
CRegKey bar3; CRegKey bar3;
if (bar3.Open(paint, _T("General-Bar3"), KEY_READ) == ERROR_SUCCESS) if (bar3.Open(paint, L"General-Bar3", KEY_READ) == ERROR_SUCCESS)
{ {
ReadDWORD(bar3, _T("Visible"), ShowToolBox); ReadDWORD(bar3, L"Visible", ShowToolBox);
} }
CRegKey bar4; CRegKey bar4;
if (bar4.Open(paint, _T("General-Bar4"), KEY_READ) == ERROR_SUCCESS) if (bar4.Open(paint, L"General-Bar4", KEY_READ) == ERROR_SUCCESS)
{ {
ReadDWORD(bar4, _T("Visible"), ShowPalette); ReadDWORD(bar4, L"Visible", ShowPalette);
} }
// Fix the bitmap size if too large // Fix the bitmap size if too large
@ -179,30 +179,30 @@ void RegistrySettings::Store()
BMPHeight = imageModel.GetHeight(); BMPHeight = imageModel.GetHeight();
CRegKey paint; CRegKey paint;
if (paint.Create(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint")) != ERROR_SUCCESS) if (paint.Create(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Paint") != ERROR_SUCCESS)
return; return;
CRegKey view; CRegKey view;
if (view.Create(paint, _T("View")) == ERROR_SUCCESS) if (view.Create(paint, L"View") == ERROR_SUCCESS)
{ {
view.SetDWORDValue(_T("BMPHeight"), BMPHeight); view.SetDWORDValue(L"BMPHeight", BMPHeight);
view.SetDWORDValue(_T("BMPWidth"), BMPWidth); view.SetDWORDValue(L"BMPWidth", BMPWidth);
view.SetDWORDValue(_T("GridExtent"), GridExtent); view.SetDWORDValue(L"GridExtent", GridExtent);
view.SetDWORDValue(_T("NoStretching"), NoStretching); view.SetDWORDValue(L"NoStretching", NoStretching);
view.SetDWORDValue(_T("ShowThumbnail"), ShowThumbnail); view.SetDWORDValue(L"ShowThumbnail", ShowThumbnail);
view.SetDWORDValue(_T("SnapToGrid"), SnapToGrid); view.SetDWORDValue(L"SnapToGrid", SnapToGrid);
view.SetDWORDValue(_T("ThumbHeight"), ThumbHeight); view.SetDWORDValue(L"ThumbHeight", ThumbHeight);
view.SetDWORDValue(_T("ThumbWidth"), ThumbWidth); view.SetDWORDValue(L"ThumbWidth", ThumbWidth);
view.SetDWORDValue(_T("ThumbXPos"), ThumbXPos); view.SetDWORDValue(L"ThumbXPos", ThumbXPos);
view.SetDWORDValue(_T("ThumbYPos"), ThumbYPos); view.SetDWORDValue(L"ThumbYPos", ThumbYPos);
view.SetDWORDValue(_T("UnitSetting"), UnitSetting); view.SetDWORDValue(L"UnitSetting", UnitSetting);
view.SetDWORDValue(_T("ShowStatusBar"), ShowStatusBar); view.SetDWORDValue(L"ShowStatusBar", ShowStatusBar);
view.SetBinaryValue(_T("WindowPlacement"), &WindowPlacement, sizeof(WINDOWPLACEMENT)); view.SetBinaryValue(L"WindowPlacement", &WindowPlacement, sizeof(WINDOWPLACEMENT));
} }
CRegKey files; CRegKey files;
if (files.Create(paint, _T("Recent File List")) == ERROR_SUCCESS) if (files.Create(paint, L"Recent File List") == ERROR_SUCCESS)
{ {
WCHAR szName[64]; WCHAR szName[64];
for (INT iFile = 0; iFile < MAX_RECENT_FILES; ++iFile) for (INT iFile = 0; iFile < MAX_RECENT_FILES; ++iFile)
@ -213,45 +213,45 @@ void RegistrySettings::Store()
} }
CRegKey text; CRegKey text;
if (text.Create(paint, _T("Text")) == ERROR_SUCCESS) if (text.Create(paint, L"Text") == ERROR_SUCCESS)
{ {
text.SetDWORDValue(_T("Bold"), Bold); text.SetDWORDValue(L"Bold", Bold);
text.SetDWORDValue(_T("Italic"), Italic); text.SetDWORDValue(L"Italic", Italic);
text.SetDWORDValue(_T("Underline"), Underline); text.SetDWORDValue(L"Underline", Underline);
text.SetDWORDValue(_T("CharSet"), CharSet); text.SetDWORDValue(L"CharSet", CharSet);
text.SetDWORDValue(_T("PointSize"), PointSize); text.SetDWORDValue(L"PointSize", PointSize);
text.SetDWORDValue(_T("PositionX"), FontsPositionX); text.SetDWORDValue(L"PositionX", FontsPositionX);
text.SetDWORDValue(_T("PositionY"), FontsPositionY); text.SetDWORDValue(L"PositionY", FontsPositionY);
text.SetDWORDValue(_T("ShowTextTool"), ShowTextTool); text.SetDWORDValue(L"ShowTextTool", ShowTextTool);
text.SetStringValue(_T("TypeFaceName"), strFontName); text.SetStringValue(L"TypeFaceName", strFontName);
} }
CRegKey bar1; CRegKey bar1;
if (bar1.Create(paint, _T("General-Bar1")) == ERROR_SUCCESS) if (bar1.Create(paint, L"General-Bar1") == ERROR_SUCCESS)
{ {
bar1.SetDWORDValue(_T("BarID"), Bar1ID); bar1.SetDWORDValue(L"BarID", Bar1ID);
} }
CRegKey bar2; CRegKey bar2;
if (bar2.Create(paint, _T("General-Bar2")) == ERROR_SUCCESS) if (bar2.Create(paint, L"General-Bar2") == ERROR_SUCCESS)
{ {
bar2.SetDWORDValue(_T("BarID"), Bar2ID); bar2.SetDWORDValue(L"BarID", Bar2ID);
} }
CRegKey bar3; CRegKey bar3;
if (bar3.Create(paint, _T("General-Bar3")) == ERROR_SUCCESS) if (bar3.Create(paint, L"General-Bar3") == ERROR_SUCCESS)
{ {
bar3.SetDWORDValue(_T("Visible"), ShowToolBox); bar3.SetDWORDValue(L"Visible", ShowToolBox);
} }
CRegKey bar4; CRegKey bar4;
if (bar4.Create(paint, _T("General-Bar4")) == ERROR_SUCCESS) if (bar4.Create(paint, L"General-Bar4") == ERROR_SUCCESS)
{ {
bar4.SetDWORDValue(_T("Visible"), ShowPalette); bar4.SetDWORDValue(L"Visible", ShowPalette);
} }
} }
void RegistrySettings::SetMostRecentFile(LPCTSTR szPathName) void RegistrySettings::SetMostRecentFile(LPCWSTR szPathName)
{ {
// Register the file to the user's 'Recent' folder // Register the file to the user's 'Recent' folder
if (szPathName && szPathName[0]) if (szPathName && szPathName[0])
@ -265,7 +265,7 @@ void RegistrySettings::SetMostRecentFile(LPCTSTR szPathName)
if (iFound >= 0) if (iFound >= 0)
{ {
CString tmp = strFiles[i]; CStringW tmp = strFiles[i];
strFiles[i] = strFiles[i - 1]; strFiles[i] = strFiles[i - 1];
strFiles[i - 1] = tmp; strFiles[i - 1] = tmp;
} }

View file

@ -28,9 +28,9 @@ public:
DWORD UnitSetting; DWORD UnitSetting;
WINDOWPLACEMENT WindowPlacement; WINDOWPLACEMENT WindowPlacement;
CString strFiles[MAX_RECENT_FILES]; CStringW strFiles[MAX_RECENT_FILES];
CString strFontName; CStringW strFontName;
DWORD PointSize; DWORD PointSize;
DWORD Bold; DWORD Bold;
DWORD Italic; DWORD Italic;
@ -61,9 +61,9 @@ public:
STRETCHED STRETCHED
}; };
static void SetWallpaper(LPCTSTR szFileName, WallpaperStyle style); static void SetWallpaper(LPCWSTR szFileName, WallpaperStyle style);
void Load(INT nCmdShow); void Load(INT nCmdShow);
void Store(); void Store();
void SetMostRecentFile(LPCTSTR szPathName); void SetMostRecentFile(LPCWSTR szPathName);
}; };

View file

@ -139,7 +139,7 @@ void SelectionModel::DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTranspar
return; return;
BITMAP bm; BITMAP bm;
if (!GetObject(m_hbmColor, sizeof(BITMAP), &bm)) if (!GetObjectW(m_hbmColor, sizeof(BITMAP), &bm))
return; return;
COLORREF keyColor = (bBgTransparent ? crBg : CLR_INVALID); COLORREF keyColor = (bBgTransparent ? crBg : CLR_INVALID);
@ -516,7 +516,7 @@ void SelectionModel::InvertSelection()
TakeOff(); TakeOff();
BITMAP bm; BITMAP bm;
::GetObject(m_hbmColor, sizeof(bm), &bm); ::GetObjectW(m_hbmColor, sizeof(bm), &bm);
HDC hdc = ::CreateCompatibleDC(NULL); HDC hdc = ::CreateCompatibleDC(NULL);
HGDIOBJ hbmOld = ::SelectObject(hdc, m_hbmColor); HGDIOBJ hbmOld = ::SelectObject(hdc, m_hbmColor);

View file

@ -21,7 +21,7 @@ BOOL setCursorOnSizeBox(HITTEST hit)
{ {
if (HIT_UPPER_LEFT <= hit && hit <= HIT_LOWER_RIGHT) if (HIT_UPPER_LEFT <= hit && hit <= HIT_LOWER_RIGHT)
{ {
::SetCursor(::LoadCursor(NULL, s_cursor_shapes[hit - HIT_UPPER_LEFT])); ::SetCursor(::LoadCursorW(NULL, s_cursor_shapes[hit - HIT_UPPER_LEFT]));
return TRUE; return TRUE;
} }
return FALSE; return FALSE;

View file

@ -44,9 +44,9 @@ void CTextEditWindow::DrawGrip(HDC hDC, RECT& rc)
drawSizeBoxes(hDC, &rc, TRUE, NULL); drawSizeBoxes(hDC, &rc, TRUE, NULL);
} }
void CTextEditWindow::FixEditPos(LPCTSTR pszOldText) void CTextEditWindow::FixEditPos(LPCWSTR pszOldText)
{ {
CString szText; CStringW szText;
GetWindowText(szText); GetWindowText(szText);
RECT rcParent; RECT rcParent;
@ -62,10 +62,10 @@ void CTextEditWindow::FixEditPos(LPCTSTR pszOldText)
SelectObject(hDC, m_hFontZoomed); SelectObject(hDC, m_hFontZoomed);
TEXTMETRIC tm; TEXTMETRIC tm;
GetTextMetrics(hDC, &tm); GetTextMetrics(hDC, &tm);
szText += TEXT("x"); // This is a trick to enable the g_ptEnd newlines szText += L"x"; // This is a trick to enable the g_ptEnd newlines
const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP | const UINT uFormat = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_NOPREFIX | DT_NOCLIP |
DT_EXPANDTABS | DT_WORDBREAK; DT_EXPANDTABS | DT_WORDBREAK;
DrawText(hDC, szText, -1, &rcText, uFormat | DT_CALCRECT); DrawTextW(hDC, szText, -1, &rcText, uFormat | DT_CALCRECT);
if (tm.tmDescent > 0) if (tm.tmDescent > 0)
rcText.bottom += tm.tmDescent; rcText.bottom += tm.tmDescent;
ReleaseDC(hDC); ReleaseDC(hDC);
@ -91,7 +91,7 @@ LRESULT CTextEditWindow::OnChar(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
if (wParam == VK_TAB) if (wParam == VK_TAB)
return 0; // FIXME: Tabs return 0; // FIXME: Tabs
CString szText; CStringW szText;
GetWindowText(szText); GetWindowText(szText);
LRESULT ret = DefWindowProc(nMsg, wParam, lParam); LRESULT ret = DefWindowProc(nMsg, wParam, lParam);
@ -108,7 +108,7 @@ LRESULT CTextEditWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
return 0; return 0;
} }
CString szText; CStringW szText;
GetWindowText(szText); GetWindowText(szText);
LRESULT ret = DefWindowProc(nMsg, wParam, lParam); LRESULT ret = DefWindowProc(nMsg, wParam, lParam);
@ -135,7 +135,7 @@ LRESULT CTextEditWindow::OnEraseBkGnd(UINT nMsg, WPARAM wParam, LPARAM lParam, B
FillRect(hDC, &rc, hbr); FillRect(hDC, &rc, hbr);
DeleteObject(hbr); DeleteObject(hbr);
} }
SetTextColor(hDC, paletteModel.GetFgColor()); ::SetTextColor(hDC, paletteModel.GetFgColor());
return TRUE; return TRUE;
} }
@ -196,7 +196,7 @@ LRESULT CTextEditWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
UINT nHitTest = LOWORD(lParam); UINT nHitTest = LOWORD(lParam);
if (nHitTest == HTCAPTION) if (nHitTest == HTCAPTION)
{ {
::SetCursor(::LoadCursor(NULL, IDC_SIZEALL)); // Enable drag move ::SetCursor(::LoadCursorW(NULL, (LPCWSTR)IDC_SIZEALL)); // Enable drag move
return FALSE; return FALSE;
} }
return DefWindowProc(nMsg, wParam, lParam); return DefWindowProc(nMsg, wParam, lParam);
@ -336,7 +336,7 @@ void CTextEditWindow::UpdateFont()
m_hFontZoomed = NULL; m_hFontZoomed = NULL;
} }
LOGFONT lf; LOGFONTW lf;
ZeroMemory(&lf, sizeof(lf)); ZeroMemory(&lf, sizeof(lf));
lf.lfCharSet = DEFAULT_CHARSET; // registrySettings.CharSet; // Ignore lf.lfCharSet = DEFAULT_CHARSET; // registrySettings.CharSet; // Ignore
lf.lfWeight = (registrySettings.Bold ? FW_BOLD : FW_NORMAL); lf.lfWeight = (registrySettings.Bold ? FW_BOLD : FW_NORMAL);
@ -493,7 +493,7 @@ LRESULT CTextEditWindow::OnSizing(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
LRESULT CTextEditWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CTextEditWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
return ::SendMessage(GetParent(), nMsg, wParam, lParam); return ::SendMessageW(GetParent(), nMsg, wParam, lParam);
} }
LRESULT CTextEditWindow::OnCut(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CTextEditWindow::OnCut(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)

View file

@ -17,7 +17,7 @@ public:
HWND Create(HWND hwndParent); HWND Create(HWND hwndParent);
void DoFillBack(HWND hwnd, HDC hDC); void DoFillBack(HWND hwnd, HDC hDC);
void FixEditPos(LPCTSTR pszOldText); void FixEditPos(LPCWSTR pszOldText);
void InvalidateEditRect(); void InvalidateEditRect();
void UpdateFont(); void UpdateFont();
BOOL GetEditRect(LPRECT prc) const; BOOL GetEditRect(LPRECT prc) const;

View file

@ -20,12 +20,12 @@ CPaintToolBar::ToolBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
{ {
// We have to detect clicking on toolbar even if no change of pressed button // We have to detect clicking on toolbar even if no change of pressed button
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
INT index = (INT)::SendMessage(hwnd, TB_HITTEST, 0, (LPARAM)&pt); INT index = (INT)::SendMessageW(hwnd, TB_HITTEST, 0, (LPARAM)&pt);
if (index >= 0) if (index >= 0)
{ {
TBBUTTON button; TBBUTTON button;
if (::SendMessage(hwnd, TB_GETBUTTON, index, (LPARAM)&button)) if (::SendMessageW(hwnd, TB_GETBUTTON, index, (LPARAM)&button))
::PostMessage(::GetParent(hwnd), WM_COMMAND, button.idCommand, 0); ::PostMessageW(::GetParent(hwnd), WM_COMMAND, button.idCommand, 0);
} }
} }
return ::CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam); return ::CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
@ -42,26 +42,26 @@ BOOL CPaintToolBar::DoCreate(HWND hwndParent)
}; };
DWORD style = WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | DWORD style = WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE |
TBSTYLE_TOOLTIPS | TBSTYLE_FLAT; TBSTYLE_TOOLTIPS | TBSTYLE_FLAT;
if (!CWindow::Create(TOOLBARCLASSNAME, hwndParent, toolbarPos, NULL, style)) if (!CWindow::Create(TOOLBARCLASSNAMEW, hwndParent, toolbarPos, NULL, style))
return FALSE; return FALSE;
HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0); HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
SendMessage(TB_SETIMAGELIST, 0, (LPARAM)hImageList); SendMessage(TB_SETIMAGELIST, 0, (LPARAM)hImageList);
HBITMAP hbmIcons = (HBITMAP)::LoadImage(g_hinstExe, MAKEINTRESOURCE(IDB_TOOLBARICONS), HBITMAP hbmIcons = (HBITMAP)::LoadImageW(g_hinstExe, MAKEINTRESOURCEW(IDB_TOOLBARICONS),
IMAGE_BITMAP, 256, 16, 0); IMAGE_BITMAP, 256, 16, 0);
ImageList_AddMasked(hImageList, hbmIcons, RGB(255, 0, 255)); ImageList_AddMasked(hImageList, hbmIcons, RGB(255, 0, 255));
::DeleteObject(hbmIcons); ::DeleteObject(hbmIcons);
SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
TCHAR szToolTip[30]; WCHAR szToolTip[30];
TBBUTTON tbbutton; TBBUTTON tbbutton;
ZeroMemory(&tbbutton, sizeof(tbbutton)); ZeroMemory(&tbbutton, sizeof(tbbutton));
tbbutton.fsStyle = TBSTYLE_CHECKGROUP; tbbutton.fsStyle = TBSTYLE_CHECKGROUP;
for (INT i = 0; i < NUM_TOOLS; i++) for (INT i = 0; i < NUM_TOOLS; i++)
{ {
::LoadString(g_hinstExe, IDS_TOOLTIP1 + i, szToolTip, _countof(szToolTip)); ::LoadStringW(g_hinstExe, IDS_TOOLTIP1 + i, szToolTip, _countof(szToolTip));
tbbutton.iString = (INT_PTR)szToolTip; tbbutton.iString = (INT_PTR)szToolTip;
tbbutton.fsState = TBSTATE_ENABLED | ((i % 2 == 1) ? TBSTATE_WRAP : 0); tbbutton.fsState = TBSTATE_ENABLED | ((i % 2 == 1) ? TBSTATE_WRAP : 0);
tbbutton.idCommand = ID_FREESEL + i; tbbutton.idCommand = ID_FREESEL + i;

View file

@ -24,7 +24,7 @@ public:
class CToolBox : public CWindowImpl<CToolBox> class CToolBox : public CWindowImpl<CToolBox>
{ {
public: public:
DECLARE_WND_CLASS_EX(_T("ToolBox"), CS_DBLCLKS, COLOR_BTNFACE) DECLARE_WND_CLASS_EX(L"ToolBox", CS_DBLCLKS, COLOR_BTNFACE)
BEGIN_MSG_MAP(CToolBox) BEGIN_MSG_MAP(CToolBox)
MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_CREATE, OnCreate)

View file

@ -284,9 +284,9 @@ VOID CToolSettingsWindow::drawBox(HDC hdc, LPCRECT prc)
LRESULT CToolSettingsWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CToolSettingsWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
/* preloading the draw transparent/nontransparent icons for later use */ /* preloading the draw transparent/nontransparent icons for later use */
m_hNontranspIcon = (HICON)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_NONTRANSPARENT), m_hNontranspIcon = (HICON)LoadImageW(g_hinstExe, MAKEINTRESOURCEW(IDI_NONTRANSPARENT),
IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR); IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR);
m_hTranspIcon = (HICON)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_TRANSPARENT), m_hTranspIcon = (HICON)LoadImageW(g_hinstExe, MAKEINTRESOURCEW(IDI_TRANSPARENT),
IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR); IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR);
RECT trackbarZoomPos, rect2; RECT trackbarZoomPos, rect2;
@ -313,13 +313,13 @@ LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam,
INT zoomRate = toolsModel.GetZoom(); INT zoomRate = toolsModel.GetZoom();
CString strZoom; CStringW strZoom;
if (zoomRate % 10 == 0) if (zoomRate % 10 == 0)
strZoom.Format(_T("%d%%"), zoomRate / 10); strZoom.Format(L"%d%%", zoomRate / 10);
else else
strZoom.Format(_T("%d.%d%%"), zoomRate / 10, zoomRate % 10); strZoom.Format(L"%d.%d%%", zoomRate / 10, zoomRate % 10);
::SendMessage(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCTSTR)strZoom); ::SendMessageW(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCWSTR)strZoom);
OnToolsModelZoomChanged(nMsg, wParam, lParam, bHandled); OnToolsModelZoomChanged(nMsg, wParam, lParam, bHandled);
return 0; return 0;

View file

@ -10,7 +10,7 @@
class CToolSettingsWindow : public CWindowImpl<CToolSettingsWindow> class CToolSettingsWindow : public CWindowImpl<CToolSettingsWindow>
{ {
public: public:
DECLARE_WND_CLASS_EX(_T("ToolSettings"), CS_DBLCLKS, COLOR_BTNFACE) DECLARE_WND_CLASS_EX(L"ToolSettings", CS_DBLCLKS, COLOR_BTNFACE)
BEGIN_MSG_MAP(CToolSettingsWindow) BEGIN_MSG_MAP(CToolSettingsWindow)
MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_CREATE, OnCreate)

View file

@ -144,11 +144,11 @@ void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
if (g_askBeforeEnlarging) if (g_askBeforeEnlarging)
{ {
TCHAR programname[20]; WCHAR programname[20];
TCHAR shouldEnlargePromptText[100]; WCHAR shouldEnlargePromptText[100];
LoadString(g_hinstExe, IDS_PROGRAMNAME, programname, _countof(programname)); ::LoadStringW(g_hinstExe, IDS_PROGRAMNAME, programname, _countof(programname));
LoadString(g_hinstExe, IDS_ENLARGEPROMPTTEXT, shouldEnlargePromptText, _countof(shouldEnlargePromptText)); ::LoadStringW(g_hinstExe, IDS_ENLARGEPROMPTTEXT, shouldEnlargePromptText, _countof(shouldEnlargePromptText));
switch (MessageBox(shouldEnlargePromptText, programname, MB_YESNOCANCEL | MB_ICONQUESTION)) switch (MessageBox(shouldEnlargePromptText, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
{ {
@ -233,7 +233,7 @@ LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
TCHAR droppedfile[MAX_PATH]; WCHAR droppedfile[MAX_PATH];
HDROP hDrop = (HDROP)wParam; HDROP hDrop = (HDROP)wParam;
DragQueryFile(hDrop, 0, droppedfile, _countof(droppedfile)); DragQueryFile(hDrop, 0, droppedfile, _countof(droppedfile));
@ -247,14 +247,14 @@ LRESULT CMainWindow::OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
LRESULT CMainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) LRESULT CMainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ {
// Loading and setting the window menu from resource // Loading and setting the window menu from resource
m_hMenu = ::LoadMenu(g_hinstExe, MAKEINTRESOURCE(ID_MENU)); m_hMenu = ::LoadMenuW(g_hinstExe, MAKEINTRESOURCEW(ID_MENU));
SetMenu(m_hMenu); SetMenu(m_hMenu);
// Create the status bar // Create the status bar
DWORD style = SBARS_SIZEGRIP | WS_CHILD | (registrySettings.ShowStatusBar ? WS_VISIBLE : 0); DWORD style = SBARS_SIZEGRIP | WS_CHILD | (registrySettings.ShowStatusBar ? WS_VISIBLE : 0);
g_hStatusBar = ::CreateWindowEx(0, STATUSCLASSNAME, NULL, style, 0, 0, 0, 0, m_hWnd, g_hStatusBar = ::CreateWindowExW(0, STATUSCLASSNAME, NULL, style, 0, 0, 0, 0, m_hWnd,
NULL, g_hinstExe, NULL); NULL, g_hinstExe, NULL);
::SendMessage(g_hStatusBar, SB_SETMINHEIGHT, 21, 0); ::SendMessageW(g_hStatusBar, SB_SETMINHEIGHT, 21, 0);
// Create the tool box // Create the tool box
toolBoxContainer.DoCreate(m_hWnd); toolBoxContainer.DoCreate(m_hWnd);
@ -276,8 +276,8 @@ LRESULT CMainWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHa
} }
// Set icon // Set icon
SendMessage(WM_SETICON, ICON_BIG, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON))); SendMessage(WM_SETICON, ICON_BIG, (LPARAM)::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
SendMessage(WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON))); SendMessage(WM_SETICON, ICON_SMALL, (LPARAM)::LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
return 0; return 0;
} }
@ -314,10 +314,10 @@ BOOL CMainWindow::ConfirmSave()
if (imageModel.IsImageSaved()) if (imageModel.IsImageSaved())
return TRUE; return TRUE;
CString strProgramName; CStringW strProgramName;
strProgramName.LoadString(IDS_PROGRAMNAME); strProgramName.LoadString(IDS_PROGRAMNAME);
CString strSavePromptText; CStringW strSavePromptText;
strSavePromptText.Format(IDS_SAVEPROMPTTEXT, PathFindFileName(g_szFileName)); strSavePromptText.Format(IDS_SAVEPROMPTTEXT, PathFindFileName(g_szFileName));
switch (MessageBox(strSavePromptText, strProgramName, MB_YESNOCANCEL | MB_ICONQUESTION)) switch (MessageBox(strSavePromptText, strProgramName, MB_YESNOCANCEL | MB_ICONQUESTION))
@ -345,11 +345,11 @@ LRESULT CMainWindow::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
void CMainWindow::ProcessFileMenu(HMENU hPopupMenu) void CMainWindow::ProcessFileMenu(HMENU hPopupMenu)
{ {
LPCTSTR dotext = PathFindExtensionW(g_szFileName); LPCWSTR dotext = PathFindExtensionW(g_szFileName);
BOOL isBMP = FALSE; BOOL isBMP = FALSE;
if (_tcsicmp(dotext, _T(".bmp")) == 0 || if (_wcsicmp(dotext, L".bmp") == 0 ||
_tcsicmp(dotext, _T(".dib")) == 0 || _wcsicmp(dotext, L".dib") == 0 ||
_tcsicmp(dotext, _T(".rle")) == 0) _wcsicmp(dotext, L".rle") == 0)
{ {
isBMP = TRUE; isBMP = TRUE;
} }
@ -371,7 +371,7 @@ void CMainWindow::ProcessFileMenu(HMENU hPopupMenu)
for (INT iItem = 0; iItem < MAX_RECENT_FILES; ++iItem) for (INT iItem = 0; iItem < MAX_RECENT_FILES; ++iItem)
{ {
CString& strFile = registrySettings.strFiles[iItem]; CStringW& strFile = registrySettings.strFiles[iItem];
if (strFile.IsEmpty()) if (strFile.IsEmpty())
break; break;
@ -379,7 +379,7 @@ void CMainWindow::ProcessFileMenu(HMENU hPopupMenu)
#define MAX_RECENT_PATHNAME_DISPLAY 30 #define MAX_RECENT_PATHNAME_DISPLAY 30
CPath pathFile(strFile); CPath pathFile(strFile);
pathFile.CompactPathEx(MAX_RECENT_PATHNAME_DISPLAY); pathFile.CompactPathEx(MAX_RECENT_PATHNAME_DISPLAY);
assert(_tcslen((LPCTSTR)pathFile) <= MAX_RECENT_PATHNAME_DISPLAY); assert(wcslen((LPCWSTR)pathFile) <= MAX_RECENT_PATHNAME_DISPLAY);
// Add an accelerator (by '&') to the item number for quick access // Add an accelerator (by '&') to the item number for quick access
WCHAR szText[4 + MAX_RECENT_PATHNAME_DISPLAY + 1]; WCHAR szText[4 + MAX_RECENT_PATHNAME_DISPLAY + 1];
@ -489,8 +489,8 @@ LRESULT CMainWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand
int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 }; int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 };
if (::IsWindow(g_hStatusBar)) if (::IsWindow(g_hStatusBar))
{ {
::SendMessage(g_hStatusBar, WM_SIZE, 0, 0); ::SendMessageW(g_hStatusBar, WM_SIZE, 0, 0);
::SendMessage(g_hStatusBar, SB_SETPARTS, 3, (LPARAM)&test); ::SendMessageW(g_hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
} }
alignChildrenToMainWindow(); alignChildrenToMainWindow();
return 0; return 0;
@ -516,7 +516,7 @@ LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
if (canvasWindow.m_hWnd == hwndCapture || if (canvasWindow.m_hWnd == hwndCapture ||
fullscreenWindow.m_hWnd == hwndCapture) fullscreenWindow.m_hWnd == hwndCapture)
{ {
::SendMessage(hwndCapture, nMsg, wParam, lParam); ::SendMessageW(hwndCapture, nMsg, wParam, lParam);
} }
} }
else if (selectionModel.m_bShow) else if (selectionModel.m_bShow)
@ -551,7 +551,7 @@ LRESULT CMainWindow::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, B
{ {
/* Redirect message to common controls */ /* Redirect message to common controls */
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL); HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
SendMessage(hToolbar, WM_SYSCOLORCHANGE, 0, 0); ::SendMessageW(hToolbar, WM_SYSCOLORCHANGE, 0, 0);
return 0; return 0;
} }
@ -569,12 +569,11 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
{ {
case IDM_HELPINFO: case IDM_HELPINFO:
{ {
TCHAR infotitle[100]; WCHAR infotitle[100], infotext[200];
TCHAR infotext[200]; ::LoadStringW(g_hinstExe, IDS_INFOTITLE, infotitle, _countof(infotitle));
LoadString(g_hinstExe, IDS_INFOTITLE, infotitle, _countof(infotitle)); ::LoadStringW(g_hinstExe, IDS_INFOTEXT, infotext, _countof(infotext));
LoadString(g_hinstExe, IDS_INFOTEXT, infotext, _countof(infotext)); ::ShellAboutW(m_hWnd, infotitle, infotext,
ShellAbout(m_hWnd, infotitle, infotext, LoadIconW(g_hinstExe, MAKEINTRESOURCEW(IDI_APPICON)));
LoadIcon(g_hinstExe, MAKEINTRESOURCE(IDI_APPICON)));
break; break;
} }
case IDM_HELPHELPTOPICS: case IDM_HELPHELPTOPICS:
@ -591,7 +590,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
break; break;
case IDM_FILEOPEN: case IDM_FILEOPEN:
{ {
TCHAR szFileName[MAX_LONG_PATH] = _T(""); WCHAR szFileName[MAX_LONG_PATH] = L"";
if (ConfirmSave() && GetOpenFileName(szFileName, _countof(szFileName))) if (ConfirmSave() && GetOpenFileName(szFileName, _countof(szFileName)))
{ {
DoLoadImageFile(m_hWnd, szFileName, TRUE); DoLoadImageFile(m_hWnd, szFileName, TRUE);
@ -628,7 +627,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
pd.nMaxPage = 0xffff; pd.nMaxPage = 0xffff;
if (PrintDlg(&pd) == TRUE) if (PrintDlg(&pd) == TRUE)
{ {
BitBlt(pd.hDC, 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), imageModel.GetDC(), 0, 0, SRCCOPY); ::BitBlt(pd.hDC, 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), imageModel.GetDC(), 0, 0, SRCCOPY);
DeleteDC(pd.hDC); DeleteDC(pd.hDC);
} }
if (pd.hDevMode) if (pd.hDevMode)
@ -795,7 +794,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
// Failed to paste // Failed to paste
{ {
CString strText, strTitle; CStringW strText, strTitle;
strText.LoadString(IDS_CANTPASTE); strText.LoadString(IDS_CANTPASTE);
strTitle.LoadString(IDS_PROGRAMNAME); strTitle.LoadString(IDS_PROGRAMNAME);
MessageBox(strText, strTitle, MB_ICONINFORMATION); MessageBox(strText, strTitle, MB_ICONINFORMATION);
@ -833,7 +832,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
break; break;
} }
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL); HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0)); ::SendMessageW(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
toolsModel.selectAll(); toolsModel.selectAll();
canvasWindow.Invalidate(TRUE); canvasWindow.Invalidate(TRUE);
break; break;
@ -841,7 +840,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
case IDM_EDITCOPYTO: case IDM_EDITCOPYTO:
{ {
WCHAR szFileName[MAX_LONG_PATH]; WCHAR szFileName[MAX_LONG_PATH];
LoadStringW(g_hinstExe, IDS_DEFAULTFILENAME, szFileName, _countof(szFileName)); ::LoadStringW(g_hinstExe, IDS_DEFAULTFILENAME, szFileName, _countof(szFileName));
if (GetSaveFileName(szFileName, _countof(szFileName))) if (GetSaveFileName(szFileName, _countof(szFileName)))
{ {
HBITMAP hbmSelection = selectionModel.GetSelectionContents(); HBITMAP hbmSelection = selectionModel.GetSelectionContents();
@ -948,8 +947,8 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
CWaitCursor waitCursor; CWaitCursor waitCursor;
if (attributesDialog.m_bBlackAndWhite && !imageModel.IsBlackAndWhite()) if (attributesDialog.m_bBlackAndWhite && !imageModel.IsBlackAndWhite())
{ {
CString strText(MAKEINTRESOURCE(IDS_LOSECOLOR)); CStringW strText(MAKEINTRESOURCEW(IDS_LOSECOLOR));
CString strTitle(MAKEINTRESOURCE(IDS_PROGRAMNAME)); CStringW strTitle(MAKEINTRESOURCEW(IDS_PROGRAMNAME));
INT id = MessageBox(strText, strTitle, MB_ICONINFORMATION | MB_YESNOCANCEL); INT id = MessageBox(strText, strTitle, MB_ICONINFORMATION | MB_YESNOCANCEL);
if (id != IDYES) if (id != IDYES)
break; break;

View file

@ -11,7 +11,7 @@
class CMainWindow : public CWindowImpl<CMainWindow> class CMainWindow : public CWindowImpl<CMainWindow>
{ {
public: public:
DECLARE_WND_CLASS_EX(_T("MSPaintApp"), CS_DBLCLKS, COLOR_BTNFACE) DECLARE_WND_CLASS_EX(L"MSPaintApp", CS_DBLCLKS, COLOR_BTNFACE)
BEGIN_MSG_MAP(CMainWindow) BEGIN_MSG_MAP(CMainWindow)
MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles) MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)
@ -30,8 +30,8 @@ public:
CMainWindow() : m_hMenu(NULL) { } CMainWindow() : m_hMenu(NULL) { }
HWND DoCreate(); HWND DoCreate();
BOOL GetOpenFileName(IN OUT LPTSTR pszFile, INT cchMaxFile); BOOL GetOpenFileName(IN OUT LPWSTR pszFile, INT cchMaxFile);
BOOL GetSaveFileName(IN OUT LPTSTR pszFile, INT cchMaxFile); BOOL GetSaveFileName(IN OUT LPWSTR pszFile, INT cchMaxFile);
BOOL ChooseColor(IN OUT COLORREF *prgbColor); BOOL ChooseColor(IN OUT COLORREF *prgbColor);
VOID TrackPopupMenu(POINT ptScreen, INT iSubMenu); VOID TrackPopupMenu(POINT ptScreen, INT iSubMenu);
BOOL CanUndo() const; BOOL CanUndo() const;