[PAINT] rearranging variable declarations for better MSVC compatiblity

svn path=/trunk/; revision=43615
This commit is contained in:
Benedikt Freisen 2009-10-19 17:46:29 +00:00
parent 56d94b0f4e
commit 9b45c01052
3 changed files with 41 additions and 33 deletions

View file

@ -73,30 +73,34 @@ LRESULT CALLBACK ATTDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l
switch (message) switch (message)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
CheckDlgButton(hwnd, IDD_ATTRIBUTESRB3, BST_CHECKED);
CheckDlgButton(hwnd, IDD_ATTRIBUTESRB5, BST_CHECKED);
SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, imgXRes, FALSE);
SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, imgYRes, FALSE);
TCHAR strrc[100];
if (isAFile)
{ {
TCHAR date[100]; TCHAR strrc[100];
TCHAR size[100]; TCHAR res[100];
TCHAR temp[100];
GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, sizeof(date)); CheckDlgButton(hwnd, IDD_ATTRIBUTESRB3, BST_CHECKED);
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, sizeof(temp)); CheckDlgButton(hwnd, IDD_ATTRIBUTESRB5, BST_CHECKED);
_tcscat(date, _T(" ")); SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, imgXRes, FALSE);
_tcscat(date, temp); SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, imgYRes, FALSE);
LoadString(hProgInstance, IDS_FILESIZE, strrc, sizeof(strrc));
_stprintf(size, strrc, fileSize); if (isAFile)
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT6, date); {
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT7, size); TCHAR date[100];
TCHAR size[100];
TCHAR temp[100];
GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, sizeof(date));
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, sizeof(temp));
_tcscat(date, _T(" "));
_tcscat(date, temp);
LoadString(hProgInstance, IDS_FILESIZE, strrc, sizeof(strrc));
_stprintf(size, strrc, fileSize);
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT6, date);
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT7, size);
}
LoadString(hProgInstance, IDS_PRINTRES, strrc, sizeof(strrc));
_stprintf(res, strrc, fileHPPM, fileVPPM);
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT8, res);
return TRUE;
} }
TCHAR res[100];
LoadString(hProgInstance, IDS_PRINTRES, strrc, sizeof(strrc));
_stprintf(res, strrc, fileHPPM, fileVPPM);
SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT8, res);
return TRUE;
case WM_CLOSE: case WM_CLOSE:
EndDialog(hwnd, 0); EndDialog(hwnd, 0);
break; break;

View file

@ -351,8 +351,8 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR l
{ {
TCHAR tempstr[1000]; TCHAR tempstr[1000];
TCHAR resstr[100]; TCHAR resstr[100];
insertReversible(bmNew);
TCHAR *temp; TCHAR *temp;
insertReversible(bmNew);
GetFullPathName(lpszArgument, sizeof(filepathname), filepathname, &temp); GetFullPathName(lpszArgument, sizeof(filepathname), filepathname, &temp);
_tcscpy(filename, temp); _tcscpy(filename, temp);
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr)); LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));

View file

