wordpad: Add view options dialog.
diff --git a/programs/wordpad/De.rc b/programs/wordpad/De.rc
index 2ea2a75..f7ef34d 100644
--- a/programs/wordpad/De.rc
+++ b/programs/wordpad/De.rc
@@ -63,6 +63,8 @@
         MENUITEM "&Toolbar",        ID_TOGGLE_TOOLBAR
         MENUITEM "&Formatbar",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Statusbar",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "&Insert"
     BEGIN
@@ -152,6 +154,21 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "Rich-Text-Format (*.rtf)"
@@ -181,6 +198,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/En.rc b/programs/wordpad/En.rc
index b6f971e..907a3f1 100644
--- a/programs/wordpad/En.rc
+++ b/programs/wordpad/En.rc
@@ -63,6 +63,8 @@
         MENUITEM "&Toolbar",        ID_TOGGLE_TOOLBAR
         MENUITEM "&Formatbar",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Statusbar",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "&Insert"
     BEGIN
@@ -152,6 +154,20 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
 
 STRINGTABLE DISCARDABLE
 BEGIN
@@ -182,6 +198,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/Fr.rc b/programs/wordpad/Fr.rc
index c2802d5..2a2bd24 100644
--- a/programs/wordpad/Fr.rc
+++ b/programs/wordpad/Fr.rc
@@ -63,6 +63,8 @@
         MENUITEM "&Barre d'outils",        ID_TOGGLE_TOOLBAR
         MENUITEM "&Barre de format",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Barre d'état",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "&Insert"
     BEGIN
@@ -152,6 +154,21 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "Rich text format (*.rtf)"
@@ -181,6 +198,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/Hu.rc b/programs/wordpad/Hu.rc
index f31f6bb..da68303 100644
--- a/programs/wordpad/Hu.rc
+++ b/programs/wordpad/Hu.rc
@@ -63,6 +63,8 @@
         MENUITEM "&Toolbar",        ID_TOGGLE_TOOLBAR
         MENUITEM "&Formatbar",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Statusbar",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "&Insert"
     BEGIN
@@ -152,6 +154,21 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "Rich text format (*.rtf)"
@@ -181,6 +198,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/Ko.rc b/programs/wordpad/Ko.rc
index fbfb8b0..ac94f1c 100644
--- a/programs/wordpad/Ko.rc
+++ b/programs/wordpad/Ko.rc
@@ -64,6 +64,8 @@
         MENUITEM "µµ±¸¹Ù(&T)",        ID_TOGGLE_TOOLBAR
         MENUITEM "Çü½Ä¹Ù(&F)",      ID_TOGGLE_FORMATBAR
         MENUITEM "»óŹÙ(&S)",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "Áý¾î³Ö±â(&I)"
     BEGIN
@@ -153,6 +155,21 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "¸®Ä¡ ÅؽºÆ® ÆÄÀÏÇü½Ä (*.rtf)"
@@ -175,6 +192,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/Nl.rc b/programs/wordpad/Nl.rc
index 86cae2c..e678fbe 100644
--- a/programs/wordpad/Nl.rc
+++ b/programs/wordpad/Nl.rc
@@ -63,6 +63,8 @@
         MENUITEM "&Toolbar",        ID_TOGGLE_TOOLBAR
         MENUITEM "&Formatbar",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Statusbar",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "&Insert"
     BEGIN
@@ -152,6 +154,21 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "Rich text format (*.rtf)"
@@ -181,6 +198,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/No.rc b/programs/wordpad/No.rc
index 5632559..5c66e09 100644
--- a/programs/wordpad/No.rc
+++ b/programs/wordpad/No.rc
@@ -63,6 +63,8 @@
         MENUITEM "Verk&tøylinje",     ID_TOGGLE_TOOLBAR
         MENUITEM "&Formatlinje",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Statuslinje",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Alternativer . . .", ID_VIEWPROPERTIES
     END
     POPUP "Sett &inn"
     BEGIN
@@ -152,6 +154,21 @@
     PUSHBUTTON "Fjern all&e", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Linjebryting", 0, 10, 10, 130, 85
+    RADIOBUTTON "Bryt tekst etter v&indusbredden", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Bryt tekst etter &margen", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Verktøylinjer", 0, 150, 10, 120, 85
+    CHECKBOX "&Verktøylinje", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatlinje", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statuslinje", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "Rikt tekstformat (*.rtf)"
@@ -181,6 +198,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Alternativer"
+    STRING_VIEWPROPS_TEXT,           "Tekst"
+    STRING_VIEWPROPS_RICHTEXT,       "Rik tekst"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/Pl.rc b/programs/wordpad/Pl.rc
index 9fe6121..2dd10b7 100644
--- a/programs/wordpad/Pl.rc
+++ b/programs/wordpad/Pl.rc
@@ -64,6 +64,8 @@
         MENUITEM "&Toolbar",        ID_TOGGLE_TOOLBAR
         MENUITEM "&Formatbar",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Statusbar",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "&Insert"
     BEGIN
@@ -153,6 +155,21 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "Tekst sformatowany - RTF (*.rtf)"
@@ -182,6 +199,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/Ru.rc b/programs/wordpad/Ru.rc
index 8c44f94e..05cd63f 100644
--- a/programs/wordpad/Ru.rc
+++ b/programs/wordpad/Ru.rc
@@ -62,6 +62,8 @@
         MENUITEM "&Toolbar",        ID_TOGGLE_TOOLBAR
         MENUITEM "&Formatbar",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Statusbar",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "&Insert"
     BEGIN
@@ -151,6 +153,21 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "Rich text format (*.rtf)"
@@ -180,6 +197,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/Tr.rc b/programs/wordpad/Tr.rc
index 9b4c454..e22e427 100644
--- a/programs/wordpad/Tr.rc
+++ b/programs/wordpad/Tr.rc
@@ -66,6 +66,8 @@
         MENUITEM "&Toolbar",        ID_TOGGLE_TOOLBAR
         MENUITEM "&Formatbar",      ID_TOGGLE_FORMATBAR
         MENUITEM "&Statusbar",      ID_TOGGLE_STATUSBAR
+        MENUITEM SEPARATOR
+        MENUITEM "&Options . . .",  ID_VIEWPROPERTIES
     END
     POPUP "&Insert"
     BEGIN
@@ -155,6 +157,21 @@
     PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
 END
 
+IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
+STYLE DS_SYSMODAL
+Caption ""
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
+    RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
+    RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
+    GROUPBOX "Toolbars", 0, 150, 10, 120, 85
+    CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
+    CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
+    CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+    LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
+END
+
 STRINGTABLE DISCARDABLE
 BEGIN
     STRING_RICHTEXT_FILES_RTF,     "Rich text format (*.rtf)"
@@ -184,6 +201,13 @@
 
 STRINGTABLE DISCARDABLE
 BEGIN
+    STRING_VIEWPROPS_TITLE,          "Options"
+    STRING_VIEWPROPS_TEXT,           "Text"
+    STRING_VIEWPROPS_RICHTEXT,       "Rich text"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
     STRING_UNITS_CM,             "cm"
 END
 
diff --git a/programs/wordpad/resource.h b/programs/wordpad/resource.h
index d742339..b752a00 100644
--- a/programs/wordpad/resource.h
+++ b/programs/wordpad/resource.h
@@ -75,17 +75,29 @@
 #define BANDID_RULER 0
 #define BANDID_STATUSBAR 1
 
+#define ID_WORDWRAP_NONE 0
+#define ID_WORDWRAP_WINDOW 1
+#define ID_WORDWRAP_MARGIN 2
+
 #define ID_NEWFILE_ABORT 100
 
 #define ID_TAB_ADD 100
 #define ID_TAB_DEL 101
 #define ID_TAB_EMPTY 102
 
+#define IDC_PAGEFMT_TB 100
+#define IDC_PAGEFMT_FB 101
+#define IDC_PAGEFMT_SB 102
+#define IDC_PAGEFMT_WW 103
+#define IDC_PAGEFMT_WM 104
+#define IDC_PAGEFMT_ID 105
+
 #define ID_DATETIME 1600
 #define ID_PARAFORMAT 1601
 #define ID_TABSTOPS 1602
 
 #define ID_ABOUT 1603
