mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-21 17:09:06 -07:00
wordpad: Open .wri files in wordpad.
This commit is contained in:
parent
17cb1c827d
commit
f3425cfe41
2 changed files with 121 additions and 2 deletions
|
@ -41,7 +41,8 @@ static const WCHAR wszRichEditClass[] = {'R','I','C','H','E','D','I','T','2','0'
|
|||
static const WCHAR wszMainWndClass[] = {'W','O','R','D','P','A','D','T','O','P',0};
|
||||
static const WCHAR wszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0};
|
||||
|
||||
static HWND hMainWnd = NULL;
|
||||
static HWND hMainWnd;
|
||||
static HWND hEditorWnd;
|
||||
|
||||
static void AddButton(HWND hwndToolBar, int nImage, int nCommand)
|
||||
{
|
||||
|
@ -71,9 +72,122 @@ static void AddSeparator(HWND hwndToolBar)
|
|||
SendMessage(hwndToolBar, TB_ADDBUTTONS, 1, (LPARAM)&button);
|
||||
}
|
||||
|
||||
static LPSTR stream_buffer;
|
||||
static LONG stream_buffer_size;
|
||||
|
||||
static DWORD CALLBACK stream_in(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
|
||||
{
|
||||
LONG size = min(stream_buffer_size, cb);
|
||||
|
||||
memcpy(buffer, stream_buffer, size);
|
||||
stream_buffer_size -= size;
|
||||
stream_buffer += size;
|
||||
*pcb = size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DoOpenFile(LPCWSTR szFileName)
|
||||
{
|
||||
HANDLE hFile;
|
||||
LPSTR pTemp;
|
||||
DWORD size;
|
||||
DWORD dwNumRead;
|
||||
EDITSTREAM es;
|
||||
|
||||
hFile = CreateFileW(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
|
||||
size = GetFileSize(hFile, NULL);
|
||||
if (size == INVALID_FILE_SIZE)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
return;
|
||||
}
|
||||
size++;
|
||||
|
||||
pTemp = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
if (!pTemp)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ReadFile(hFile, pTemp, size, &dwNumRead, NULL))
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
HeapFree(GetProcessHeap(), 0, pTemp);
|
||||
return;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
pTemp[dwNumRead] = 0;
|
||||
|
||||
memset(&es, 0, sizeof(es));
|
||||
es.pfnCallback = stream_in;
|
||||
|
||||
stream_buffer = pTemp;
|
||||
stream_buffer_size = size;
|
||||
|
||||
SendMessage(hEditorWnd, EM_STREAMIN, SF_RTF, (LPARAM)&es);
|
||||
HeapFree(GetProcessHeap(), 0, pTemp);
|
||||
|
||||
SetFocus(hEditorWnd);
|
||||
}
|
||||
|
||||
static void HandleCommandLine(LPWSTR cmdline)
|
||||
{
|
||||
WCHAR delimiter;
|
||||
int opt_print = 0;
|
||||
|
||||
/* skip white space */
|
||||
while (*cmdline == ' ') cmdline++;
|
||||
|
||||
/* skip executable name */
|
||||
delimiter = (*cmdline == '"' ? '"' : ' ');
|
||||
|
||||
if (*cmdline == delimiter) cmdline++;
|
||||
while (*cmdline && *cmdline != delimiter) cmdline++;
|
||||
if (*cmdline == delimiter) cmdline++;
|
||||
|
||||
while (*cmdline == ' ' || *cmdline == '-' || *cmdline == '/')
|
||||
{
|
||||
WCHAR option;
|
||||
|
||||
if (*cmdline++ == ' ') continue;
|
||||
|
||||
option = *cmdline;
|
||||
if (option) cmdline++;
|
||||
while (*cmdline == ' ') cmdline++;
|
||||
|
||||
switch (option)
|
||||
{
|
||||
case 'p':
|
||||
case 'P':
|
||||
opt_print = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*cmdline)
|
||||
{
|
||||
/* file name is passed on the command line */
|
||||
if (cmdline[0] == '"')
|
||||
{
|
||||
cmdline++;
|
||||
cmdline[lstrlenW(cmdline) - 1] = 0;
|
||||
}
|
||||
DoOpenFile(cmdline);
|
||||
InvalidateRect(hMainWnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
if (opt_print)
|
||||
MessageBox(hMainWnd, "Printing not implemented", "WordPad", MB_OK);
|
||||
}
|
||||
|
||||
static LRESULT OnCreate( HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hEditorWnd, hToolBarWnd, hReBarWnd;
|
||||
HWND hToolBarWnd, hReBarWnd;
|
||||
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
|
||||
HANDLE hDLL;
|
||||
TBADDBITMAP ab;
|
||||
|
@ -500,6 +614,8 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar
|
|||
CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, hInstance, NULL);
|
||||
ShowWindow(hMainWnd, SW_SHOWMAXIMIZED);
|
||||
|
||||
HandleCommandLine(GetCommandLineW());
|
||||
|
||||
while(GetMessage(&msg,0,0,0))
|
||||
{
|
||||
if (TranslateAccelerator(hMainWnd, hAccel, &msg))
|
||||
|
|
|
@ -99,6 +99,7 @@ HKCR,.msi,,2,"Msi.Package"
|
|||
HKCR,.tif,"Content Type",2,"image/tiff"
|
||||
HKCR,.tiff,"Content Type",2,"image/tiff"
|
||||
HKCR,.txt,,2,"txtfile"
|
||||
HKCR,.wri,,2,"wrifile"
|
||||
HKCR,.wav,"Content Type",2,"audio/wav"
|
||||
HKCR,.xml,"Content Type",2,"text/xml"
|
||||
HKCR,.xsl,"Content Type",2,"text/xsl"
|
||||
|
@ -123,6 +124,8 @@ HKCR,Msi.Package\shell\Repair\command,,2,"msiexec /f %1"
|
|||
HKCR,Msi.Package\shell\Uninstall\command,,2,"msiexec /x %1"
|
||||
HKCR,txtfile\shell\open\command,,2,"%11%\notepad.exe %1"
|
||||
HKCR,txtfile\shell\print\command,,2,"%11%\notepad.exe /p %1"
|
||||
HKCR,wrifile\shell\open\command,,2,"%11%\wordpad.exe %1"
|
||||
HKCR,wrifile\shell\print\command,,2,"%11%\wordpad.exe /p %1"
|
||||
HKCR,http\shell\open\command,,2,"winebrowser"
|
||||
HKCR,https\shell\open\command,,2,"winebrowser"
|
||||
HKCR,mailto\shell\open\command,,2,"winebrowser %1"
|
||||
|
|
Loading…
Reference in a new issue