wordpad: Save and load word wrap registry options.

This commit is contained in:
Dylan Smith 2010-07-19 18:22:22 -04:00 committed by Alexandre Julliard
parent 9de8357965
commit c37cdce905
3 changed files with 25 additions and 11 deletions

View File

@ -34,6 +34,7 @@ static const WCHAR key_text[] = {'T','e','x','t',0};
static const WCHAR var_file[] = {'F','i','l','e','%','d',0};
static const WCHAR var_framerect[] = {'F','r','a','m','e','R','e','c','t',0};
static const WCHAR var_barstate0[] = {'B','a','r','S','t','a','t','e','0',0};
static const WCHAR var_wrap[] = {'W','r','a','p',0};
static const WCHAR var_maximized[] = {'M','a','x','i','m','i','z','e','d',0};
static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
@ -377,10 +378,22 @@ static void registry_read_formatopts(int index, LPCWSTR key, DWORD barState[], D
if(!fetched)
barState[index] = (1 << BANDID_TOOLBAR) | (1 << BANDID_FORMATBAR) | (1 << BANDID_RULER) | (1 << BANDID_STATUSBAR);
if(index == reg_formatindex(SF_RTF))
wordWrap[index] = ID_WORDWRAP_WINDOW;
else if(index == reg_formatindex(SF_TEXT))
wordWrap[index] = ID_WORDWRAP_NONE;
fetched = FALSE;
if(action == REG_OPENED_EXISTING_KEY)
{
DWORD size = sizeof(DWORD);
if(RegQueryValueExW(hKey, var_wrap, 0, NULL, (LPBYTE)&wordWrap[index],
&size) == ERROR_SUCCESS)
fetched = TRUE;
}
if (!fetched)
{
if(index == reg_formatindex(SF_RTF))
wordWrap[index] = ID_WORDWRAP_WINDOW;
else if(index == reg_formatindex(SF_TEXT))
wordWrap[index] = ID_WORDWRAP_NONE;
}
RegCloseKey(hKey);
}
@ -391,7 +404,7 @@ void registry_read_formatopts_all(DWORD barState[], DWORD wordWrap[])
registry_read_formatopts(reg_formatindex(SF_TEXT), key_text, barState, wordWrap);
}
static void registry_set_formatopts(int index, LPCWSTR key, DWORD barState[])
static void registry_set_formatopts(int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[])
{
HKEY hKey;
DWORD action = 0;
@ -400,13 +413,14 @@ static void registry_set_formatopts(int index, LPCWSTR key, DWORD barState[])
{
RegSetValueExW(hKey, var_barstate0, 0, REG_DWORD, (LPBYTE)&barState[index],
sizeof(DWORD));
RegSetValueExW(hKey, var_wrap, 0, REG_DWORD, (LPBYTE)&wordWrap[index],
sizeof(DWORD));
RegCloseKey(hKey);
}
}
void registry_set_formatopts_all(DWORD barState[])
void registry_set_formatopts_all(DWORD barState[], DWORD wordWrap[])
{
registry_set_formatopts(reg_formatindex(SF_RTF), key_rtf, barState);
registry_set_formatopts(reg_formatindex(SF_TEXT), key_text, barState);
registry_set_formatopts(reg_formatindex(SF_RTF), key_rtf, barState, wordWrap);
registry_set_formatopts(reg_formatindex(SF_TEXT), key_text, barState, wordWrap);
}

View File

@ -2639,7 +2639,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
} else if(prompt_save_changes())
{
registry_set_options(hMainWnd);
registry_set_formatopts_all(barState);
registry_set_formatopts_all(barState, wordWrap);
PostQuitMessage(0);
}
break;

View File

@ -262,5 +262,5 @@ void registry_read_formatopts_all(DWORD[], DWORD[]);
void registry_read_winrect(RECT*);
void registry_read_maximized(DWORD*);
void registry_set_filelist(LPCWSTR, HWND);
void registry_set_formatopts_all(DWORD[]);
void registry_set_formatopts_all(DWORD[], DWORD[]);
void registry_set_options(HWND);