+#define ID_VIEWPROPERTIES 1604
 
 #define IDC_STATUSBAR 2000
 #define IDC_EDITOR 2001
@@ -105,6 +117,7 @@
 #define IDD_NEWFILE 2101
 #define IDD_PARAFORMAT 2102
 #define IDD_TABSTOPS 2103
+#define IDD_FORMATOPTS 2104
 
 #define IDM_POPUP 2200
 
@@ -128,7 +141,11 @@
 
 #define STRING_PRINTER_FILES_PRN 1410
 
-#define STRING_UNITS_CM 1411
+#define STRING_VIEWPROPS_TITLE 1411
+#define STRING_VIEWPROPS_TEXT 1412
+#define STRING_VIEWPROPS_RICHTEXT 1413
+
+#define STRING_UNITS_CM 1414
 
 #define STRING_DEFAULT_FILENAME 1700
 #define STRING_PROMPT_SAVE_CHANGES 1701
diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c
index 8c3d2a2..f833084 100644
--- a/programs/wordpad/wordpad.c
+++ b/programs/wordpad/wordpad.c
@@ -610,6 +610,7 @@
 }
 
 static DWORD barState[2];
+static DWORD wordWrap[2];
 
 static BOOL is_bar_visible(int bandId)
 {
@@ -671,12 +672,102 @@
     update_window();
 }
 
+static HGLOBAL devMode;
+static HGLOBAL devNames;
+
+static HDC make_dc(void)
+{
+    if(devNames && devMode)
+    {
+        LPDEVNAMES dn = GlobalLock(devNames);
+        LPDEVMODEW dm = GlobalLock(devMode);
+        HDC ret;
+
+        ret = CreateDCW((LPWSTR)dn + dn->wDriverOffset,
+                        (LPWSTR)dn + dn->wDeviceOffset, 0, dm);
+
+        GlobalUnlock(dn);
+        GlobalUnlock(dm);
+
+        return ret;
+    } else
+    {
+        return 0;
+    }
+}
+
+static LONG devunits_to_twips(int units, int dpi)
+{
+    float ret = ((float)units / (float)dpi) * (float)567 * 2.54;
+    return (LONG)ret;
+}
+
+static LONG centmm_to_twips(int mm)
+{
+    return MulDiv(mm, 567, 1000);
+}
+
+static LONG twips_to_centmm(int twips)
+{
+    return MulDiv(twips, 1000, 567);
+}
+
+static RECT get_print_rect(HDC hdc)
+{
+    RECT rc;
+    int width, height;
+
+    if(hdc)
+    {
+        int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
+        int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
+        width = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALWIDTH), dpiX);
+        height = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALHEIGHT), dpiY);
+    } else
+    {
+        width = centmm_to_twips(18500);
+        height = centmm_to_twips(27000);
+    }
+
+    rc.left = margins.left;
+    rc.right = width - margins.right;
+    rc.top = margins.top;
+    rc.bottom = height - margins.bottom;
+
+    return rc;
+}
+
+static void target_device(void)
+{
+    HDC hdc = make_dc();
+    int width = 0;
+    int index = reg_formatindex(fileFormat);
+
+    if(wordWrap[index] == ID_WORDWRAP_MARGIN)
+    {
+        RECT rc = get_print_rect(hdc);
+        width = rc.right;
+    }
+
+    if(!hdc)
+    {
+        HDC hMaindc = GetDC(hMainWnd);
+        hdc = CreateCompatibleDC(hMaindc);
+        ReleaseDC(hMainWnd, hMaindc);
+    }
+
+    SendMessageW(hEditorWnd, EM_SETTARGETDEVICE, (WPARAM)hdc, width);
+
+    DeleteDC(hdc);
+}
+
 static void set_fileformat(WPARAM format)
 {
     fileFormat = format;
 
     set_bar_states();
     set_default_font();
+    target_device();
 }
 
 static void DoOpenFile(LPCWSTR szOpenFileName)
