Commit b6959241 authored by Alexander Nicolaysen Sørnes's avatar Alexander Nicolaysen Sørnes Committed by Alexandre Julliard

wordpad: Show error if file open fails.

parent 5aa90f37
......@@ -236,4 +236,6 @@ BEGIN
STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
STRING_WRITE_FAILED, "Could not save the file."
STRING_WRITE_ACCESS_DENIED, "You do not have access to save the file."
STRING_OPEN_FAILED, "Could not open the file."
STRING_OPEN_ACCESS_DENIED, "You do not have access to open the file."
END
......@@ -236,4 +236,6 @@ BEGIN
STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
STRING_WRITE_FAILED, "Klarte ikke lagre filen."
STRING_WRITE_ACCESS_DENIED, "Du har ikke tilgang til lagre filen."
STRING_OPEN_FAILED, "Klarte ikke pne filen."
STRING_OPEN_ACCESS_DENIED, "Du har ikke tilgang til pne filen."
END
......@@ -698,6 +698,22 @@ static void set_fileformat(WPARAM format)
target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);
}
static void ShowOpenError(DWORD Code)
{
LPWSTR Message;
switch(Code)
{
case ERROR_ACCESS_DENIED:
Message = MAKEINTRESOURCEW(STRING_OPEN_ACCESS_DENIED);
break;
default:
Message = MAKEINTRESOURCEW(STRING_OPEN_FAILED);
}
MessageBoxW(hMainWnd, Message, wszAppTitle, MB_ICONEXCLAMATION | MB_OK);
}
static void DoOpenFile(LPCWSTR szOpenFileName)
{
HANDLE hFile;
......@@ -709,7 +725,10 @@ static void DoOpenFile(LPCWSTR szOpenFileName)
hFile = CreateFileW(szOpenFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
ShowOpenError(GetLastError());
return;
}
ReadFile(hFile, fileStart, 5, &readOut, NULL);
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
......
......@@ -195,6 +195,8 @@
#define STRING_OLE_STORAGE_NOT_SUPPORTED 1706
#define STRING_WRITE_FAILED 1707
#define STRING_WRITE_ACCESS_DENIED 1708
#define STRING_OPEN_FAILED 1709
#define STRING_OPEN_ACCESS_DENIED 1710
LPWSTR file_basename(LPWSTR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment