Attempting to fix GCC cross initialization errors.

This commit is contained in:
Quantum 2013-09-07 20:39:15 -04:00
parent d981000d09
commit f84ad63e63
2 changed files with 15 additions and 10 deletions

View file

@ -11,6 +11,8 @@ void MainWindow::OnLoadFile()
HANDLE file = INVALID_HANDLE_VALUE, mapping = 0; HANDLE file = INVALID_HANDLE_VALUE, mapping = 0;
LPSTR data = NULL; LPSTR data = NULL;
LPWSTR storage = NULL; LPWSTR storage = NULL;
int codepage = 0
DWORD size = 0, length = 0;
ofn.hwndOwner = m_hwnd; ofn.hwndOwner = m_hwnd;
ofn.lpstrFilter = L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; ofn.lpstrFilter = L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
@ -29,7 +31,7 @@ void MainWindow::OnLoadFile()
return; return;
} }
DWORD length = GetFileSize(file, NULL); length = GetFileSize(file, NULL);
if (!length) { if (!length) {
MessageBox(m_hwnd, L"You have to choose a file with contents!", MessageBox(m_hwnd, L"You have to choose a file with contents!",
L"Zero size file", MB_ICONERROR); L"Zero size file", MB_ICONERROR);
@ -47,8 +49,8 @@ void MainWindow::OnLoadFile()
TellError(L"Failed to Load File into Memory", m_hwnd); TellError(L"Failed to Load File into Memory", m_hwnd);
goto cleanup; goto cleanup;
} }
int codepage = IsDlgButtonChecked(m_hwnd, ZALGO_USE_UTF8) ? CP_UTF8 : CP_ACP; codepage = IsDlgButtonChecked(m_hwnd, ZALGO_USE_UTF8) ? CP_UTF8 : CP_ACP;
DWORD size = MultiByteToWideChar(codepage, 0, data, -1, NULL, 0); size = MultiByteToWideChar(codepage, 0, data, -1, NULL, 0);
storage = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); storage = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
if (!storage) { if (!storage) {
@ -85,6 +87,9 @@ void MainWindow::OnSaveFile()
LPWSTR data = NULL; LPWSTR data = NULL;
LPSTR storage = NULL; LPSTR storage = NULL;
HANDLE file = INVALID_HANDLE_VALUE; HANDLE file = INVALID_HANDLE_VALUE;
HLOCAL buf = NULL;
int codepage = 0;
DWORD length = 0, size = 0, written = 0;
ofn.hwndOwner = m_hwnd; ofn.hwndOwner = m_hwnd;
ofn.lpstrFilter = L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; ofn.lpstrFilter = L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
@ -97,11 +102,11 @@ void MainWindow::OnSaveFile()
if (!GetSaveFileName(&ofn)) if (!GetSaveFileName(&ofn))
return; return;
HLOCAL buf = Edit_GetHandle(m_message); buf = Edit_GetHandle(m_message);
data = (LPWSTR) LocalLock(buf); data = (LPWSTR) LocalLock(buf);
int codepage = IsDlgButtonChecked(m_hwnd, ZALGO_USE_UTF8) ? CP_UTF8 : CP_ACP; codepage = IsDlgButtonChecked(m_hwnd, ZALGO_USE_UTF8) ? CP_UTF8 : CP_ACP;
int size = WideCharToMultiByte(codepage, 0, data, -1, NULL, 0, NULL, NULL); size = WideCharToMultiByte(codepage, 0, data, -1, NULL, 0, NULL, NULL);
storage = (LPSTR) HeapAlloc(GetProcessHeap(), 0, size); storage = (LPSTR) HeapAlloc(GetProcessHeap(), 0, size);
if (!storage) { if (!storage) {
@ -122,8 +127,7 @@ void MainWindow::OnSaveFile()
goto cleanup; goto cleanup;
} }
DWORD length = lstrlenA(storage); length = lstrlenA(storage);
DWORD written;
if (!WriteFile(file, storage, length, &written, NULL)) if (!WriteFile(file, storage, length, &written, NULL))
TellError(L"Failed to Write to Save File", m_hwnd); TellError(L"Failed to Write to Save File", m_hwnd);

View file

@ -32,6 +32,7 @@ void PreviewWindow::OnPaint()
PAINTSTRUCT ps; PAINTSTRUCT ps;
SCROLLINFO si; SCROLLINFO si;
RECT rect; RECT rect;
int FirstLine, LastLine;
BeginPaint(m_hwnd, &ps); BeginPaint(m_hwnd, &ps);
GetClientRect(m_hwnd, &rect); GetClientRect(m_hwnd, &rect);
@ -47,8 +48,8 @@ void PreviewWindow::OnPaint()
SelectObject(ps.hdc, hFont); SelectObject(ps.hdc, hFont);
SetBkMode(ps.hdc, TRANSPARENT); SetBkMode(ps.hdc, TRANSPARENT);
// Find painting limits. // Find painting limits.
int FirstLine = max(0, yPos + ps.rcPaint.top / yChar); FirstLine = max(0, yPos + ps.rcPaint.top / yChar);
int LastLine = min(lines - 1, yPos + ps.rcPaint.bottom / yChar); LastLine = min(lines - 1, yPos + ps.rcPaint.bottom / yChar);
// Get horizontal scroll bar position. // Get horizontal scroll bar position.
GetScrollInfo(m_hwnd, SB_HORZ, &si); GetScrollInfo(m_hwnd, SB_HORZ, &si);