@@ -722,7 +813,6 @@
     lstrcpyW(wszFileName, szOpenFileName);
     SendMessageW(hEditorWnd, EM_SETMODIFY, FALSE, 0);
     registry_set_filelist(szOpenFileName);
-    set_fileformat(format);
 }
 
 static void DoSaveFile(LPCWSTR wszSaveFileName, WPARAM format)
@@ -913,48 +1003,20 @@
         return FALSE;
 }
 
-static LONG devunits_to_twips(int units, int dpi)
-{
-    float ret = ((float)units / (float)dpi) * (float)567 * 2.54;
-    return (LONG)ret;
-}
-
-static int centmm_to_twips(int mm)
-{
-    return MulDiv(mm, 567, 1000);
-}
-
-static int twips_to_centmm(int twips)
-{
-    return MulDiv(twips, 1000, 567);
-}
-
-static HGLOBAL devMode;
-static HGLOBAL devNames;
-
 static void print(LPPRINTDLGW pd)
 {
     FORMATRANGE fr;
     DOCINFOW di;
-    int dpiY, dpiX, width, height;
     int printedPages = 0;
 
     fr.hdc = pd->hDC;
     fr.hdcTarget = pd->hDC;
 
-    dpiY = GetDeviceCaps(fr.hdc, LOGPIXELSY);
-    dpiX = GetDeviceCaps(fr.hdc, LOGPIXELSX);
-    width = devunits_to_twips(GetDeviceCaps(fr.hdc, PHYSICALWIDTH), dpiX);
-    height = devunits_to_twips(GetDeviceCaps(fr.hdc, PHYSICALHEIGHT), dpiY);
-
-    fr.rc.left = margins.left;
-    fr.rc.right = width - margins.right;
-    fr.rc.top = margins.top;
-    fr.rc.bottom = height - margins.bottom;
+    fr.rc = get_print_rect(fr.hdc);
     fr.rcPage.left = 0;
-    fr.rcPage.right = width;
+    fr.rcPage.right = fr.rc.right + margins.right;
     fr.rcPage.top = 0;
-    fr.rcPage.bottom = height;
+    fr.rcPage.bottom = fr.rc.bottom + margins.bottom;
 
     ZeroMemory(&di, sizeof(di));
     di.cbSize = sizeof(di);
@@ -1010,6 +1072,7 @@
 
     EndDoc(fr.hdc);
     SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0);
+    target_device();
 }
 
 static void dialog_printsetup(void)
@@ -1035,35 +1098,33 @@
         margins.bottom = centmm_to_twips(ps.rtMargin.bottom);
         devMode = ps.hDevMode;
         devNames = ps.hDevNames;
+        target_device();
     }
 }
 
+static void get_default_printer_opts(void)
+{
+    PRINTDLGW pd;
+    ZeroMemory(&pd, sizeof(pd));
+
+    ZeroMemory(&pd, sizeof(pd));
+    pd.lStructSize = sizeof(pd);
+    pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
+    pd.hwndOwner = hMainWnd;
+    pd.hDevMode = devMode;
+
+    PrintDlgW(&pd);
+
+    devMode = pd.hDevMode;
+    devNames = pd.hDevNames;
+}
+
 static void print_quick(void)
 {
     PRINTDLGW pd;
+
     ZeroMemory(&pd, sizeof(pd));
-
-    if(devMode && devNames)
-    {
-        LPDEVNAMES dn = GlobalLock(devNames);
-        LPDEVMODEW dm = GlobalLock(devMode);
-        pd.hDC = CreateDCW((LPWSTR)dn + dn->wDriverOffset,
-                           (LPWSTR)dn + dn->wDeviceOffset, 0, dm);
-        GlobalUnlock(dn);
-        GlobalUnlock(dm);
-    } else
-    {
-        ZeroMemory(&pd, sizeof(pd));
-        pd.lStructSize = sizeof(pd);
-        pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
-        pd.hwndOwner = hMainWnd;
-        pd.hDevMode = (HGLOBAL)devMode;
-
-        PrintDlgW(&pd);
-
-        devMode = pd.hDevMode;
-        devNames = pd.hDevNames;
-    }
+    pd.hDC = make_dc();
 
     print(&pd);
 }