@ -50,11 +50,14 @@ void updateCanvasAndScrollbars()
void zoomTo(int newZoom, int mouseX, int mouseY) void zoomTo(int newZoom, int mouseX, int mouseY)
{ {
int tbPos = 0;
int tempZoom = newZoom;
long clientRectScrollbox[4]; long clientRectScrollbox[4];
long clientRectImageArea[4]; long clientRectImageArea[4];
int x, y, w, h;
GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox); GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox);
GetClientRect(hImageArea, (LPRECT)&clientRectImageArea); GetClientRect(hImageArea, (LPRECT)&clientRectImageArea);
int x, y, w, h;
w = clientRectImageArea[2] * clientRectScrollbox[2] / (clientRectImageArea[2] * newZoom / zoom); w = clientRectImageArea[2] * clientRectScrollbox[2] / (clientRectImageArea[2] * newZoom / zoom);
h = clientRectImageArea[3] * clientRectScrollbox[3] / (clientRectImageArea[3] * newZoom / zoom); h = clientRectImageArea[3] * clientRectScrollbox[3] / (clientRectImageArea[3] * newZoom / zoom);
x = max(0, min(clientRectImageArea[2] - w, mouseX - w / 2)) * newZoom / zoom; x = max(0, min(clientRectImageArea[2] - w, mouseX - w / 2)) * newZoom / zoom;
@ -70,8 +73,6 @@ void zoomTo(int newZoom, int mouseX, int mouseY)
SendMessage(hScrollbox, WM_HSCROLL, SB_THUMBPOSITION | (x << 16), 0); SendMessage(hScrollbox, WM_HSCROLL, SB_THUMBPOSITION | (x << 16), 0);
SendMessage(hScrollbox, WM_VSCROLL, SB_THUMBPOSITION | (y << 16), 0); SendMessage(hScrollbox, WM_VSCROLL, SB_THUMBPOSITION | (y << 16), 0);
int tbPos = 0;
int tempZoom = newZoom;
while (tempZoom>125) while (tempZoom>125)
{ {
tbPos++; tbPos++;
@ -82,24 +83,26 @@ void zoomTo(int newZoom, int mouseX, int mouseY)
void drawZoomFrame(int mouseX, int mouseY) void drawZoomFrame(int mouseX, int mouseY)
{ {
HDC hdc;
HPEN oldPen;
HBRUSH oldBrush;
LOGBRUSH logbrush;
int rop;
long clientRectScrollbox[4]; long clientRectScrollbox[4];
long clientRectImageArea[4]; long clientRectImageArea[4];
int x, y, w, h;
GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox); GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox);
GetClientRect(hImageArea, (LPRECT)&clientRectImageArea); GetClientRect(hImageArea, (LPRECT)&clientRectImageArea);
int x, y, w, h;
w = clientRectImageArea[2] * clientRectScrollbox[2] / (clientRectImageArea[2] * 2); w = clientRectImageArea[2] * clientRectScrollbox[2] / (clientRectImageArea[2] * 2);
h = clientRectImageArea[3] * clientRectScrollbox[3] / (clientRectImageArea[3] * 2); h = clientRectImageArea[3] * clientRectScrollbox[3] / (clientRectImageArea[3] * 2);
x = max(0, min(clientRectImageArea[2] - w, mouseX - w / 2)); x = max(0, min(clientRectImageArea[2] - w, mouseX - w / 2));
y = max(0, min(clientRectImageArea[3] - h, mouseY - h / 2)); y = max(0, min(clientRectImageArea[3] - h, mouseY - h / 2));
HDC hdc;
hdc = GetDC(hImageArea); hdc = GetDC(hImageArea);
HPEN oldPen;
oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 0, 0)); oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 0, 0));
HBRUSH oldBrush;
LOGBRUSH logbrush;
logbrush.lbStyle = BS_HOLLOW; logbrush.lbStyle = BS_HOLLOW;
oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush));
int rop;
rop = SetROP2(hdc, R2_NOT); rop = SetROP2(hdc, R2_NOT);
Rectangle(hdc, x, y, x + w, y + h); Rectangle(hdc, x, y, x + w, y + h);
SetROP2(hdc, rop); SetROP2(hdc, rop);
@ -525,6 +528,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
{ {
if ((!drawing)||(activeTool<=9)) if ((!drawing)||(activeTool<=9))
{ {
TRACKMOUSEEVENT tme;
TCHAR coordStr[100]; TCHAR coordStr[100];
_stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom); _stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom);
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)coordStr); SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)coordStr);
@ -535,7 +540,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
drawZoomFrame((short)LOWORD(lParam), (short)HIWORD(lParam)); drawZoomFrame((short)LOWORD(lParam), (short)HIWORD(lParam));
} }
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE; tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hImageArea; tme.hwndTrack = hImageArea;