@@ -1102,6 +1163,137 @@
     ShellAboutW(hMainWnd, wszAppTitle, 0, icon);
 }
 
+static INT_PTR CALLBACK formatopts_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    switch(message)
+    {
+        case WM_INITDIALOG:
+            {
+                LPPROPSHEETPAGEW ps = (LPPROPSHEETPAGEW)lParam;
+                int wrap = -1;
+                char id[4];
+                HWND hIdWnd = GetDlgItem(hWnd, IDC_PAGEFMT_ID);
+
+                sprintf(id, "%d\n", (int)ps->lParam);
+                SetWindowTextA(hIdWnd, id);
+                if(wordWrap[ps->lParam] == ID_WORDWRAP_WINDOW)
+                    wrap = IDC_PAGEFMT_WW;
+                else if(wordWrap[ps->lParam] == ID_WORDWRAP_MARGIN)
+                    wrap = IDC_PAGEFMT_WM;
+
+                if(wrap != -1)
+                    CheckRadioButton(hWnd, IDC_PAGEFMT_WW,
+                                     IDC_PAGEFMT_WM, wrap);
+
+                if(barState[ps->lParam] & (1 << BANDID_TOOLBAR))
+                    CheckDlgButton(hWnd, IDC_PAGEFMT_TB, TRUE);
+                if(barState[ps->lParam] & (1 << BANDID_FORMATBAR))
+                    CheckDlgButton(hWnd, IDC_PAGEFMT_FB, TRUE);
+                if(barState[ps->lParam] & (BANDID_STATUSBAR))
+                    CheckDlgButton(hWnd, IDC_PAGEFMT_SB, TRUE);
+            }
+            break;
+
+        case WM_COMMAND:
+            switch(LOWORD(wParam))
+            {
+                case IDC_PAGEFMT_WW:
+                case IDC_PAGEFMT_WM:
+                    CheckRadioButton(hWnd, IDC_PAGEFMT_WW, IDC_PAGEFMT_WM,
+                                     LOWORD(wParam));
+                    break;
+
+                case IDC_PAGEFMT_TB:
+                case IDC_PAGEFMT_FB:
+                case IDC_PAGEFMT_SB:
+                    CheckDlgButton(hWnd, LOWORD(wParam),
+                                   !IsDlgButtonChecked(hWnd, LOWORD(wParam)));
+                    break;
+            }
+            break;
+        case WM_NOTIFY:
+            {
+                LPNMHDR header = (LPNMHDR)lParam;
+                if(header->code == PSN_APPLY)
+                {
+                    HWND hIdWnd = GetDlgItem(hWnd, IDC_PAGEFMT_ID);
+                    char sid[4];
+                    int id;
+
+                    GetWindowTextA(hIdWnd, sid, 4);
+                    id = atoi(sid);
+                    if(IsDlgButtonChecked(hWnd, IDC_PAGEFMT_WW))
+                        wordWrap[id] = ID_WORDWRAP_WINDOW;
+                    else if(IsDlgButtonChecked(hWnd, IDC_PAGEFMT_WM))
+                        wordWrap[id] = ID_WORDWRAP_MARGIN;
+
+                    if(IsDlgButtonChecked(hWnd, IDC_PAGEFMT_TB))
+                        barState[id] |= (1 << BANDID_TOOLBAR);
+                    else
+                        barState[id] &= ~(1 << BANDID_TOOLBAR);
+
+                    if(IsDlgButtonChecked(hWnd, IDC_PAGEFMT_FB))
+                        barState[id] |= (1 << BANDID_FORMATBAR);
+                    else
+                        barState[id] &= ~(1 << BANDID_FORMATBAR);
+
+                    if(IsDlgButtonChecked(hWnd, IDC_PAGEFMT_SB))
+                        barState[id] |= (1 << BANDID_STATUSBAR);
+                    else
+                        barState[id] &= ~(1 << BANDID_STATUSBAR);
+                }
+            }
+            break;
+    }
+    return FALSE;
+}
+
+static void dialog_viewproperties(void)
+{
+    PROPSHEETPAGEW psp[2];
+    PROPSHEETHEADERW psh;
+    int i;
+    HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE);
+    LPCPROPSHEETPAGEW ppsp = (LPCPROPSHEETPAGEW)&psp;
+
+    psp[0].dwSize = sizeof(PROPSHEETPAGEW);
+    psp[0].dwFlags = PSP_USETITLE;
+    psp[0].pszTemplate = MAKEINTRESOURCEW(IDD_FORMATOPTS);
+    psp[0].pfnDlgProc = formatopts_proc;
+    psp[0].hInstance = hInstance;
+    psp[0].lParam = reg_formatindex(SF_TEXT);
+    psp[0].pfnCallback = NULL;
+    psp[0].pszTitle = MAKEINTRESOURCEW(STRING_VIEWPROPS_TEXT);
+    for(i = 1; i < sizeof(psp)/sizeof(psp[0]); i++)
+    {
+        psp[i].dwSize = psp[0].dwSize;
+        psp[i].dwFlags = psp[0].dwFlags;
+        psp[i].pszTemplate = psp[0].pszTemplate;
+        psp[i].pfnDlgProc = psp[0].pfnDlgProc;
+        psp[i].hInstance = psp[0].hInstance;
+        psp[i].lParam = reg_formatindex(SF_RTF);
+        psp[i].pfnCallback = psp[0].pfnCallback;
+        psp[i].pszTitle = MAKEINTRESOURCEW(STRING_VIEWPROPS_RICHTEXT);
+    }
+
+    psh.dwSize = sizeof(psh);
+    psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
+    psh.hwndParent = hMainWnd;
+    psh.hInstance = hInstance;
+    psh.pszCaption = MAKEINTRESOURCEW(STRING_VIEWPROPS_TITLE);
+    psh.nPages = sizeof(psp)/sizeof(psp[0]);
+    psh.ppsp = ppsp;
+    psh.pszIcon = MAKEINTRESOURCEW(IDI_WORDPAD);
+
+    if(fileFormat & SF_RTF)
+        psh.nStartPage = 1;
+    else
+        psh.nStartPage = 0;
+    PropertySheetW(&psh);
+    set_bar_states();
+    target_device();
+}
+
 static void HandleCommandLine(LPWSTR cmdline)
 {
     WCHAR delimiter;
@@ -1278,6 +1470,7 @@
     DWORD action = 0;
     BOOL fetched = FALSE;
     barState[index] = 0;
+    wordWrap[index] = 0;
 
     if(registry_get_handle(&hKey, &action, key) != ERROR_SUCCESS)
         return;
@@ -1294,6 +1487,11 @@
     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_WINDOW; /* FIXME: should be ID_WORDWRAP_NONE once we support it */
+
     RegCloseKey(hKey);
 }
 
@@ -1782,7 +1980,7 @@
     }
 
     hEditorWnd = CreateWindowExW(WS_EX_CLIENTEDGE, wszRichEditClass, NULL,
-      WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN|WS_VSCROLL,
+      WS_CHILD|WS_VISIBLE|ECO_SELECTIONBAR|ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN|WS_VSCROLL,
       0, 0, 1000, 100, hWnd, (HMENU)IDC_EDITOR, hInstance, NULL);
 
     if (!hEditorWnd)
@@ -2208,6 +2406,10 @@
         dialog_about();
         break;
 
+    case ID_VIEWPROPERTIES:
+        dialog_viewproperties();
+        break;
+
     default:
         SendMessageW(hwndEditor, WM_COMMAND, wParam, lParam);
         break;
@@ -2423,6 +2625,8 @@
     set_caption(NULL);
     set_bar_states();
     hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP));
+    get_default_printer_opts();
+    target_device();
 
     HandleCommandLine(GetCommandLineW());