ReactOS  0.4.15-dev-439-g292f67a
wordpad.c File Reference
#include <stdio.h>
#include <assert.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <richedit.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shellapi.h>
#include <shlobj.h>
#include <wine/unicode.h>
#include "wordpad.h"
Include dependency graph for wordpad.c:

Go to the source code of this file.

Classes

struct  FINDREPLACE_custom
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#define U(x)   (x)
 
#define U2(x)   (x)
 
#define U3(x)   (x)
 

Enumerations

enum  UNIT { UNIT_CM, UNIT_INCH, UNIT_PT }
 

Functions

LRESULT CALLBACK preview_proc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT OnSize (HWND hWnd, WPARAM wParam, LPARAM lParam)
 
static void DoLoadStrings (void)
 
static int MessageBoxWithResStringW (HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
 
static void AddButton (HWND hwndToolBar, int nImage, int nCommand)
 
static void AddSeparator (HWND hwndToolBar)
 
static DWORD CALLBACK stream_in (DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
 
static DWORD CALLBACK stream_out (DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
 
LPWSTR file_basename (LPWSTR path)
 
static void set_caption (LPCWSTR wszNewFileName)
 
static BOOL validate_endptr (LPCWSTR endptr, UNIT *punit)
 
static BOOL number_from_string (LPCWSTR string, float *num, UNIT *punit)
 
static void set_size (float size)
 
static void on_sizelist_modified (HWND hwndSizeList, LPWSTR wszNewFontSize)
 
static void add_size (HWND hSizeListWnd, unsigned size)
 
static void populate_size_list (HWND hSizeListWnd)
 
static void update_size_list (void)
 
static void update_font_list (void)
 
static void clear_formatting (void)
 
static int fileformat_number (WPARAM format)
 
static WPARAM fileformat_flags (int format)
 
static void set_font (LPCWSTR wszFaceName)
 
static void set_default_font (void)
 
static void on_fontlist_modified (LPWSTR wszNewFaceName)
 
static void add_font (LPCWSTR fontName, DWORD fontType, HWND hListWnd, const NEWTEXTMETRICEXW *ntmc)
 
static void dialog_choose_font (void)
 
static int CALLBACK enum_font_proc (const LOGFONTW *lpelfe, const TEXTMETRICW *lpntme, DWORD FontType, LPARAM lParam)
 
static void populate_font_list (HWND hListWnd)
 
static void update_window (void)
 
static BOOL is_bar_visible (int bandId)
 
static void store_bar_state (int bandId, BOOL show)
 
static void set_toolbar_state (int bandId, BOOL show)
 
static void set_statusbar_state (BOOL show)
 
static void set_bar_states (void)
 
static void preview_exit (HWND hMainWnd)
 
static void set_fileformat (WPARAM format)
 
static void ShowOpenError (DWORD Code)
 
static void DoOpenFile (LPCWSTR szOpenFileName)
 
static void ShowWriteError (DWORD Code)
 
static BOOL DoSaveFile (LPCWSTR wszSaveFileName, WPARAM format)
 
static BOOL DialogSaveFile (void)
 
static BOOL prompt_save_changes (void)
 
static void DialogOpenFile (void)
 
static void dialog_about (void)
 
static INT_PTR CALLBACK formatopts_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static void dialog_viewproperties (void)
 
static void HandleCommandLine (LPWSTR cmdline)
 
static LRESULT handle_findmsg (LPFINDREPLACEW pFr)
 
static void dialog_find (LPFINDREPLACEW fr, BOOL replace)
 
static int units_to_twips (UNIT unit, float number)
 
static void append_current_units (LPWSTR buffer)
 
static void number_with_units (LPWSTR buffer, int number)
 
static BOOL get_comboexlist_selection (HWND hComboEx, LPWSTR wszBuffer, UINT bufferLength)
 
static INT_PTR CALLBACK datetime_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK newfile_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK paraformat_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK tabstops_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT OnCreate (HWND hWnd)
 
static LRESULT OnUser (HWND hWnd)
 
static LRESULT OnNotify (HWND hWnd, LPARAM lParam)
 
static LRESULT OnCommand (HWND hWnd, WPARAM wParam, LPARAM lParam)
 
static LRESULT OnInitPopupMenu (HWND hWnd, WPARAM wParam)
 
static LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
int CALLBACK WinMain (HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdParagraph, int nCmdShow)
 

Variables

static const WCHAR wszAppTitle [] = {'W','o','r','d','p','a','d',0}
 
static const WCHAR wszMainWndClass [] = {'W','O','R','D','P','A','D','T','O','P',0}
 
static const WCHAR stringFormat [] = {'%','2','d','\0'}
 
const WCHAR wszPreviewWndClass [] = {'P','r','t','P','r','e','v','i','e','w',0}
 
static HWND hMainWnd
 
static HWND hEditorWnd
 
static HWND hFindWnd
 
static HMENU hColorPopupMenu
 
static UINT ID_FINDMSGSTRING
 
static DWORD wordWrap [2]
 
static DWORD barState [2]
 
static WPARAM fileFormat = SF_RTF
 
static WCHAR wszFileName [MAX_PATH]
 
static WCHAR wszFilter [MAX_STRING_LEN *4+6 *3+5]
 
static WCHAR wszDefaultFileName [MAX_STRING_LEN]
 
static WCHAR wszSaveChanges [MAX_STRING_LEN]
 
static WCHAR units_cmW [MAX_STRING_LEN]
 
static WCHAR units_inW [MAX_STRING_LEN]
 
static WCHAR units_inchW [MAX_STRING_LEN]
 
static WCHAR units_ptW [MAX_STRING_LEN]
 
static const COLORREF textcolors []
 

Macro Definition Documentation

◆ U

#define U (   x)    (x)

Definition at line 45 of file wordpad.c.

◆ U2

#define U2 (   x)    (x)

Definition at line 46 of file wordpad.c.

◆ U3

#define U3 (   x)    (x)

Definition at line 47 of file wordpad.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 23 of file wordpad.c.

Enumeration Type Documentation

◆ UNIT

Enumerator
UNIT_CM 
UNIT_INCH 
UNIT_PT 

Definition at line 82 of file wordpad.c.

83 {
84  UNIT_CM,
85  UNIT_INCH,
86  UNIT_PT
87 } UNIT;
UNIT
Definition: wordpad.c:82

Function Documentation

◆ add_font()

static void add_font ( LPCWSTR  fontName,
DWORD  fontType,
HWND  hListWnd,
const NEWTEXTMETRICEXW ntmc 
)
static

Definition at line 536 of file wordpad.c.

537 {
538  COMBOBOXEXITEMW cbItem;
540  int fontHeight = 0;
541 
542  cbItem.mask = CBEIF_TEXT;
543  cbItem.pszText = buffer;
544  cbItem.cchTextMax = MAX_STRING_LEN;
545  cbItem.iItem = 0;
546 
547  while(SendMessageW(hListWnd, CBEM_GETITEMW, 0, (LPARAM)&cbItem))
548  {
549  if(lstrcmpiW(cbItem.pszText, fontName) <= 0)
550  cbItem.iItem++;
551  else
552  break;
553  }
554  cbItem.pszText = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(fontName) + 1)*sizeof(WCHAR) );
555  lstrcpyW( cbItem.pszText, fontName );
556 
557  cbItem.mask |= CBEIF_LPARAM;
558  if(fontType & RASTER_FONTTYPE)
560 
561  cbItem.lParam = MAKELONG(fontType,fontHeight);
562  SendMessageW(hListWnd, CBEM_INSERTITEMW, 0, (LPARAM)&cbItem);
563  HeapFree( GetProcessHeap(), 0, cbItem.pszText );
564 }
GLuint buffer
Definition: glext.h:5915
#define MAX_STRING_LEN
Definition: precomp.h:36
#define lstrlenW
Definition: compat.h:416
NEWTEXTMETRICW ntmTm
Definition: wingdi.h:2674
GLenum const GLvoid * fontName
Definition: glext.h:11715
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define CBEIF_TEXT
Definition: commctrl.h:3782
#define CBEM_GETITEMW
Definition: commctrl.h:3839
#define MAKELONG(a, b)
Definition: typedefs.h:248
LONG_PTR LPARAM
Definition: windef.h:208
#define CBEIF_LPARAM
Definition: commctrl.h:3787
int fontHeight
Definition: appswitch.c:47
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define RASTER_FONTTYPE
Definition: wingdi.h:1106
LONG tmInternalLeading
Definition: wingdi.h:2646
#define CBEM_INSERTITEMW
Definition: commctrl.h:3837
#define lstrcpyW
Definition: compat.h:415
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by enum_font_proc().

◆ add_size()

static void add_size ( HWND  hSizeListWnd,
unsigned  size 
)
static

Definition at line 353 of file wordpad.c.

354 {
355  WCHAR buffer[3];
356  COMBOBOXEXITEMW cbItem;
357  cbItem.mask = CBEIF_TEXT;
358  cbItem.iItem = -1;
359 
361  cbItem.pszText = buffer;
362  SendMessageW(hSizeListWnd, CBEM_INSERTITEMW, 0, (LPARAM)&cbItem);
363 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
GLuint buffer
Definition: glext.h:5915
#define CBEIF_TEXT
Definition: commctrl.h:3782
LONG_PTR LPARAM
Definition: windef.h:208
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR stringFormat[]
Definition: wordpad.c:55
#define CBEM_INSERTITEMW
Definition: commctrl.h:3837
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by populate_size_list().

◆ AddButton()

static void AddButton ( HWND  hwndToolBar,
int  nImage,
int  nCommand 
)
static

Definition at line 155 of file wordpad.c.

156 {
158 
159  ZeroMemory(&button, sizeof(button));
160  button.iBitmap = nImage;
161  button.idCommand = nCommand;
162  button.fsState = TBSTATE_ENABLED;
163  button.fsStyle = BTNS_BUTTON;
164  button.dwData = 0;
165  button.iString = -1;
166  SendMessageW(hwndToolBar, TB_ADDBUTTONSW, 1, (LPARAM)&button);
167 }
DWORD button
Definition: button.c:166
#define ZeroMemory
Definition: winbase.h:1648
#define BTNS_BUTTON
Definition: commctrl.h:994
LONG_PTR LPARAM
Definition: windef.h:208
#define TB_ADDBUTTONSW
Definition: commctrl.h:1262
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TBSTATE_ENABLED
Definition: commctrl.h:970

Referenced by InitFilterListBox(), and OnCreate().

◆ AddSeparator()

static void AddSeparator ( HWND  hwndToolBar)
static

Definition at line 169 of file wordpad.c.

170 {
172 
173  ZeroMemory(&button, sizeof(button));
174  button.iBitmap = -1;
175  button.idCommand = 0;
176  button.fsState = 0;
177  button.fsStyle = BTNS_SEP;
178  button.dwData = 0;
179  button.iString = -1;
180  SendMessageW(hwndToolBar, TB_ADDBUTTONSW, 1, (LPARAM)&button);
181 }
DWORD button
Definition: button.c:166
#define ZeroMemory
Definition: winbase.h:1648
LONG_PTR LPARAM
Definition: windef.h:208
#define BTNS_SEP
Definition: commctrl.h:995
#define TB_ADDBUTTONSW
Definition: commctrl.h:1262
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by OnCreate().

◆ append_current_units()

static void append_current_units ( LPWSTR  buffer)
static

Definition at line 1374 of file wordpad.c.

1375 {
1376  static const WCHAR space[] = {' ', 0};
1377  lstrcatW(buffer, space);
1379 }
GLuint buffer
Definition: glext.h:5915
static WCHAR units_cmW[MAX_STRING_LEN]
Definition: wordpad.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by tabstops_proc().

◆ clear_formatting()

static void clear_formatting ( void  )
static

Definition at line 448 of file wordpad.c.

449 {
450  PARAFORMAT2 pf;
451 
452  pf.cbSize = sizeof(pf);
453  pf.dwMask = PFM_ALIGNMENT;
454  pf.wAlignment = PFA_LEFT;
456 }
WORD wAlignment
Definition: richedit.h:673
#define PFM_ALIGNMENT
Definition: richedit.h:841
static HWND hEditorWnd
Definition: wordpad.c:61
#define EM_SETPARAFORMAT
Definition: richedit.h:104
LONG_PTR LPARAM
Definition: windef.h:208
DWORD dwMask
Definition: richedit.h:667
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define PFA_LEFT
Definition: richedit.h:921
UINT cbSize
Definition: richedit.h:666

Referenced by DoOpenFile(), and OnCommand().

◆ datetime_proc()

static INT_PTR CALLBACK datetime_proc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1418 of file wordpad.c.

1419 {
1420  switch(message)
1421  {
1422  case WM_INITDIALOG:
1423  {
1425  SYSTEMTIME st;
1426  HWND hListWnd = GetDlgItem(hWnd, IDC_DATETIME);
1427  GetLocalTime(&st);
1428 
1430  MAX_STRING_LEN);
1431  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1433  MAX_STRING_LEN);
1434  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1436  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1437 
1438  SendMessageW(hListWnd, LB_SETSEL, TRUE, 0);
1439  }
1440  break;
1441 
1442  case WM_COMMAND:
1443  switch(LOWORD(wParam))
1444  {
1445  case IDC_DATETIME:
1446  if (HIWORD(wParam) != LBN_DBLCLK)
1447  break;
1448  /* Fall through */
1449 
1450  case IDOK:
1451  {
1452  LRESULT index;
1453  HWND hListWnd = GetDlgItem(hWnd, IDC_DATETIME);
1454 
1455  index = SendMessageW(hListWnd, LB_GETCURSEL, 0, 0);
1456 
1457  if(index != LB_ERR)
1458  {
1460  SendMessageW(hListWnd, LB_GETTEXT, index, (LPARAM)&buffer);
1462  }
1463  }
1464  /* Fall through */
1465 
1466  case IDCANCEL:
1467  EndDialog(hWnd, wParam);
1468  return TRUE;
1469  }
1470  }
1471  return FALSE;
1472 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define LB_ADDSTRING
Definition: winuser.h:2013
#define LB_SETSEL
Definition: winuser.h:2050
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
HWND hWnd
Definition: settings.c:17
GLuint buffer
Definition: glext.h:5915
#define MAX_STRING_LEN
Definition: precomp.h:36
static HWND hEditorWnd
Definition: wordpad.c:61
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define LB_ERR
Definition: winuser.h:2407
LONG_PTR LPARAM
Definition: windef.h:208
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
GLuint index
Definition: glext.h:6031
#define IDC_DATETIME
Definition: wordpad.h:161
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LBN_DBLCLK
Definition: winuser.h:2053
#define index(s, c)
Definition: various.h:29
#define LB_GETTEXT
Definition: winuser.h:2031
#define WM_COMMAND
Definition: winuser.h:1722
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DATE_LONGDATE
Definition: winnls.h:194
#define LB_GETCURSEL
Definition: winuser.h:2021
#define HIWORD(l)
Definition: typedefs.h:246
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1079
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82
#define EM_REPLACESEL
Definition: winuser.h:1988

Referenced by OnCommand().

◆ dialog_about()

static void dialog_about ( void  )
static

Definition at line 1007 of file wordpad.c.

1008 {
1011 }
static HICON
Definition: imagelist.c:84
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
#define IDI_WORDPAD
Definition: wordpad.h:186
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
smooth NULL
Definition: ftsmooth.c:416
static HWND hMainWnd
Definition: wordpad.c:60
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by OnCommand().

◆ dialog_choose_font()

static void dialog_choose_font ( void  )
static

Definition at line 566 of file wordpad.c.

567 {
568  CHOOSEFONTW cf;
569  LOGFONTW lf;
571  HDC hDC = GetDC(hMainWnd);
572 
573  ZeroMemory(&cf, sizeof(cf));
574  cf.lStructSize = sizeof(cf);
575  cf.hwndOwner = hMainWnd;
576  cf.lpLogFont = &lf;
578 
579  ZeroMemory(&fmt, sizeof(fmt));
580  fmt.cbSize = sizeof(fmt);
581 
583  lstrcpyW(cf.lpLogFont->lfFaceName, fmt.szFaceName);
584  cf.lpLogFont->lfItalic = (fmt.dwEffects & CFE_ITALIC) != 0;
585  cf.lpLogFont->lfWeight = (fmt.dwEffects & CFE_BOLD) ? FW_BOLD : FW_NORMAL;
586  cf.lpLogFont->lfUnderline = (fmt.dwEffects & CFE_UNDERLINE) != 0;
587  cf.lpLogFont->lfStrikeOut = (fmt.dwEffects & CFE_STRIKEOUT) != 0;
588  cf.lpLogFont->lfHeight = -MulDiv(fmt.yHeight / 20, GetDeviceCaps(hDC, LOGPIXELSY), 72);
589  cf.rgbColors = fmt.crTextColor;
590 
591  if(ChooseFontW(&cf))
592  {
593  ZeroMemory(&fmt, sizeof(fmt));
594  fmt.cbSize = sizeof(fmt);
596  fmt.yHeight = cf.iPointSize * 2;
597 
598  if(cf.nFontType & BOLD_FONTTYPE)
599  fmt.dwEffects |= CFE_BOLD;
600  if(cf.nFontType & ITALIC_FONTTYPE)
601  fmt.dwEffects |= CFE_ITALIC;
602  if(cf.lpLogFont->lfUnderline)
603  fmt.dwEffects |= CFE_UNDERLINE;
604  if(cf.lpLogFont->lfStrikeOut)
605  fmt.dwEffects |= CFE_STRIKEOUT;
606 
607  fmt.crTextColor = cf.rgbColors;
608 
610  set_font(cf.lpLogFont->lfFaceName);
611  }
612 }
static IClassFactory * cf
#define CFE_UNDERLINE
Definition: richedit.h:408
HDC WINAPI GetDC(_In_opt_ HWND)
#define CF_EFFECTS
Definition: commdlg.h:68
static HDC
Definition: imagelist.c:92
const char * fmt
Definition: wsprintf.c:30
#define ZeroMemory
Definition: winbase.h:1648
#define CFM_ITALIC
Definition: richedit.h:333
static HWND hEditorWnd
Definition: wordpad.c:61
#define ITALIC_FONTTYPE
Definition: commdlg.h:91
#define CFE_BOLD
Definition: richedit.h:406
#define CF_SCREENFONTS
Definition: commdlg.h:59
BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
Definition: fontdlg.c:184
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define CFM_COLOR
Definition: richedit.h:361
#define CFM_UNDERLINE
Definition: richedit.h:334
LONG_PTR LPARAM
Definition: windef.h:208
#define CF_NOSCRIPTSEL
Definition: commdlg.h:85
#define CFM_SIZE
Definition: richedit.h:362
static HWND hMainWnd
Definition: wordpad.c:60
#define CFE_ITALIC
Definition: richedit.h:407
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define CFM_STRIKEOUT
Definition: richedit.h:335
static HDC hDC
Definition: 3dtext.c:33
#define FW_BOLD
Definition: wingdi.h:377
#define lstrcpyW
Definition: compat.h:415
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define CFM_BOLD
Definition: richedit.h:332
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define FW_NORMAL
Definition: wingdi.h:372
static void set_font(LPCWSTR wszFaceName)
Definition: wordpad.c:479
#define CFE_STRIKEOUT
Definition: richedit.h:409
#define SCF_SELECTION
Definition: richedit.h:235
#define LOGPIXELSY
Definition: wingdi.h:718
#define CF_NOVERTFONTS
Definition: commdlg.h:86
Definition: dsound.c:943
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66
#define BOLD_FONTTYPE
Definition: commdlg.h:90

Referenced by OnCommand().

◆ dialog_find()

static void dialog_find ( LPFINDREPLACEW  fr,
BOOL  replace 
)
static

Definition at line 1303 of file wordpad.c.

1304 {
1305  static WCHAR selBuffer[128];
1306  static WCHAR replaceBuffer[128];
1307  static FINDREPLACE_custom custom_data;
1308  static const WCHAR endl = '\r';
1309  FINDTEXTW ft;
1310 
1311  /* Allow only one search/replace dialog to open */
1312  if(hFindWnd != NULL)
1313  {
1315  return;
1316  }
1317 
1318  ZeroMemory(fr, sizeof(FINDREPLACEW));
1319  fr->lStructSize = sizeof(FINDREPLACEW);
1320  fr->hwndOwner = hMainWnd;
1321  fr->Flags = FR_HIDEUPDOWN;
1322  /* Find field is filled with the selected text if it is non-empty
1323  * and stays within the same paragraph, otherwise the previous
1324  * find field is used. */
1326  (LPARAM)&ft.chrg.cpMax);
1327  ft.lpstrText = &endl;
1328  if (ft.chrg.cpMin != ft.chrg.cpMax &&
1330  {
1331  /* Use a temporary buffer for the selected text so that the saved
1332  * find field is only overwritten when a find/replace is clicked. */
1333  GETTEXTEX gt = {sizeof(selBuffer), GT_SELECTION, 1200, NULL, NULL};
1334  SendMessageW(hEditorWnd, EM_GETTEXTEX, (WPARAM)&gt, (LPARAM)selBuffer);
1335  fr->lpstrFindWhat = selBuffer;
1336  } else {
1337  fr->lpstrFindWhat = custom_data.findBuffer;
1338  }
1339  fr->lpstrReplaceWith = replaceBuffer;
1340  custom_data.endPos = -1;
1341  custom_data.wrapped = FALSE;
1342  fr->lCustData = (LPARAM)&custom_data;
1343  fr->wFindWhatLen = sizeof(custom_data.findBuffer);
1344  fr->wReplaceWithLen = sizeof(replaceBuffer);
1345 
1346  if(replace)
1347  hFindWnd = ReplaceTextW(fr);
1348  else
1349  hFindWnd = FindTextW(fr);
1350 }
LPWSTR lpstrFindWhat
Definition: commdlg.h:320
CHARRANGE chrg
Definition: richedit.h:586
static HWND hFindWnd
Definition: wordpad.c:62
HWND WINAPI ReplaceTextW(LPFINDREPLACEW pfr)
Definition: finddlg.c:526
#define GT_SELECTION
Definition: richedit.h:1038
#define ZeroMemory
Definition: winbase.h:1648
LONG cpMax
Definition: richedit.h:501
static HWND hEditorWnd
Definition: wordpad.c:61
UINT_PTR WPARAM
Definition: windef.h:207
#define FR_HIDEUPDOWN
Definition: commdlg.h:132
WCHAR findBuffer[128]
Definition: wordpad.c:93
#define EM_GETSEL
Definition: winuser.h:1979
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
#define EM_GETTEXTEX
Definition: richedit.h:128
HWND WINAPI SetActiveWindow(_In_ HWND)
WORD wReplaceWithLen
Definition: commdlg.h:323
LPARAM lCustData
Definition: commdlg.h:324
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD Flags
Definition: commdlg.h:319
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:47
HWND WINAPI FindTextW(LPFINDREPLACEW pfr)
Definition: finddlg.c:492
__wchar_t WCHAR
Definition: xmlstorage.h:180
WORD wFindWhatLen
Definition: commdlg.h:322
static HWND hMainWnd
Definition: wordpad.c:60
LPWSTR lpstrReplaceWith
Definition: commdlg.h:321
LPCWSTR lpstrText
Definition: richedit.h:587
DWORD lStructSize
Definition: commdlg.h:316
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define FR_DOWN
Definition: commdlg.h:127
#define EM_FINDTEXTW
Definition: richedit.h:147
HWND hwndOwner
Definition: commdlg.h:317
LONG cpMin
Definition: richedit.h:500

Referenced by OnCommand().

◆ dialog_viewproperties()

static void dialog_viewproperties ( void  )
static

Definition at line 1111 of file wordpad.c.

1112 {
1113  PROPSHEETPAGEW psp[2];
1114  PROPSHEETHEADERW psh;
1115  size_t i;
1117  LPCPROPSHEETPAGEW ppsp = (LPCPROPSHEETPAGEW)&psp;
1118 
1119  psp[0].dwSize = sizeof(PROPSHEETPAGEW);
1120  psp[0].dwFlags = PSP_USETITLE;
1121  U(psp[0]).pszTemplate = MAKEINTRESOURCEW(IDD_FORMATOPTS);
1122  psp[0].pfnDlgProc = formatopts_proc;
1123  psp[0].hInstance = hInstance;
1124  psp[0].lParam = reg_formatindex(SF_TEXT);
1125  psp[0].pfnCallback = NULL;
1127  for(i = 1; i < sizeof(psp)/sizeof(psp[0]); i++)
1128  {
1129  psp[i].dwSize = psp[0].dwSize;
1130  psp[i].dwFlags = psp[0].dwFlags;
1131  U(psp[i]).pszTemplate = U(psp[0]).pszTemplate;
1132  psp[i].pfnDlgProc = psp[0].pfnDlgProc;
1133  psp[i].hInstance = psp[0].hInstance;
1134  psp[i].lParam = reg_formatindex(SF_RTF);
1135  psp[i].pfnCallback = psp[0].pfnCallback;
1137  }
1138 
1139  psh.dwSize = sizeof(psh);
1141  psh.hwndParent = hMainWnd;
1142  psh.hInstance = hInstance;
1144  psh.nPages = sizeof(psp)/sizeof(psp[0]);
1145  U3(psh).ppsp = ppsp;
1146  U(psh).pszIcon = MAKEINTRESOURCEW(IDI_WORDPAD);
1147 
1148  if(fileFormat & SF_RTF)
1149  U2(psh).nStartPage = 1;
1150  else
1151  U2(psh).nStartPage = 0;
1152  PropertySheetW(&psh);
1153  set_bar_states();
1155 }
HWND hwndParent
Definition: prsht.h:295
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
#define IDI_WORDPAD
Definition: wordpad.h:186
#define SF_RTF
Definition: richedit.h:721
#define U(x)
Definition: wordpad.c:45
static DWORD wordWrap[2]
Definition: wordpad.c:67
#define STRING_VIEWPROPS_TITLE
Definition: wordpad.h:214
#define U3(x)
Definition: wordpad.c:47
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD dwSize
Definition: prsht.h:214
#define PSH_USEICONID
Definition: prsht.h:42
LPCWSTR pszCaption
Definition: prsht.h:301
DLGPROC pfnDlgProc
Definition: prsht.h:226
struct _PROPSHEETPAGEW PROPSHEETPAGEW
smooth NULL
Definition: ftsmooth.c:416
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2905
LPCWSTR pszTitle
Definition: prsht.h:225
static void set_bar_states(void)
Definition: wordpad.c:711
#define SF_TEXT
Definition: richedit.h:720
#define IDD_FORMATOPTS
Definition: wordpad.h:177
HINSTANCE hInstance
Definition: prsht.h:296
#define STRING_VIEWPROPS_RICHTEXT
Definition: wordpad.h:216
DWORD dwSize
Definition: prsht.h:293
HINSTANCE hInstance
Definition: wordpad.c:3
DWORD dwFlags
Definition: prsht.h:294
static WPARAM fileFormat
Definition: wordpad.c:69
static HWND hMainWnd
Definition: wordpad.c:60
static INT_PTR CALLBACK formatopts_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1013
LPARAM lParam
Definition: prsht.h:227
#define STRING_VIEWPROPS_TEXT
Definition: wordpad.h:215
HINSTANCE hInstance
Definition: prsht.h:216
#define U2(x)
Definition: wordpad.c:46
#define PSP_USETITLE
Definition: prsht.h:26
const PROPSHEETPAGEW * LPCPROPSHEETPAGEW
Definition: prsht.h:245
void target_device(HWND hMainWnd, DWORD wordWrap)
Definition: print.c:209
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
DWORD dwFlags
Definition: prsht.h:215
int reg_formatindex(WPARAM format)
Definition: registry.c:330

Referenced by OnCommand().

◆ DialogOpenFile()

static void DialogOpenFile ( void  )
static

Definition at line 982 of file wordpad.c.

983 {
985 
986  WCHAR wszFile[MAX_PATH] = {'\0'};
987  static const WCHAR wszDefExt[] = {'r','t','f','\0'};
988 
989  ZeroMemory(&ofn, sizeof(ofn));
990 
991  ofn.lStructSize = sizeof(ofn);
997  ofn.lpstrDefExt = wszDefExt;
999 
1000  if(GetOpenFileNameW(&ofn))
1001  {
1002  if(prompt_save_changes())
1004  }
1005 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
HWND hwndOwner
Definition: commdlg.h:330
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
Definition: wordpad.c:72
OPENFILENAME ofn
Definition: main.cpp:37
#define ZeroMemory
Definition: winbase.h:1648
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nMaxFile
Definition: commdlg.h:337
static const WCHAR wszFile[]
Definition: urlmon_main.c:386
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4577
static BOOL prompt_save_changes(void)
Definition: wordpad.c:929
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
static WPARAM fileFormat
Definition: wordpad.c:69
static HWND hMainWnd
Definition: wordpad.c:60
static int fileformat_number(WPARAM format)
Definition: wordpad.c:458
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
static void DoOpenFile(LPCWSTR szOpenFileName)
Definition: wordpad.c:764
LPSTR lpstrFile
Definition: commdlg.h:336
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nFilterIndex
Definition: commdlg.h:335
#define OFN_ENABLESIZING
Definition: commdlg.h:101
DWORD Flags
Definition: commdlg.h:342

Referenced by OnCommand().

◆ DialogSaveFile()

static BOOL DialogSaveFile ( void  )
static

Definition at line 898 of file wordpad.c.

899 {
901 
902  WCHAR wszFile[MAX_PATH] = {'\0'};
903  static const WCHAR wszDefExt[] = {'r','t','f','\0'};
904 
905  ZeroMemory(&sfn, sizeof(sfn));
906 
907  sfn.lStructSize = sizeof(sfn);
913  sfn.lpstrDefExt = wszDefExt;
915 
916  while(GetSaveFileNameW(&sfn))
917  {
919  {
922  continue;
923  }
925  }
926  return FALSE;
927 }
DWORD Flags
Definition: commdlg.h:373
LPCWSTR lpstrFilter
Definition: commdlg.h:363
#define IDYES
Definition: winuser.h:829
#define SF_RTF
Definition: richedit.h:721
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
Definition: wordpad.c:72
LPWSTR lpstrFile
Definition: commdlg.h:367
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4642
DWORD lStructSize
Definition: commdlg.h:360
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
#define MB_YESNO
Definition: winuser.h:811
static const WCHAR wszFile[]
Definition: urlmon_main.c:386
#define STRING_SAVE_LOSEFORMATTING
Definition: wordpad.h:238
DWORD nFilterIndex
Definition: commdlg.h:366
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
OPENFILENAMEW sfn
Definition: eventvwr.c:118
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL DoSaveFile(LPCWSTR wszSaveFileName, WPARAM format)
Definition: wordpad.c:840
#define MAX_PATH
Definition: compat.h:26
DWORD nMaxFile
Definition: commdlg.h:368
static WPARAM fileFormat
Definition: wordpad.c:69
static WPARAM fileformat_flags(int format)
Definition: wordpad.c:472
static HWND hMainWnd
Definition: wordpad.c:60
HWND hwndOwner
Definition: commdlg.h:361
static int fileformat_number(WPARAM format)
Definition: wordpad.c:458
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:137
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define OFN_ENABLESIZING
Definition: commdlg.h:101

Referenced by OnCommand(), and prompt_save_changes().

◆ DoLoadStrings()

static void DoLoadStrings ( void  )
static

Definition at line 97 of file wordpad.c.

98 {
99  LPWSTR p = wszFilter;
100  static const WCHAR files_rtf[] = {'*','.','r','t','f','\0'};
101  static const WCHAR files_txt[] = {'*','.','t','x','t','\0'};
102  static const WCHAR files_all[] = {'*','.','*','\0'};
103 
105 
107  p += lstrlenW(p) + 1;
108  lstrcpyW(p, files_rtf);
109  p += lstrlenW(p) + 1;
111  p += lstrlenW(p) + 1;
112  lstrcpyW(p, files_txt);
113  p += lstrlenW(p) + 1;
115  p += lstrlenW(p) + 1;
116  lstrcpyW(p, files_txt);
117  p += lstrlenW(p) + 1;
119  p += lstrlenW(p) + 1;
120  lstrcpyW(p, files_all);
121  p += lstrlenW(p) + 1;
122  *p = '\0';
123 
126 
127  p = wszSaveChanges;
129 
134 }
#define STRING_UNITS_INCH
Definition: wordpad.h:231
#define STRING_UNITS_CM
Definition: wordpad.h:229
static WCHAR units_inW[MAX_STRING_LEN]
Definition: wordpad.c:76
#define STRING_TEXT_FILES_UNICODE_TXT
Definition: wordpad.h:201
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
Definition: wordpad.c:72
#define MAX_STRING_LEN
Definition: precomp.h:36
#define STRING_UNITS_PT
Definition: wordpad.h:232
#define lstrlenW
Definition: compat.h:416
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define STRING_RICHTEXT_FILES_RTF
Definition: wordpad.h:202
#define STRING_UNITS_IN
Definition: wordpad.h:230
static WCHAR units_cmW[MAX_STRING_LEN]
Definition: wordpad.c:75
#define STRING_TEXT_FILES_TXT
Definition: notepad_res.h:80
#define STRING_ALL_FILES
Definition: notepad_res.h:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
static WCHAR wszDefaultFileName[MAX_STRING_LEN]
Definition: wordpad.c:73
static WCHAR wszSaveChanges[MAX_STRING_LEN]
Definition: wordpad.c:74
static WCHAR units_inchW[MAX_STRING_LEN]
Definition: wordpad.c:77
HINSTANCE hInstance
Definition: wordpad.c:3
#define STRING_PROMPT_SAVE_CHANGES
Definition: wordpad.h:235
#define lstrcpyW
Definition: compat.h:415
static WCHAR units_ptW[MAX_STRING_LEN]
Definition: wordpad.c:78
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define STRING_DEFAULT_FILENAME
Definition: wordpad.h:234

Referenced by OnCreate().

◆ DoOpenFile()

static void DoOpenFile ( LPCWSTR  szOpenFileName)
static

Definition at line 764 of file wordpad.c.

765 {
766  HANDLE hFile;
767  EDITSTREAM es;
768  char fileStart[5];
769  DWORD readOut;
771 
772  hFile = CreateFileW(szOpenFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
775  {
777  return;
778  }
779 
780  ReadFile(hFile, fileStart, 5, &readOut, NULL);
782 
783  if(readOut >= 2 && (BYTE)fileStart[0] == 0xff && (BYTE)fileStart[1] == 0xfe)
784  {
787  } else if(readOut >= 5)
788  {
789  static const char header[] = "{\\rtf";
790  static const BYTE STG_magic[] = { 0xd0,0xcf,0x11,0xe0 };
791 
792  if(!memcmp(header, fileStart, 5))
793  format = SF_RTF;
794  else if (!memcmp(STG_magic, fileStart, sizeof(STG_magic)))
795  {
799  return;
800  }
801  }
802 
803  es.dwCookie = (DWORD_PTR)hFile;
804  es.pfnCallback = stream_in;
805 
809 
811 
813 
814  set_caption(szOpenFileName);
815  if (szOpenFileName[0])
816  SHAddToRecentDocs(SHARD_PATHW, szOpenFileName);
817 
818  lstrcpyW(wszFileName, szOpenFileName);
820  registry_set_filelist(szOpenFileName, hMainWnd);
822 }
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
void registry_set_filelist(LPCWSTR newFile, HWND hMainWnd)
Definition: registry.c:269
#define CloseHandle
Definition: compat.h:407
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define DWORD_PTR
Definition: treelist.c:76
static void ShowOpenError(DWORD Code)
Definition: wordpad.c:748
#define SF_RTF
Definition: richedit.h:721
static void set_fileformat(WPARAM format)
Definition: wordpad.c:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
static void update_font_list(void)
Definition: wordpad.c:424
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
static HWND hEditorWnd
Definition: wordpad.c:61
UINT_PTR WPARAM
Definition: windef.h:207
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FILE_SHARE_READ
Definition: compat.h:125
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:723
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define OPEN_EXISTING
Definition: compat.h:435
#define EM_STREAMIN
Definition: richedit.h:106
#define SF_TEXT
Definition: richedit.h:720
static DWORD CALLBACK stream_in(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
Definition: wordpad.c:183
unsigned long DWORD
Definition: ntddk_ex.h:95
static HWND hMainWnd
Definition: wordpad.c:60
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
#define EM_SETMODIFY
Definition: winuser.h:1995
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned char BYTE
Definition: xxhash.c:193
#define FILE_BEGIN
Definition: winbase.h:112
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
#define lstrcpyW
Definition: compat.h:415
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SHARD_PATHW
Definition: shlobj.h:1103
#define MB_OK
Definition: winuser.h:784
#define STRING_OLE_STORAGE_NOT_SUPPORTED
Definition: wordpad.h:240
#define CreateFileW
Definition: compat.h:409
static void clear_formatting(void)
Definition: wordpad.c:448
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:137
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define es
Definition: i386-dis.c:431
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
static void set_caption(LPCWSTR wszNewFileName)
Definition: wordpad.c:228
#define SF_UNICODE
Definition: richedit.h:724

Referenced by DialogOpenFile(), HandleCommandLine(), OnCommand(), and WndProc().

◆ DoSaveFile()

static BOOL DoSaveFile ( LPCWSTR  wszSaveFileName,
WPARAM  format 
)
static

Definition at line 840 of file wordpad.c.

841 {
842  HANDLE hFile;
844  LRESULT ret;
845 
846  hFile = CreateFileW(wszSaveFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
848 
850  {
852  return FALSE;
853  }
854 
855  if(format == (SF_TEXT | SF_UNICODE))
856  {
857  static const BYTE unicode[] = {0xff,0xfe};
858  DWORD writeOut;
859  WriteFile(hFile, &unicode, sizeof(unicode), &writeOut, 0);
860 
861  if(writeOut != sizeof(unicode))
862  {
864  return FALSE;
865  }
866  }
867 
868  stream.dwCookie = (DWORD_PTR)hFile;
869  stream.pfnCallback = stream_out;
870 
872 
874 
876 
877  if(!ret)
878  {
879  GETTEXTLENGTHEX gt;
880  gt.flags = GTL_DEFAULT;
881  gt.codepage = 1200;
882 
884  return FALSE;
885  }
886 
887  lstrcpyW(wszFileName, wszSaveFileName);
889  if (wszFileName[0])
891 
894 
895  return TRUE;
896 }
#define GTL_DEFAULT
Definition: richedit.h:1054
static void ShowWriteError(DWORD Code)
Definition: wordpad.c:824
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:407
#define DWORD_PTR
Definition: treelist.c:76
static void set_fileformat(WPARAM format)
Definition: wordpad.c:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
static HWND hEditorWnd
Definition: wordpad.c:61
UINT_PTR WPARAM
Definition: windef.h:207
static DWORD CALLBACK stream_out(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
Definition: wordpad.c:196
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:723
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define SF_TEXT
Definition: richedit.h:720
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define EM_SETMODIFY
Definition: winuser.h:1995
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned char BYTE
Definition: xxhash.c:193
#define EM_STREAMOUT
Definition: richedit.h:107
#define CREATE_ALWAYS
Definition: disk.h:72
#define lstrcpyW
Definition: compat.h:415
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SHARD_PATHW
Definition: shlobj.h:1103
#define CreateFileW
Definition: compat.h:409
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
LONG_PTR LRESULT
Definition: windef.h:209
static void set_caption(LPCWSTR wszNewFileName)
Definition: wordpad.c:228
#define SF_UNICODE
Definition: richedit.h:724

Referenced by DialogSaveFile(), OnCommand(), and prompt_save_changes().

◆ enum_font_proc()

static int CALLBACK enum_font_proc ( const LOGFONTW lpelfe,
const TEXTMETRICW lpntme,
DWORD  FontType,
LPARAM  lParam 
)
static

Definition at line 615 of file wordpad.c.

617 {
618  HWND hListWnd = (HWND) lParam;
619 
620  if (lpelfe->lfFaceName[0] == '@') return 1; /* ignore vertical fonts */
621 
622  if(SendMessageW(hListWnd, CB_FINDSTRINGEXACT, -1, (LPARAM)lpelfe->lfFaceName) == CB_ERR)
623  {
624 
625  add_font(lpelfe->lfFaceName, FontType, hListWnd, (const NEWTEXTMETRICEXW*)lpntme);
626  }
627 
628  return 1;
629 }
HANDLE HWND
Definition: compat.h:13
static void add_font(LPCWSTR fontName, DWORD fontType, HWND hListWnd, const NEWTEXTMETRICEXW *ntmc)
Definition: wordpad.c:536
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_ERR
Definition: winuser.h:2410
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LPARAM lParam
Definition: combotst.c:139
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1922

Referenced by populate_font_list().

◆ file_basename()

LPWSTR file_basename ( LPWSTR  path)

Definition at line 212 of file wordpad.c.

213 {
214  LPWSTR pos = path + lstrlenW(path);
215 
216  while(pos > path)
217  {
218  if(*pos == '\\' || *pos == '/')
219  {
220  pos++;
221  break;
222  }
223  pos--;
224  }
225  return pos;
226 }
#define lstrlenW
Definition: compat.h:416
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by format_filelist_filename(), prompt_save_changes(), and set_caption().

◆ fileformat_flags()

static WPARAM fileformat_flags ( int  format)
static

Definition at line 472 of file wordpad.c.

473 {
475 
476  return flags[format];
477 }
#define SF_RTF
Definition: richedit.h:721
UINT_PTR WPARAM
Definition: windef.h:207
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define SF_TEXT
Definition: richedit.h:720
GLbitfield flags
Definition: glext.h:7161
#define SF_UNICODE
Definition: richedit.h:724

Referenced by DialogSaveFile(), and newfile_proc().

◆ fileformat_number()

static int fileformat_number ( WPARAM  format)
static

Definition at line 458 of file wordpad.c.

459 {
460  int number = 0;
461 
462  if(format == SF_TEXT)
463  {
464  number = 1;
465  } else if (format == (SF_TEXT | SF_UNICODE))
466  {
467  number = 2;
468  }
469  return number;
470 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static size_t double number
Definition: printf.c:69
#define SF_TEXT
Definition: richedit.h:720
#define SF_UNICODE
Definition: richedit.h:724

Referenced by DialogOpenFile(), and DialogSaveFile().

◆ formatopts_proc()

static INT_PTR CALLBACK formatopts_proc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1013 of file wordpad.c.

1014 {
1015  switch(message)
1016  {
1017  case WM_INITDIALOG:
1018  {
1020  int wrap = -1;
1021  char id[4];
1022  HWND hIdWnd = GetDlgItem(hWnd, IDC_PAGEFMT_ID);
1023 
1024  sprintf(id, "%d\n", (int)ps->lParam);
1025  SetWindowTextA(hIdWnd, id);
1026  if(wordWrap[ps->lParam] == ID_WORDWRAP_NONE)
1027  wrap = IDC_PAGEFMT_WN;
1028  else if(wordWrap[ps->lParam] == ID_WORDWRAP_WINDOW)
1029  wrap = IDC_PAGEFMT_WW;
1030  else if(wordWrap[ps->lParam] == ID_WORDWRAP_MARGIN)
1031  wrap = IDC_PAGEFMT_WM;
1032 
1033  if(wrap != -1)
1035  IDC_PAGEFMT_WM, wrap);
1036 
1037  if(barState[ps->lParam] & (1 << BANDID_TOOLBAR))
1039  if(barState[ps->lParam] & (1 << BANDID_FORMATBAR))
1041  if(barState[ps->lParam] & (1 << BANDID_RULER))
1043  if(barState[ps->lParam] & (1 << BANDID_STATUSBAR))
1045  }
1046  break;
1047 
1048  case WM_COMMAND:
1049  switch(LOWORD(wParam))
1050  {
1051  case IDC_PAGEFMT_WN:
1052  case IDC_PAGEFMT_WW:
1053  case IDC_PAGEFMT_WM:
1055  LOWORD(wParam));
1056  break;
1057 
1058  case IDC_PAGEFMT_TB:
1059  case IDC_PAGEFMT_FB:
1060  case IDC_PAGEFMT_RU:
1061  case IDC_PAGEFMT_SB:
1064  break;
1065  }
1066  break;
1067  case WM_NOTIFY:
1068  {
1070  if(header->code == PSN_APPLY)
1071  {
1072  HWND hIdWnd = GetDlgItem(hWnd, IDC_PAGEFMT_ID);
1073  char sid[4];
1074  int id;
1075 
1076  GetWindowTextA(hIdWnd, sid, 4);
1077  id = atoi(sid);
1084 
1086  barState[id] |= (1 << BANDID_TOOLBAR);
1087  else
1088  barState[id] &= ~(1 << BANDID_TOOLBAR);
1089 
1091  barState[id] |= (1 << BANDID_FORMATBAR);
1092  else
1093  barState[id] &= ~(1 << BANDID_FORMATBAR);
1094 
1096  barState[id] |= (1 << BANDID_RULER);
1097  else
1098  barState[id] &= ~(1 << BANDID_RULER);
1099 
1101  barState[id] |= (1 << BANDID_STATUSBAR);
1102  else
1103  barState[id] &= ~(1 << BANDID_STATUSBAR);
1104  }
1105  }
1106  break;
1107  }
1108  return FALSE;
1109 }
#define ID_WORDWRAP_MARGIN
Definition: wordpad.h:112
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define ID_WORDWRAP_NONE
Definition: wordpad.h:110
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1330
#define IDC_PAGEFMT_WM
Definition: wordpad.h:126
#define ID_WORDWRAP_WINDOW
Definition: wordpad.h:111
static DWORD wordWrap[2]
Definition: wordpad.c:67
HWND hWnd
Definition: settings.c:17
#define BANDID_STATUSBAR
Definition: wordpad.h:97
FT_UInt sid
Definition: cffcmap.c:139
static DWORD barState[2]
Definition: wordpad.c:68
#define BANDID_TOOLBAR
Definition: wordpad.h:94
#define BANDID_FORMATBAR
Definition: wordpad.h:95
#define PSN_APPLY
Definition: prsht.h:117
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define BANDID_RULER
Definition: wordpad.h:96
#define IDC_PAGEFMT_RU
Definition: wordpad.h:122
struct _PROPSHEETPAGEW * LPPROPSHEETPAGEW
#define IDC_PAGEFMT_FB
Definition: wordpad.h:121
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
#define IDC_PAGEFMT_WW
Definition: wordpad.h:125
#define IDC_PAGEFMT_SB
Definition: wordpad.h:123
LPARAM lParam
Definition: prsht.h:227
#define WM_COMMAND
Definition: winuser.h:1722
#define IDC_PAGEFMT_ID
Definition: wordpad.h:127
#define IDC_PAGEFMT_WN
Definition: wordpad.h:124
#define IDC_PAGEFMT_TB
Definition: wordpad.h:120
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
GLenum GLuint id
Definition: glext.h:5579
#define wrap(journal, var)
Definition: recovery.c:207
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by dialog_viewproperties().

◆ get_comboexlist_selection()

static BOOL get_comboexlist_selection ( HWND  hComboEx,
LPWSTR  wszBuffer,
UINT  bufferLength 
)
static

Definition at line 1389 of file wordpad.c.

1390 {
1391  COMBOBOXEXITEMW cbItem;
1392  COMBOBOXINFO cbInfo;
1393  HWND hCombo, hList;
1394  int idx, result;
1395 
1396  hCombo = (HWND)SendMessageW(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
1397  if (!hCombo)
1398  return FALSE;
1399  cbInfo.cbSize = sizeof(COMBOBOXINFO);
1400  result = SendMessageW(hCombo, CB_GETCOMBOBOXINFO, 0, (LPARAM)&cbInfo);
1401  if (!result)
1402  return FALSE;
1403  hList = cbInfo.hwndList;
1404  idx = SendMessageW(hList, LB_GETCURSEL, 0, 0);
1405  if (idx < 0)
1406  return FALSE;
1407 
1408  ZeroMemory(&cbItem, sizeof(cbItem));
1409  cbItem.mask = CBEIF_TEXT;
1410  cbItem.iItem = idx;
1411  cbItem.pszText = wszBuffer;
1412  cbItem.cchTextMax = bufferLength-1;
1413  result = SendMessageW(hComboEx, CBEM_GETITEMW, 0, (LPARAM)&cbItem);
1414 
1415  return result != 0;
1416 }
HANDLE HWND
Definition: compat.h:13
#define ZeroMemory
Definition: winbase.h:1648
#define CBEIF_TEXT
Definition: commctrl.h:3782
unsigned int idx
Definition: utils.c:41
#define CBEM_GETITEMW
Definition: commctrl.h:3839
#define CB_GETCOMBOBOXINFO
Definition: winuser.h:1923
LONG_PTR LPARAM
Definition: windef.h:208
HWND hList
Definition: livecd.c:10
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CBEM_GETCOMBOCONTROL
Definition: commctrl.h:3828
#define LB_GETCURSEL
Definition: winuser.h:2021
GLuint64EXT * result
Definition: glext.h:11304
struct tagCOMBOBOXINFO COMBOBOXINFO

Referenced by OnCommand().

◆ handle_findmsg()

static LRESULT handle_findmsg ( LPFINDREPLACEW  pFr)
static

Definition at line 1210 of file wordpad.c.

1211 {
1212  if(pFr->Flags & FR_DIALOGTERM)
1213  {
1214  hFindWnd = 0;
1215  pFr->Flags = FR_FINDNEXT;
1216  return 0;
1217  }
1218 
1219  if(pFr->Flags & FR_FINDNEXT || pFr->Flags & FR_REPLACE || pFr->Flags & FR_REPLACEALL)
1220  {
1221  FINDREPLACE_custom *custom_data = (FINDREPLACE_custom*)pFr->lCustData;
1222  DWORD flags;
1223  FINDTEXTEXW ft;
1224  CHARRANGE sel;
1225  LRESULT ret = -1;
1226  HMENU hMenu = GetMenu(hMainWnd);
1227  MENUITEMINFOW mi;
1228 
1229  mi.cbSize = sizeof(mi);
1230  mi.fMask = MIIM_DATA;
1231  mi.dwItemData = 1;
1233 
1234  /* Make sure find field is saved. */
1235  if (pFr->lpstrFindWhat != custom_data->findBuffer)
1236  {
1237  lstrcpynW(custom_data->findBuffer, pFr->lpstrFindWhat,
1238  sizeof(custom_data->findBuffer) / sizeof(WCHAR));
1239  pFr->lpstrFindWhat = custom_data->findBuffer;
1240  }
1241 
1242  SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&sel.cpMin, (LPARAM)&sel.cpMax);
1243  if(custom_data->endPos == -1) {
1244  custom_data->endPos = sel.cpMin;
1245  custom_data->wrapped = FALSE;
1246  }
1247 
1248  flags = FR_DOWN | (pFr->Flags & (FR_MATCHCASE | FR_WHOLEWORD));
1249  ft.lpstrText = pFr->lpstrFindWhat;
1250 
1251  /* Only replace the existing selection if it is an exact match. */
1252  if (sel.cpMin != sel.cpMax &&
1253  (pFr->Flags & FR_REPLACE || pFr->Flags & FR_REPLACEALL))
1254  {
1255  ft.chrg = sel;
1257  if (ft.chrgText.cpMin == sel.cpMin && ft.chrgText.cpMax == sel.cpMax) {
1259  SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&sel.cpMin, (LPARAM)&sel.cpMax);
1260  }
1261  }
1262 
1263  /* Search from the start of the selection, but exclude the first character
1264  * from search if there is a selection. */
1265  ft.chrg.cpMin = sel.cpMin;
1266  if (sel.cpMin != sel.cpMax)
1267  ft.chrg.cpMin++;
1268 
1269  /* Search to the end, then wrap around and search from the start. */
1270  if (!custom_data->wrapped) {
1271  ft.chrg.cpMax = -1;
1273  if (ret == -1) {
1274  custom_data->wrapped = TRUE;
1275  ft.chrg.cpMin = 0;
1276  }
1277  }
1278 
1279  if (ret == -1) {
1280  ft.chrg.cpMax = custom_data->endPos + lstrlenW(pFr->lpstrFindWhat) - 1;
1281  if (ft.chrg.cpMax > ft.chrg.cpMin)
1283  }
1284 
1285  if (ret == -1) {
1286  custom_data->endPos = -1;
1291  } else {
1292  SendMessageW(hEditorWnd, EM_SETSEL, ft.chrgText.cpMin, ft.chrgText.cpMax);
1294 
1295  if (pFr->Flags & FR_REPLACEALL)
1296  return handle_findmsg(pFr);
1297  }
1298  }
1299 
1300  return 0;
1301 }
#define FR_FINDNEXT
Definition: commdlg.h:131
LPWSTR lpstrFindWhat
Definition: commdlg.h:320
#define TRUE
Definition: types.h:120
#define ID_FIND_NEXT
Definition: wordpad.h:45
static HWND hFindWnd
Definition: wordpad.c:62
static MONITORINFO mi
Definition: win.c:7339
static HWND hEditorWnd
Definition: wordpad.c:61
UINT_PTR WPARAM
Definition: windef.h:207
#define lstrlenW
Definition: compat.h:416
WCHAR findBuffer[128]
Definition: wordpad.c:93
#define lstrcpynW
Definition: compat.h:406
#define EM_GETSEL
Definition: winuser.h:1979
#define FR_REPLACEALL
Definition: commdlg.h:143
#define EM_FINDTEXTEXW
Definition: richedit.h:148
#define MB_TASKMODAL
Definition: winuser.h:810
LPARAM lCustData
Definition: commdlg.h:324
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
LONG_PTR LPARAM
Definition: windef.h:208
DWORD Flags
Definition: commdlg.h:319
#define FR_MATCHCASE
Definition: commdlg.h:136
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EM_SETSEL
Definition: winuser.h:2000
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MB_ICONASTERISK
Definition: winuser.h:778
GLbitfield flags
Definition: glext.h:7161
#define FR_REPLACE
Definition: commdlg.h:142
static HWND hMainWnd
Definition: wordpad.c:60
int ret
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LPWSTR lpstrReplaceWith
Definition: commdlg.h:321
#define FR_WHOLEWORD
Definition: commdlg.h:145
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
DWORD cbSize
Definition: winuser.h:3759
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static LRESULT handle_findmsg(LPFINDREPLACEW pFr)
Definition: wordpad.c:1210
#define MB_OK
Definition: winuser.h:784
#define FR_DOWN
Definition: commdlg.h:127
#define STRING_SEARCH_FINISHED
Definition: wordpad.h:236
#define FR_DIALOGTERM
Definition: commdlg.h:126
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:137
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define MIIM_DATA
Definition: winuser.h:721
LONG_PTR LRESULT
Definition: windef.h:209
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define EM_REPLACESEL
Definition: winuser.h:1988
#define EM_SCROLLCARET
Definition: richedit.h:81

Referenced by OnCommand(), and WndProc().

◆ HandleCommandLine()

static void HandleCommandLine ( LPWSTR  cmdline)
static

Definition at line 1157 of file wordpad.c.

1158 {
1159  WCHAR delimiter;
1160  BOOL opt_print = FALSE;
1161 
1162  /* skip white space */
1163  while (*cmdline == ' ') cmdline++;
1164 
1165  /* skip executable name */
1166  delimiter = (*cmdline == '"' ? '"' : ' ');
1167 
1168  if (*cmdline == delimiter) cmdline++;
1169  while (*cmdline && *cmdline != delimiter) cmdline++;
1170  if (*cmdline == delimiter) cmdline++;
1171 
1172  while (*cmdline)
1173  {
1174  while (isspace(*cmdline)) cmdline++;
1175 
1176  if (*cmdline == '-' || *cmdline == '/')
1177  {
1178  if (!cmdline[2] || isspace(cmdline[2]))
1179  {
1180  switch (cmdline[1])
1181  {
1182  case 'P':
1183  case 'p':
1184  opt_print = TRUE;
1185  cmdline += 2;
1186  continue;
1187  }
1188  }
1189  /* a filename starting by / */
1190  }
1191  break;
1192  }
1193 
1194  if (*cmdline)
1195  {
1196  /* file name is passed on the command line */
1197  if (cmdline[0] == '"')
1198  {
1199  cmdline++;
1200  cmdline[lstrlenW(cmdline) - 1] = 0;
1201  }
1204  }
1205 
1206  if (opt_print)
1208 }
#define isspace(c)
Definition: acclib.h:69
#define TRUE
Definition: types.h:120
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define lstrlenW
Definition: compat.h:416
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
const char * delimiter
Definition: string.c:1566
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static HWND hMainWnd
Definition: wordpad.c:60
#define STRING_PRINTING_NOT_IMPLEMENTED
Definition: wordpad.h:245
static void DoOpenFile(LPCWSTR szOpenFileName)
Definition: wordpad.c:764
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
#define MB_OK
Definition: winuser.h:784
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:137
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by WinMain().

◆ is_bar_visible()

static BOOL is_bar_visible ( int  bandId)
static

Definition at line 660 of file wordpad.c.

661 {
662  return barState[reg_formatindex(fileFormat)] & (1 << bandId);
663 }
static DWORD barState[2]
Definition: wordpad.c:68
static WPARAM fileFormat
Definition: wordpad.c:69
int reg_formatindex(WPARAM format)
Definition: registry.c:330

Referenced by OnCommand(), OnInitPopupMenu(), and set_bar_states().

◆ MessageBoxWithResStringW()

static int MessageBoxWithResStringW ( HWND  hWnd,
LPCWSTR  lpText,
LPCWSTR  lpCaption,
UINT  uType 
)
static

Definition at line 137 of file wordpad.c.

138 {
140 
141  params.cbSize = sizeof(params);
142  params.hwndOwner = hWnd;
143  params.hInstance = GetModuleHandleW(0);
144  params.lpszText = lpText;
145  params.lpszCaption = lpCaption;
146  params.dwStyle = uType;
147  params.lpszIcon = NULL;
148  params.dwContextHelpId = 0;
149  params.lpfnMsgBoxCallback = NULL;
150  params.dwLanguageId = 0;
151  return MessageBoxIndirectW(&params);
152 }
HWND hWnd
Definition: settings.c:17
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
int WINAPI MessageBoxIndirectW(_In_ CONST MSGBOXPARAMSW *)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838

Referenced by DialogSaveFile(), DoOpenFile(), handle_findmsg(), HandleCommandLine(), on_sizelist_modified(), OnCreate(), paraformat_proc(), and tabstops_proc().

◆ newfile_proc()

static INT_PTR CALLBACK newfile_proc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1474 of file wordpad.c.

1475 {
1476  switch(message)
1477  {
1478  case WM_INITDIALOG:
1479  {
1482  HWND hListWnd = GetDlgItem(hWnd, IDC_NEWFILE);
1483 
1485  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1487  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1489  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1490 
1491  SendMessageW(hListWnd, LB_SETSEL, TRUE, 0);
1492  }
1493  break;
1494 
1495  case WM_COMMAND:
1496  switch(LOWORD(wParam))
1497  {
1498  case IDOK:
1499  {
1500  LRESULT index;
1501  HWND hListWnd = GetDlgItem(hWnd, IDC_NEWFILE);
1502  index = SendMessageW(hListWnd, LB_GETCURSEL, 0, 0);
1503 
1504  if(index != LB_ERR)
1506  }
1507  return TRUE;
1508 
1509  case IDCANCEL:
1511  return TRUE;
1512  }
1513  }
1514  return FALSE;
1515 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define STRING_NEWFILE_RICHTEXT
Definition: wordpad.h:204
#define LB_ADDSTRING
Definition: winuser.h:2013
#define LB_SETSEL
Definition: winuser.h:2050
HWND hWnd
Definition: settings.c:17
GLuint buffer
Definition: glext.h:5915
#define MAX_STRING_LEN
Definition: precomp.h:36
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define LB_ERR
Definition: winuser.h:2407
#define MAKELONG(a, b)
Definition: typedefs.h:248
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
#define ID_NEWFILE_ABORT
Definition: wordpad.h:114
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
HINSTANCE hInstance
Definition: wordpad.c:3
static WPARAM fileformat_flags(int format)
Definition: wordpad.c:472
#define index(s, c)
Definition: various.h:29
#define WM_COMMAND
Definition: winuser.h:1722
#define STRING_NEWFILE_TXT_UNICODE
Definition: wordpad.h:206
#define IDC_NEWFILE
Definition: wordpad.h:162
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETCURSEL
Definition: winuser.h:2021
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82
#define STRING_NEWFILE_TXT
Definition: wordpad.h:205

Referenced by OnCommand().

◆ number_from_string()

static BOOL number_from_string ( LPCWSTR  string,
float num,
UNIT punit 
)
static

Definition at line 295 of file wordpad.c.

296 {
297  double ret;
298  WCHAR *endptr;
299 
300  *num = 0;
301  errno = 0;
302  ret = wcstod(string, &endptr);
303 
304  if (punit != NULL)
305  *punit = UNIT_CM;
306  if((ret == 0 && errno != 0) || endptr == string || !validate_endptr(endptr, punit))
307  {
308  return FALSE;
309  } else
310  {
311  *num = (float)ret;
312  return TRUE;
313  }
314 }
#define TRUE
Definition: types.h:120
int errno
static BOOL validate_endptr(LPCWSTR endptr, UNIT *punit)
Definition: wordpad.c:256
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint GLuint num
Definition: glext.h:9618
int ret
_Check_return_ double __cdecl wcstod(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr)
static float(__cdecl *square_half_float)(float x

Referenced by on_sizelist_modified(), paraformat_proc(), and tabstops_proc().

◆ number_with_units()

static void number_with_units ( LPWSTR  buffer,
int  number 
)
static

Definition at line 1381 of file wordpad.c.

1382 {
1383  static const WCHAR fmt[] = {'%','.','2','f',' ','%','s','\0'};
1384  float converted = (float)number / (float)TWIPS_PER_INCH *(float)CENTMM_PER_INCH / 1000.0;
1385 
1386  sprintfW(buffer, fmt, converted, units_cmW);
1387 }
#define CENTMM_PER_INCH
Definition: wordpad.h:25
GLuint buffer
Definition: glext.h:5915
static WCHAR units_cmW[MAX_STRING_LEN]
Definition: wordpad.c:75
static size_t double number
Definition: printf.c:69
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TWIPS_PER_INCH
Definition: wordpad.h:24
static float(__cdecl *square_half_float)(float x
#define sprintfW
Definition: unicode.h:58
Definition: dsound.c:943

Referenced by paraformat_proc(), and tabstops_proc().

◆ on_fontlist_modified()

static void on_fontlist_modified ( LPWSTR  wszNewFaceName)
static

Definition at line 525 of file wordpad.c.

526 {
528  ZeroMemory(&format, sizeof(format));
529  format.cbSize = sizeof(format);
531 
532  if(lstrcmpW(format.szFaceName, wszNewFaceName))
533  set_font(wszNewFaceName);
534 }
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define ZeroMemory
Definition: winbase.h:1648
static HWND hEditorWnd
Definition: wordpad.c:61
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
LONG_PTR LPARAM
Definition: windef.h:208
#define EM_GETCHARFORMAT
Definition: richedit.h:91
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static void set_font(LPCWSTR wszFaceName)
Definition: wordpad.c:479
#define SCF_SELECTION
Definition: richedit.h:235

Referenced by OnCommand(), and OnNotify().

◆ on_sizelist_modified()

static void on_sizelist_modified ( HWND  hwndSizeList,
LPWSTR  wszNewFontSize 
)
static

Definition at line 327 of file wordpad.c.

328 {
329  WCHAR sizeBuffer[MAX_STRING_LEN];
331 
332  ZeroMemory(&format, sizeof(format));
333  format.cbSize = sizeof(format);
335 
336  wsprintfW(sizeBuffer, stringFormat, format.yHeight / 20);
337  if(lstrcmpW(sizeBuffer, wszNewFontSize))
338  {
339  float size = 0;
340  if(number_from_string(wszNewFontSize, &size, NULL)
341  && size > 0)
342  {
343  set_size(size);
344  } else
345  {
346  SetWindowTextW(hwndSizeList, sizeBuffer);
349  }
350  }
351 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define ZeroMemory
Definition: winbase.h:1648
#define STRING_INVALID_NUMBER
Definition: wordpad.h:239
#define MAX_STRING_LEN
Definition: precomp.h:36
static HWND hEditorWnd
Definition: wordpad.c:61
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static void set_size(float size)
Definition: wordpad.c:316
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL number_from_string(LPCWSTR string, float *num, UNIT *punit)
Definition: wordpad.c:295
static const WCHAR stringFormat[]
Definition: wordpad.c:55
#define MB_ICONINFORMATION
Definition: winuser.h:796
static HWND hMainWnd
Definition: wordpad.c:60
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
#define EM_GETCHARFORMAT
Definition: richedit.h:91
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_OK
Definition: winuser.h:784
#define SCF_SELECTION
Definition: richedit.h:235
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:137
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by OnCommand(), and OnNotify().

◆ OnCommand()

static LRESULT OnCommand ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 2057 of file wordpad.c.

2058 {
2059  HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
2060  static FINDREPLACEW findreplace;
2061 
2062  if ((HWND)lParam == hwndEditor)
2063  return 0;
2064 
2065  switch(LOWORD(wParam))
2066  {
2067 
2068  case ID_FILE_EXIT:
2069  PostMessageW(hWnd, WM_CLOSE, 0, 0);
2070  break;
2071 
2072  case ID_FILE_NEW:
2073  {
2076 
2077  if(ret != ID_NEWFILE_ABORT)
2078  {
2079  if(prompt_save_changes())
2080  {
2081  SETTEXTEX st;
2082 
2083  set_caption(NULL);
2084  wszFileName[0] = '\0';
2085 
2086  clear_formatting();
2087 
2088  st.flags = ST_DEFAULT;
2089  st.codepage = 1200;
2091 
2094  update_font_list();
2095  }
2096  }
2097  }
2098  break;
2099 
2100  case ID_FILE_OPEN:
2101  DialogOpenFile();
2102  break;
2103 
2104  case ID_FILE_SAVE:
2105  if(wszFileName[0])
2106  {
2108  break;
2109  }
2110  /* Fall through */
2111 
2112  case ID_FILE_SAVEAS:
2113  DialogSaveFile();
2114  break;
2115 
2116  case ID_FILE_RECENT1:
2117  case ID_FILE_RECENT2:
2118  case ID_FILE_RECENT3:
2119  case ID_FILE_RECENT4:
2120  {
2121  HMENU hMenu = GetMenu(hWnd);
2122  MENUITEMINFOW mi;
2123 
2124  mi.cbSize = sizeof(MENUITEMINFOW);
2125  mi.fMask = MIIM_DATA;
2126  if(GetMenuItemInfoW(hMenu, LOWORD(wParam), FALSE, &mi))
2127  DoOpenFile((LPWSTR)mi.dwItemData);
2128  }
2129  break;
2130 
2131  case ID_FIND:
2132  dialog_find(&findreplace, FALSE);
2133  break;
2134 
2135  case ID_FIND_NEXT:
2136  handle_findmsg(&findreplace);
2137  break;
2138 
2139  case ID_REPLACE:
2140  dialog_find(&findreplace, TRUE);
2141  break;
2142 
2143  case ID_FONTSETTINGS:
2145  break;
2146 
2147  case ID_PRINT:
2150  break;
2151 
2152  case ID_PRINT_QUICK:
2155  break;
2156 
2157  case ID_PREVIEW:
2158  {
2160  DWORD tmp = barState[index];
2162  set_bar_states();
2163  barState[index] = tmp;
2165 
2167 
2168  SetMenu(hWnd, NULL);
2169  InvalidateRect(0, 0, TRUE);
2170  }
2171  break;
2172 
2173  case ID_PRINTSETUP:
2176  break;
2177 
2178  case ID_FORMAT_BOLD:
2179  case ID_FORMAT_ITALIC:
2180  case ID_FORMAT_UNDERLINE:
2181  {
2182  CHARFORMAT2W fmt;
2183  int effects = CFE_BOLD;
2184 
2185  ZeroMemory(&fmt, sizeof(fmt));
2186  fmt.cbSize = sizeof(fmt);
2188 
2189  fmt.dwMask = CFM_BOLD;
2190 
2191  if (LOWORD(wParam) == ID_FORMAT_ITALIC)
2192  {
2193  effects = CFE_ITALIC;
2194  fmt.dwMask = CFM_ITALIC;
2195  } else if (LOWORD(wParam) == ID_FORMAT_UNDERLINE)
2196  {
2197  effects = CFE_UNDERLINE;
2198  fmt.dwMask = CFM_UNDERLINE;
2199  }
2200 
2201  fmt.dwEffects ^= effects;
2202 
2204  break;
2205  }
2206 
2207  case ID_FORMAT_COLOR:
2208  {
2209  HWND hReBarWnd = GetDlgItem(hWnd, IDC_REBAR);
2210  HWND hFormatBarWnd = GetDlgItem(hReBarWnd, IDC_FORMATBAR);
2211  HMENU hPop;
2212  RECT itemrc;
2213  POINT pt;
2214  int mid;
2215  int itemidx = SendMessageW(hFormatBarWnd, TB_COMMANDTOINDEX, ID_FORMAT_COLOR, 0);
2216 
2217  SendMessageW(hFormatBarWnd, TB_GETITEMRECT, itemidx, (LPARAM)&itemrc);
2218  pt.x = itemrc.left;
2219  pt.y = itemrc.bottom;
2220  ClientToScreen(hFormatBarWnd, &pt);
2221  hPop = GetSubMenu(hColorPopupMenu, 0);
2224  pt.x, pt.y, 0, hWnd, 0);
2225  if (mid >= ID_COLOR_FIRST && mid <= ID_COLOR_AUTOMATIC)
2226  {
2227  CHARFORMAT2W fmt;
2228 
2229  ZeroMemory(&fmt, sizeof(fmt));
2230  fmt.cbSize = sizeof(fmt);
2232 
2233  fmt.dwMask = CFM_COLOR;
2234 
2235  if (mid < ID_COLOR_AUTOMATIC) {
2236  fmt.crTextColor = textcolors[mid - ID_COLOR_FIRST];
2237  fmt.dwEffects &= ~CFE_AUTOCOLOR;
2238  } else {
2239  fmt.dwEffects |= CFE_AUTOCOLOR;
2240  }
2241 
2243  }
2244  break;
2245  }
2246 
2247  case ID_EDIT_CUT:
2248  PostMessageW(hwndEditor, WM_CUT, 0, 0);
2249  break;
2250 
2251  case ID_EDIT_COPY:
2252  PostMessageW(hwndEditor, WM_COPY, 0, 0);
2253  break;
2254 
2255  case ID_EDIT_PASTE:
2256  PostMessageW(hwndEditor, WM_PASTE, 0, 0);
2257  break;
2258 
2259  case ID_EDIT_CLEAR:
2260  PostMessageW(hwndEditor, WM_CLEAR, 0, 0);
2261  break;
2262 
2263  case ID_EDIT_SELECTALL:
2264  {
2265  CHARRANGE range = {0, -1};
2266  SendMessageW(hwndEditor, EM_EXSETSEL, 0, (LPARAM)&range);
2267  /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
2268  return 0;
2269  }
2270 
2271  case ID_EDIT_GETTEXT:
2272  {
2273  int nLen = GetWindowTextLengthW(hwndEditor);
2274  LPWSTR data = HeapAlloc( GetProcessHeap(), 0, (nLen+1)*sizeof(WCHAR) );
2275  TEXTRANGEW tr;
2276 
2277  GetWindowTextW(hwndEditor, data, nLen+1);
2279 
2280  HeapFree( GetProcessHeap(), 0, data);
2281  data = HeapAlloc(GetProcessHeap(), 0, (nLen+1)*sizeof(WCHAR));
2282  tr.chrg.cpMin = 0;
2283  tr.chrg.cpMax = nLen;
2284  tr.lpstrText = data;
2285  SendMessageW(hwndEditor, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
2287  HeapFree( GetProcessHeap(), 0, data );
2288 
2289  /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
2290  return 0;
2291  }
2292 
2293  case ID_EDIT_CHARFORMAT:
2294  case ID_EDIT_DEFCHARFORMAT:
2295  {
2296  CHARFORMAT2W cf;
2297 
2298  ZeroMemory(&cf, sizeof(cf));
2299  cf.cbSize = sizeof(cf);
2300  cf.dwMask = 0;
2301  SendMessageW(hwndEditor, EM_GETCHARFORMAT,
2303  return 0;
2304  }
2305 
2306  case ID_EDIT_PARAFORMAT:
2307  {
2308  PARAFORMAT2 pf;
2309  ZeroMemory(&pf, sizeof(pf));
2310  pf.cbSize = sizeof(pf);
2311  SendMessageW(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
2312  return 0;
2313  }
2314 
2315  case ID_EDIT_SELECTIONINFO:
2316  {
2317  CHARRANGE range = {0, -1};
2318  char buf[128];
2319  WCHAR *data = NULL;
2320 
2321  SendMessageW(hwndEditor, EM_EXGETSEL, 0, (LPARAM)&range);
2322  data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data) * (range.cpMax-range.cpMin+1));
2323  SendMessageW(hwndEditor, EM_GETSELTEXT, 0, (LPARAM)data);
2324  sprintf(buf, "Start = %d, End = %d", range.cpMin, range.cpMax);
2325  MessageBoxA(hWnd, buf, "Editor", MB_OK);
2327  HeapFree( GetProcessHeap(), 0, data);
2328  /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
2329  return 0;
2330  }
2331 
2332  case ID_EDIT_READONLY:
2333  {
2334  LONG nStyle = GetWindowLongW(hwndEditor, GWL_STYLE);
2335  if (nStyle & ES_READONLY)
2336  SendMessageW(hwndEditor, EM_SETREADONLY, 0, 0);
2337  else
2338  SendMessageW(hwndEditor, EM_SETREADONLY, 1, 0);
2339  return 0;
2340  }
2341 
2342  case ID_EDIT_MODIFIED:
2343  if (SendMessageW(hwndEditor, EM_GETMODIFY, 0, 0))
2344  SendMessageW(hwndEditor, EM_SETMODIFY, 0, 0);
2345  else
2346  SendMessageW(hwndEditor, EM_SETMODIFY, 1, 0);
2347  return 0;
2348 
2349  case ID_EDIT_UNDO:
2350  SendMessageW(hwndEditor, EM_UNDO, 0, 0);
2351  return 0;
2352 
2353  case ID_EDIT_REDO:
2354  SendMessageW(hwndEditor, EM_REDO, 0, 0);
2355  return 0;
2356 
2357  case ID_BULLET:
2358  {
2359  PARAFORMAT pf;
2360 
2361  pf.cbSize = sizeof(pf);
2362  pf.dwMask = PFM_NUMBERING;
2363  SendMessageW(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
2364 
2365  pf.dwMask |= PFM_OFFSET;
2366 
2367  if(pf.wNumbering == PFN_BULLET)
2368  {
2369  pf.wNumbering = 0;
2370  pf.dxOffset = 0;
2371  } else
2372  {
2373  pf.wNumbering = PFN_BULLET;
2374  pf.dxOffset = 720;
2375  }
2376 
2377  SendMessageW(hwndEditor, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
2378  }
2379  break;
2380 
2381  case ID_ALIGN_LEFT:
2382  case ID_ALIGN_CENTER:
2383  case ID_ALIGN_RIGHT:
2384  {
2385  PARAFORMAT2 pf;
2386 
2387  pf.cbSize = sizeof(pf);
2388  pf.dwMask = PFM_ALIGNMENT;
2389  switch(LOWORD(wParam)) {
2390  case ID_ALIGN_LEFT: pf.wAlignment = PFA_LEFT; break;
2391  case ID_ALIGN_CENTER: pf.wAlignment = PFA_CENTER; break;
2392  case ID_ALIGN_RIGHT: pf.wAlignment = PFA_RIGHT; break;
2393  }
2394  SendMessageW(hwndEditor, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
2395  break;
2396  }
2397 
2398  case ID_BACK_1:
2399  SendMessageW(hwndEditor, EM_SETBKGNDCOLOR, 1, 0);
2400  break;
2401 
2402  case ID_BACK_2:
2403  SendMessageW(hwndEditor, EM_SETBKGNDCOLOR, 0, RGB(255,255,192));
2404  break;
2405 
2406  case ID_TOGGLE_TOOLBAR:
2408  update_window();
2409  break;
2410 
2411  case ID_TOGGLE_FORMATBAR:
2415  update_window();
2416  break;
2417 
2418  case ID_TOGGLE_STATUSBAR:
2420  update_window();
2421  break;
2422 
2423  case ID_TOGGLE_RULER:
2425  update_window();
2426  break;
2427 
2428  case ID_DATETIME:
2430  break;
2431 
2432  case ID_PARAFORMAT:
2434  break;
2435 
2436  case ID_TABSTOPS:
2438  break;
2439 
2440  case ID_ABOUT:
2441  dialog_about();
2442  break;
2443 
2444  case ID_VIEWPROPERTIES:
2446  break;
2447 
2448  case IDC_FONTLIST:
2449  if (HIWORD(wParam) == CBN_SELENDOK)
2450  {
2452  HWND hwndFontList = (HWND)lParam;
2455  }
2456  break;
2457 
2458  case IDC_SIZELIST:
2459  if (HIWORD(wParam) == CBN_SELENDOK)
2460  {
2462  HWND hwndSizeList = (HWND)lParam;
2464  on_sizelist_modified(hwndSizeList, buffer);
2465  }
2466  break;
2467 
2468  default:
2469  SendMessageW(hwndEditor, WM_COMMAND, wParam, lParam);
2470  break;
2471  }
2472  return 0;
2473 }
static IClassFactory * cf
#define PFA_RIGHT
Definition: richedit.h:922
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
#define PFN_BULLET
Definition: richedit.h:905
#define IDD_NEWFILE
Definition: wordpad.h:174
#define ID_FILE_RECENT1
Definition: wordpad.h:33
#define CFE_AUTOCOLOR
Definition: richedit.h:414
#define TRUE
Definition: types.h:120
#define ID_TOGGLE_STATUSBAR
Definition: wordpad.h:86
#define LF_FACESIZE
Definition: dimm.idl:39
#define ID_EDIT_CLEAR
Definition: wordpad.h:74
#define ID_FIND_NEXT
Definition: wordpad.h:45
#define ID_PARAFORMAT
Definition: wordpad.h:130
static void set_toolbar_state(int bandId, BOOL show)
Definition: wordpad.c:675
void dialog_print(HWND hMainWnd, LPWSTR wszFileName)
Definition: print.c:551
#define ID_FORMAT_UNDERLINE
Definition: wordpad.h:81
#define ID_FORMAT_COLOR
Definition: wordpad.h:82
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WM_CUT
Definition: winuser.h:1843
#define CFE_UNDERLINE
Definition: richedit.h:408
UINT cbSize
Definition: richedit.h:653
static const COLORREF textcolors[]
Definition: wordpad.c:2049
#define EM_GETTEXTRANGE
Definition: richedit.h:108
#define RGB(r, g, b)
Definition: precomp.h:62
#define EM_SETREADONLY
Definition: winuser.h:1997
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define pt(x, y)
Definition: drawing.c:79
#define TPM_LEFTALIGN
Definition: winuser.h:2352
static void dialog_choose_font(void)
Definition: wordpad.c:566
void dialog_printsetup(HWND hMainWnd)
Definition: print.c:500
#define ID_TOGGLE_TOOLBAR
Definition: wordpad.h:84
#define TPM_RETURNCMD
Definition: winuser.h:2362
static void set_fileformat(WPARAM format)
Definition: wordpad.c:739
#define ID_PRINT_QUICK
Definition: wordpad.h:42
static DWORD wordWrap[2]
Definition: wordpad.c:67
#define ID_EDIT_COPY
Definition: resource.h:48
#define ID_COLOR_AUTOMATIC
Definition: wordpad.h:153
WORD wAlignment
Definition: richedit.h:673
const char * fmt
Definition: wsprintf.c:30
HWND hWnd
Definition: settings.c:17
#define BANDID_STATUSBAR
Definition: wordpad.h:97
HANDLE HWND
Definition: compat.h:13
#define ID_PRINTSETUP
Definition: wordpad.h:41
#define ID_EDIT_SELECTALL
Definition: wordpad.h:61
#define WM_PASTE
Definition: winuser.h:1845
#define PFM_ALIGNMENT
Definition: richedit.h:841
static DWORD barState[2]
Definition: wordpad.c:68
static void update_font_list(void)
Definition: wordpad.c:424
#define ZeroMemory
Definition: winbase.h:1648
LONG cpMax
Definition: richedit.h:501
GLuint buffer
Definition: glext.h:5915
#define CFM_ITALIC
Definition: richedit.h:333
#define MAX_STRING_LEN
Definition: precomp.h:36
#define ID_FILE_OPEN
Definition: resource.h:41
static MONITORINFO mi
Definition: win.c:7339
#define ID_EDIT_READONLY
Definition: wordpad.h:63
static HWND hEditorWnd
Definition: wordpad.c:61
#define BANDID_TOOLBAR
Definition: wordpad.h:94
UINT_PTR WPARAM
Definition: windef.h:207
#define ID_FORMAT_BOLD
Definition: wordpad.h:79
#define ES_READONLY
Definition: pedump.c:675
#define ID_FIND
Definition: wordpad.h:44
#define BANDID_FORMATBAR
Definition: wordpad.h:95
LONG left
Definition: windef.h:306
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define ID_DATETIME
Definition: wordpad.h:129
#define EM_SETPARAFORMAT
Definition: richedit.h:104
#define WM_CLEAR
Definition: winuser.h:1846
WPARAM wParam
Definition: combotst.c:138
#define IDC_FONTLIST
Definition: wordpad.h:168
#define TB_GETITEMRECT
Definition: commctrl.h:1129
#define ID_REPLACE
Definition: wordpad.h:46
static void set_statusbar_state(BOOL show)
Definition: wordpad.c:703
#define PFM_NUMBERING
Definition: richedit.h:843
#define EM_GETPARAFORMAT
Definition: richedit.h:94
#define CFE_BOLD
Definition: richedit.h:406
#define ID_ALIGN_RIGHT
Definition: wordpad.h:56
#define EM_EXGETSEL
Definition: richedit.h:85
int WINAPI MessageBoxA(_In_opt_ HWND, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_ UINT)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define IDD_DATETIME
Definition: wordpad.h:173
static HMENU hColorPopupMenu
Definition: wordpad.c:63
#define BANDID_RULER
Definition: wordpad.h:96
DWORD flags
Definition: richedit.h:1065
#define WM_COPY
Definition: winuser.h:1844
#define CBN_SELENDOK
Definition: winuser.h:1963
long LONG
Definition: pedump.c:60
static void update_window(void)
Definition: wordpad.c:651
static void DialogOpenFile(void)
Definition: wordpad.c:982
#define ID_FILE_EXIT
Definition: resource.h:46
#define TPM_TOPALIGN
Definition: winuser.h:2358
#define TB_COMMANDTOINDEX
Definition: commctrl.h:1107
static BOOL prompt_save_changes(void)
Definition: wordpad.c:929
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define ID_EDIT_UNDO
Definition: wordpad.h:68
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define ST_DEFAULT
Definition: richedit.h:1070
#define CFM_COLOR
Definition: richedit.h:361
smooth NULL
Definition: ftsmooth.c:416
LPWSTR lpstrText
Definition: richedit.h:515
#define CFM_UNDERLINE
Definition: richedit.h:334
LONG_PTR LPARAM
Definition: windef.h:208
#define ID_EDIT_MODIFIED
Definition: wordpad.h:64
#define IDC_SIZELIST
Definition: wordpad.h:169
#define ID_ABOUT
Definition: charmap.c:18
#define EM_SETBKGNDCOLOR
Definition: richedit.h:100
GLuint index
Definition: glext.h:6031
#define ID_FILE_SAVE
Definition: resource.h:42
#define IDC_FORMATBAR
Definition: wordpad.h:158
DWORD dwMask
Definition: richedit.h:667
static void set_bar_states(void)
Definition: wordpad.c:711
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4374
#define ID_FILE_NEW
Definition: resource.h:40
static void on_fontlist_modified(LPWSTR wszNewFaceName)
Definition: wordpad.c:525
#define ID_TABSTOPS
Definition: wordpad.h:131
#define ID_NEWFILE_ABORT
Definition: wordpad.h:114
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define ID_BULLET
Definition: wordpad.h:75
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define IDC_EDITOR
Definition: wordpad.h:156
static BOOL is_bar_visible(int bandId)
Definition: wordpad.c:660
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define ID_EDIT_CHARFORMAT
Definition: wordpad.h:65
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ID_ALIGN_CENTER
Definition: wordpad.h:55
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
#define ID_EDIT_DEFCHARFORMAT
Definition: wordpad.h:67
#define ID_EDIT_SELECTIONINFO
Definition: wordpad.h:62
#define ID_PREVIEW
Definition: wordpad.h:40
#define ID_BACK_2
Definition: wordpad.h:59
static BOOL DoSaveFile(LPCWSTR wszSaveFileName, WPARAM format)
Definition: wordpad.c:840
#define ID_FONTSETTINGS
Definition: wordpad.h:77
#define PFA_CENTER
Definition: richedit.h:923
#define WM_CLOSE
Definition: winuser.h:1603
#define EM_GETMODIFY
Definition: winuser.h:1976
#define ID_FORMAT_ITALIC
Definition: wordpad.h:80
int WINAPI GetWindowTextLengthW(_In_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ID_FILE_RECENT2
Definition: wordpad.h:34
static void dialog_about(void)
Definition: wordpad.c:1007
#define ID_EDIT_CUT
Definition: wordpad.h:72
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HINSTANCE hInstance
Definition: wordpad.c:3
#define TPM_NONOTIFY
Definition: winuser.h:2361
static WPARAM fileFormat
Definition: wordpad.c:69
#define ID_FILE_SAVEAS
Definition: resource.h:43
#define ID_EDIT_GETTEXT
Definition: wordpad.h:70
#define EM_EXSETSEL
Definition: richedit.h:88
#define ID_COLOR_FIRST
Definition: wordpad.h:136
void init_preview(HWND hMainWnd, LPWSTR wszFileName)
Definition: print.c:737
static HWND hMainWnd
Definition: wordpad.c:60
int ret
#define EM_UNDO
Definition: winuser.h:2003
#define index(s, c)
Definition: various.h:29
static INT_PTR CALLBACK tabstops_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1642
#define CFE_ITALIC
Definition: richedit.h:407
#define EM_REDO
Definition: richedit.h:117
#define EM_SETTEXTEX
Definition: richedit.h:131
#define EM_SETMODIFY
Definition: winuser.h:1995
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
#define ID_FILE_RECENT4
Definition: wordpad.h:36
WORD wNumbering
Definition: richedit.h:655
GLenum GLint * range
Definition: glext.h:7539
static void dialog_viewproperties(void)
Definition: wordpad.c:1111
#define ID_EDIT_REDO
Definition: wordpad.h:69
#define BANDID_SIZELIST
Definition: wordpad.h:99
#define GWL_STYLE
Definition: winuser.h:846
#define ID_BACK_1
Definition: wordpad.h:58
DWORD dwMask
Definition: richedit.h:654
static INT_PTR CALLBACK datetime_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1418
static void DoOpenFile(LPCWSTR szOpenFileName)
Definition: wordpad.c:764
#define ID_PRINT
Definition: wordpad.h:39
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
void target_device(HWND hMainWnd, DWORD wordWrap)
Definition: print.c:209
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define CFM_BOLD
Definition: richedit.h:332
void print_quick(HWND hMainWnd, LPWSTR wszFileName)
Definition: print.c:539
#define ID_EDIT_PARAFORMAT
Definition: wordpad.h:66
DWORD cbSize
Definition: winuser.h:3759
CHARRANGE chrg
Definition: richedit.h:514
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDD_TABSTOPS
Definition: wordpad.h:176
#define ID_TOGGLE_FORMATBAR
Definition: wordpad.h:85
UINT codepage
Definition: richedit.h:1066
static LRESULT handle_findmsg(LPFINDREPLACEW pFr)
Definition: wordpad.c:1210
#define MB_OK
Definition: winuser.h:784
static BOOL DialogSaveFile(void)
Definition: wordpad.c:898
#define BANDID_FONTLIST
Definition: wordpad.h:98
static INT_PTR CALLBACK newfile_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1474
static BOOL get_comboexlist_selection(HWND hComboEx, LPWSTR wszBuffer, UINT bufferLength)
Definition: wordpad.c:1389
#define IDD_PARAFORMAT
Definition: wordpad.h:175
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LONG dxOffset
Definition: richedit.h:659
#define TPM_LEFTBUTTON
Definition: winuser.h:2354
#define PFA_LEFT
Definition: richedit.h:921
#define HIWORD(l)
Definition: typedefs.h:246
#define ID_EDIT_PASTE
Definition: resource.h:49
#define SCF_SELECTION
Definition: richedit.h:235
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
LONG bottom
Definition: windef.h:309
UINT cbSize
Definition: richedit.h:666
static void clear_formatting(void)
Definition: wordpad.c:448
static void dialog_find(LPFINDREPLACEW fr, BOOL replace)
Definition: wordpad.c:1303
#define ID_ALIGN_LEFT
Definition: wordpad.h:54
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static void on_sizelist_modified(HWND hwndSizeList, LPWSTR wszNewFontSize)
Definition: wordpad.c:327
#define MIIM_DATA
Definition: winuser.h:721
#define PFM_OFFSET
Definition: richedit.h:840
#define EM_GETSELTEXT
Definition: richedit.h:95
#define ID_VIEWPROPERTIES
Definition: wordpad.h:134
#define ID_TOGGLE_RULER
Definition: wordpad.h:87
HMENU WINAPI GetMenu(_In_ HWND)
#define IDC_REBAR
Definition: wordpad.h:159
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define ID_FILE_RECENT3
Definition: wordpad.h:35
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define LOWORD(l)
Definition: pedump.c:82
Definition: dsound.c:943
struct tagMENUITEMINFOW MENUITEMINFOW
#define HeapFree(x, y, z)
Definition: compat.h:403
static void set_caption(LPCWSTR wszNewFileName)
Definition: wordpad.c:228
LONG cpMin
Definition: richedit.h:500
int reg_formatindex(WPARAM format)
Definition: registry.c:330
static INT_PTR CALLBACK paraformat_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1517

Referenced by WndProc().

◆ OnCreate()

static LRESULT OnCreate ( HWND  hWnd)
static

Definition at line 1794 of file wordpad.c.

1795 {
1796  HWND hToolBarWnd, hFormatBarWnd, hReBarWnd, hFontListWnd, hSizeListWnd, hRulerWnd;
1798  HANDLE hDLL;
1799  TBADDBITMAP ab;
1800  int nStdBitmaps = 0;
1801  REBARINFO rbi;
1802  REBARBANDINFOW rbb;
1803  static const WCHAR wszRichEditDll[] = {'R','I','C','H','E','D','2','0','.','D','L','L','\0'};
1804  static const WCHAR wszRichEditText[] = {'R','i','c','h','E','d','i','t',' ','t','e','x','t','\0'};
1805 
1807 
1811 
1812  rbi.cbSize = sizeof(rbi);
1813  rbi.fMask = 0;
1814  rbi.himl = NULL;
1815  if(!SendMessageW(hReBarWnd, RB_SETBARINFO, 0, (LPARAM)&rbi))
1816  return -1;
1817 
1819  IDC_TOOLBAR,
1820  1, hInstance, IDB_TOOLBAR,
1821  NULL, 0,
1822  24, 24, 16, 16, sizeof(TBBUTTON));
1823 
1824  ab.hInst = HINST_COMMCTRL;
1825  ab.nID = IDB_STD_SMALL_COLOR;
1826  nStdBitmaps = SendMessageW(hToolBarWnd, TB_ADDBITMAP, 0, (LPARAM)&ab);
1827 
1828  AddButton(hToolBarWnd, nStdBitmaps+STD_FILENEW, ID_FILE_NEW);
1829  AddButton(hToolBarWnd, nStdBitmaps+STD_FILEOPEN, ID_FILE_OPEN);
1830  AddButton(hToolBarWnd, nStdBitmaps+STD_FILESAVE, ID_FILE_SAVE);
1831  AddSeparator(hToolBarWnd);
1832  AddButton(hToolBarWnd, nStdBitmaps+STD_PRINT, ID_PRINT_QUICK);
1833  AddButton(hToolBarWnd, nStdBitmaps+STD_PRINTPRE, ID_PREVIEW);
1834  AddSeparator(hToolBarWnd);
1835  AddButton(hToolBarWnd, nStdBitmaps+STD_FIND, ID_FIND);
1836  AddSeparator(hToolBarWnd);
1837  AddButton(hToolBarWnd, nStdBitmaps+STD_CUT, ID_EDIT_CUT);
1838  AddButton(hToolBarWnd, nStdBitmaps+STD_COPY, ID_EDIT_COPY);
1839  AddButton(hToolBarWnd, nStdBitmaps+STD_PASTE, ID_EDIT_PASTE);
1840  AddButton(hToolBarWnd, nStdBitmaps+STD_UNDO, ID_EDIT_UNDO);
1841  AddButton(hToolBarWnd, nStdBitmaps+STD_REDOW, ID_EDIT_REDO);
1842  AddSeparator(hToolBarWnd);
1843  AddButton(hToolBarWnd, 0, ID_DATETIME);
1844 
1845  SendMessageW(hToolBarWnd, TB_AUTOSIZE, 0, 0);
1846 
1850  rbb.cx = 0;
1851  rbb.hwndChild = hToolBarWnd;
1852  rbb.cxMinChild = 0;
1853  rbb.cyChild = rbb.cyMinChild = HIWORD(SendMessageW(hToolBarWnd, TB_GETBUTTONSIZE, 0, 0));
1854  rbb.wID = BANDID_TOOLBAR;
1855 
1856  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1857 
1858  hFontListWnd = CreateWindowExW(0, WC_COMBOBOXEXW, NULL,
1860  0, 0, 200, 150, hReBarWnd, (HMENU)IDC_FONTLIST, hInstance, NULL);
1861 
1862  rbb.hwndChild = hFontListWnd;
1863  rbb.cx = 200;
1864  rbb.wID = BANDID_FONTLIST;
1865 
1866  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1867 
1868  hSizeListWnd = CreateWindowExW(0, WC_COMBOBOXEXW, NULL,
1870  0, 0, 50, 150, hReBarWnd, (HMENU)IDC_SIZELIST, hInstance, NULL);
1871 
1872  rbb.hwndChild = hSizeListWnd;
1873  rbb.cx = 50;
1874  rbb.fStyle ^= RBBS_BREAK;
1875  rbb.wID = BANDID_SIZELIST;
1876 
1877  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1878 
1879  hFormatBarWnd = CreateToolbarEx(hReBarWnd,
1881  IDC_FORMATBAR, 8, hInstance, IDB_FORMATBAR, NULL, 0, 16, 16, 16, 16, sizeof(TBBUTTON));
1882 
1883  AddButton(hFormatBarWnd, 0, ID_FORMAT_BOLD);
1884  AddButton(hFormatBarWnd, 1, ID_FORMAT_ITALIC);
1885  AddButton(hFormatBarWnd, 2, ID_FORMAT_UNDERLINE);
1886  AddButton(hFormatBarWnd, 3, ID_FORMAT_COLOR);
1887  AddSeparator(hFormatBarWnd);
1888  AddButton(hFormatBarWnd, 4, ID_ALIGN_LEFT);
1889  AddButton(hFormatBarWnd, 5, ID_ALIGN_CENTER);
1890  AddButton(hFormatBarWnd, 6, ID_ALIGN_RIGHT);
1891  AddSeparator(hFormatBarWnd);
1892  AddButton(hFormatBarWnd, 7, ID_BULLET);
1893 
1894  SendMessageW(hFormatBarWnd, TB_AUTOSIZE, 0, 0);
1895 
1896  rbb.hwndChild = hFormatBarWnd;
1897  rbb.wID = BANDID_FORMATBAR;
1898 
1899  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1900 
1901  hRulerWnd = CreateWindowExW(0, WC_STATICW, NULL, WS_VISIBLE | WS_CHILD,
1902  0, 0, 200, 10, hReBarWnd, (HMENU)IDC_RULER, hInstance, NULL);
1903 
1904 
1905  rbb.hwndChild = hRulerWnd;
1906  rbb.wID = BANDID_RULER;
1907  rbb.fStyle |= RBBS_BREAK;
1908 
1909  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1910 
1911  hDLL = LoadLibraryW(wszRichEditDll);
1912  if(!hDLL)
1913  {
1916  PostQuitMessage(1);
1917  }
1918 
1922  0, 0, 1000, 100, hWnd, (HMENU)IDC_EDITOR, hInstance, NULL);
1923 
1924  if (!hEditorWnd)
1925  {
1926  fprintf(stderr, "Error code %u\n", GetLastError());
1927  return -1;
1928  }
1929  assert(hEditorWnd);
1930 
1934 
1935  set_default_font();
1936 
1937  populate_font_list(hFontListWnd);
1938  populate_size_list(hSizeListWnd);
1939  DoLoadStrings();
1941 
1943 
1948 
1949  return 0;
1950 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define CBS_SORT
Definition: winuser.h:292
#define STD_PASTE
Definition: commctrl.h:1069
static void AddSeparator(HWND hwndToolBar)
Definition: wordpad.c:169
#define TRUE
Definition: types.h:120
#define IDC_STATUSBAR
Definition: resource.h:12
#define RBBIM_CHILD
Definition: commctrl.h:1502
#define RBS_VARHEIGHT
Definition: commctrl.h:1467
#define FINDMSGSTRINGW
Definition: commdlg.h:28
#define ID_FORMAT_UNDERLINE
Definition: wordpad.h:81
#define ID_FORMAT_COLOR
Definition: wordpad.h:82
static const WCHAR RICHEDIT_CLASS20W[]
Definition: richedit.h:50
static void DoLoadStrings(void)
Definition: wordpad.c:97
#define ENM_SELCHANGE
Definition: richedit.h:478
#define ID_PRINT_QUICK
Definition: wordpad.h:42
static DWORD wordWrap[2]
Definition: wordpad.c:67
#define ES_MULTILINE
Definition: pedump.c:667
#define ID_EDIT_COPY
Definition: resource.h:48
#define RBBS_BREAK
Definition: commctrl.h:1485
HWND hWnd
Definition: settings.c:17
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:527
#define RBBIM_ID
Definition: commctrl.h:1506
static void populate_size_list(HWND hSizeListWnd)
Definition: wordpad.c:365
#define IDB_STD_SMALL_COLOR
Definition: commctrl.h:1060
#define assert(x)
Definition: debug.h:53
static DWORD barState[2]
Definition: wordpad.c:68
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define RBBS_CHILDEDGE
Definition: commctrl.h:1487
HWND WINAPI SetFocus(_In_opt_ HWND)
#define ID_FILE_OPEN
Definition: resource.h:41
static HWND hEditorWnd
Definition: wordpad.c:61
#define BANDID_TOOLBAR
Definition: wordpad.h:94
#define ID_FORMAT_BOLD
Definition: wordpad.h:79
#define STD_FILENEW
Definition: commctrl.h:1073
#define WS_CHILD
Definition: pedump.c:617
#define ID_FIND
Definition: wordpad.h:44
#define BANDID_FORMATBAR
Definition: wordpad.h:95
#define ID_DATETIME
Definition: wordpad.h:129
#define WS_CLIPCHILDREN
Definition: pedump.c:619
HWND WINAPI CreateToolbarEx(HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HINSTANCE hBMInst, UINT_PTR wBMID, LPCTBBUTTON lpButtons, INT iNumButtons, INT dxButton, INT dyButton, INT dxBitmap, INT dyBitmap, UINT uStructSize)
Definition: commctrl.c:929
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define STD_PRINT
Definition: commctrl.h:1081
#define IDC_FONTLIST
Definition: wordpad.h:168
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define ID_ALIGN_RIGHT
Definition: wordpad.h:56
#define REBARBANDINFOW_V6_SIZE
Definition: commctrl.h:1538
#define REBARCLASSNAMEW
Definition: commctrl.h:1459
#define RBBIM_STYLE
Definition: commctrl.h:1498
#define RBBIM_SIZE
Definition: commctrl.h:1504
#define CCS_NODIVIDER
Definition: commctrl.h:2244
#define BTNS_BUTTON
Definition: commctrl.h:994
#define BANDID_RULER
Definition: wordpad.h:96
static void AddButton(HWND hwndToolBar, int nImage, int nCommand)
Definition: wordpad.c:155
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define TB_AUTOSIZE
Definition: commctrl.h:1133
HWND WINAPI CreateStatusWindowW(LONG style, LPCWSTR text, HWND parent, UINT wid)
Definition: commctrl.c:795
#define CW_USEDEFAULT
Definition: winuser.h:225
#define IDC_RULER
Definition: wordpad.h:170
#define ID_EDIT_UNDO
Definition: wordpad.h:68
#define ES_WANTRETURN
Definition: pedump.c:676
#define LoadLibraryW(x)
Definition: compat.h:413
smooth NULL
Definition: ftsmooth.c:416
#define STD_COPY
Definition: commctrl.h:1068
LONG_PTR LPARAM
Definition: windef.h:208
#define CCS_TOP
Definition: commctrl.h:2238
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2242
#define RB_INSERTBANDW
Definition: commctrl.h:1579
#define IDC_SIZELIST
Definition: wordpad.h:169
#define ES_SELECTIONBAR
Definition: richedit.h:230
UCHAR ab[sizeof("Hello World!") -1]
Definition: fdi.c:106
#define ID_FILE_SAVE
Definition: resource.h:42
#define STRING_LOAD_RICHED_FAILED
Definition: wordpad.h:237
#define RB_SETBARINFO
Definition: commctrl.h:1574
#define EM_SETEVENTMASK
Definition: richedit.h:102
#define IDC_FORMATBAR
Definition: wordpad.h:158
#define STD_REDOW
Definition: commctrl.h:1071
#define ID_FILE_NEW
Definition: resource.h:40
#define TB_GETBUTTONSIZE
Definition: commctrl.h:1156
#define ES_AUTOVSCROLL
Definition: pedump.c:671
static UINT ID_FINDMSGSTRING
Definition: wordpad.c:65
#define ID_BULLET
Definition: wordpad.h:75
#define IDC_EDITOR
Definition: wordpad.h:156
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ID_ALIGN_CENTER
Definition: wordpad.h:55
#define ID_PREVIEW
Definition: wordpad.h:40
static void set_default_font(void)
Definition: wordpad.c:501
#define ID_FORMAT_ITALIC
Definition: wordpad.h:80
#define IDC_TOOLBAR
Definition: wordpad.h:157
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:985
#define RBBIM_CHILDSIZE
Definition: commctrl.h:1503
#define ID_EDIT_CUT
Definition: wordpad.h:72
HINSTANCE hInstance
Definition: wordpad.c:3
#define ES_NOHIDESEL
Definition: pedump.c:673
#define WS_HSCROLL
Definition: pedump.c:628
#define TB_ADDBITMAP
Definition: commctrl.h:1052
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define STD_PRINTPRE
Definition: commctrl.h:1076
#define EM_SETMODIFY
Definition: winuser.h:1995
HIMAGELIST himl
Definition: commctrl.h:1479
#define ID_EDIT_REDO
Definition: wordpad.h:69
#define BANDID_SIZELIST
Definition: wordpad.h:99
static void populate_font_list(HWND hListWnd)
Definition: wordpad.c:631
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
#define WS_BORDER
Definition: pedump.c:625
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
#define STD_UNDO
Definition: commctrl.h:1070
#define CBS_DROPDOWN
Definition: winuser.h:283
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WC_COMBOBOXEXW
Definition: commctrl.h:3777
#define WS_VSCROLL
Definition: pedump.c:627
#define MB_OK
Definition: winuser.h:784
#define IDB_FORMATBAR
Definition: wordpad.h:184
#define BANDID_FONTLIST
Definition: wordpad.h:98
#define HINST_COMMCTRL
Definition: commctrl.h:1059
#define WC_STATICW
Definition: commctrl.h:4676
#define CCS_NOMOVEY
Definition: commctrl.h:2239
#define RBBS_NOGRIPPER
Definition: commctrl.h:1493
#define STD_FILESAVE
Definition: commctrl.h:1075
#define HIWORD(l)
Definition: typedefs.h:246
#define ID_EDIT_PASTE
Definition: resource.h:49
FILE * stderr
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HRESULT setup_richedit_olecallback(HWND hEditorWnd)
Definition: olecallback.c:203
#define IDB_TOOLBAR
Definition: wordpad.h:183
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:137
#define ID_ALIGN_LEFT
Definition: wordpad.h:54
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define STD_FIND
Definition: commctrl.h:1079
#define STD_FILEOPEN
Definition: commctrl.h:1074
#define WS_VISIBLE
Definition: pedump.c:620
void registry_read_filelist(HWND hMainWnd)
Definition: registry.c:217
#define IDC_REBAR
Definition: wordpad.h:159
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
void registry_read_options(void)
Definition: registry.c:335
void registry_read_formatopts_all(DWORD barState[], DWORD wordWrap[])
Definition: registry.c:398
#define STD_CUT
Definition: commctrl.h:1067

Referenced by WndProc().

◆ OnInitPopupMenu()

static LRESULT OnInitPopupMenu ( HWND  hWnd,
WPARAM  wParam 
)
static

Definition at line 2475 of file wordpad.c.

2476 {
2477  HMENU hMenu = (HMENU)wParam;
2478  HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
2480  PARAFORMAT pf;
2481  int nAlignment = -1;
2482  int selFrom, selTo;
2483  GETTEXTLENGTHEX gt;
2484  LRESULT textLength;
2485  MENUITEMINFOW mi;
2486 
2487  SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&selFrom, (LPARAM)&selTo);
2488  EnableMenuItem(hMenu, ID_EDIT_COPY, (selFrom == selTo) ? MF_GRAYED : MF_ENABLED);
2489  EnableMenuItem(hMenu, ID_EDIT_CUT, (selFrom == selTo) ? MF_GRAYED : MF_ENABLED);
2490 
2491  pf.cbSize = sizeof(PARAFORMAT);
2492  SendMessageW(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
2496  SendMessageW(hwndEditor, EM_GETMODIFY, 0, 0) ? MF_CHECKED : MF_UNCHECKED);
2497  if (pf.dwMask & PFM_ALIGNMENT)
2498  nAlignment = pf.wAlignment;
2499  CheckMenuItem(hMenu, ID_ALIGN_LEFT, (nAlignment == PFA_LEFT) ? MF_CHECKED : MF_UNCHECKED);
2500  CheckMenuItem(hMenu, ID_ALIGN_CENTER, (nAlignment == PFA_CENTER) ? MF_CHECKED : MF_UNCHECKED);
2501  CheckMenuItem(hMenu, ID_ALIGN_RIGHT, (nAlignment == PFA_RIGHT) ? MF_CHECKED : MF_UNCHECKED);
2503  EnableMenuItem(hMenu, ID_EDIT_UNDO, SendMessageW(hwndEditor, EM_CANUNDO, 0, 0) ?
2504  MF_ENABLED : MF_GRAYED);
2505  EnableMenuItem(hMenu, ID_EDIT_REDO, SendMessageW(hwndEditor, EM_CANREDO, 0, 0) ?
2506  MF_ENABLED : MF_GRAYED);
2507 
2510 
2513 
2516 
2518 
2519  gt.flags = GTL_NUMCHARS;
2520  gt.codepage = 1200;
2521  textLength = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)&gt, 0);
2522  EnableMenuItem(hMenu, ID_FIND, textLength ? MF_ENABLED : MF_GRAYED);
2523 
2524  mi.cbSize = sizeof(mi);
2525  mi.fMask = MIIM_DATA;
2526 
2528 
2529  EnableMenuItem(hMenu, ID_FIND_NEXT, (textLength && mi.dwItemData) ? MF_ENABLED : MF_GRAYED);
2530 
2531  EnableMenuItem(hMenu, ID_REPLACE, textLength ? MF_ENABLED : MF_GRAYED);
2532 
2533  return 0;
2534 }
#define PFA_RIGHT
Definition: richedit.h:922
#define PFN_BULLET
Definition: richedit.h:905
#define ID_TOGGLE_STATUSBAR
Definition: wordpad.h:86
#define IDC_STATUSBAR
Definition: resource.h:12
#define ID_FIND_NEXT
Definition: wordpad.h:45
UINT cbSize
Definition: richedit.h:653
#define ID_TOGGLE_TOOLBAR
Definition: wordpad.h:84
#define ID_EDIT_COPY
Definition: resource.h:48
HWND hWnd
Definition: settings.c:17
#define PFM_ALIGNMENT
Definition: richedit.h:841
static MONITORINFO mi
Definition: win.c:7339
#define ID_EDIT_READONLY
Definition: wordpad.h:63
static HWND hEditorWnd
Definition: wordpad.c:61
#define BANDID_TOOLBAR
Definition: wordpad.h:94
UINT_PTR WPARAM
Definition: windef.h:207
#define ES_READONLY
Definition: pedump.c:675
#define ID_FIND
Definition: wordpad.h:44
#define BANDID_FORMATBAR
Definition: wordpad.h:95
WPARAM wParam
Definition: combotst.c:138
#define ID_REPLACE
Definition: wordpad.h:46
#define EM_GETPARAFORMAT
Definition: richedit.h:94
#define EM_GETSEL
Definition: winuser.h:1979
#define EM_CANREDO
Definition: richedit.h:118
#define ID_ALIGN_RIGHT
Definition: wordpad.h:56
#define BANDID_RULER
Definition: wordpad.h:96
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HWND hwndStatus
Definition: solitaire.cpp:13
#define ID_EDIT_UNDO
Definition: wordpad.h:68
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
LONG_PTR LPARAM
Definition: windef.h:208
#define ID_EDIT_MODIFIED
Definition: wordpad.h:64
#define MF_CHECKED
Definition: winuser.h:132
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define ID_BULLET
Definition: wordpad.h:75
#define IDC_EDITOR
Definition: wordpad.h:156
static BOOL is_bar_visible(int bandId)
Definition: wordpad.c:660
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ID_ALIGN_CENTER
Definition: wordpad.h:55
#define PFA_CENTER
Definition: richedit.h:923
#define MF_ENABLED
Definition: winuser.h:128
#define EM_GETMODIFY
Definition: winuser.h:1976
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_EDIT_CUT
Definition: wordpad.h:72
#define MF_UNCHECKED
Definition: winuser.h:204
struct _paraformat PARAFORMAT
WORD wAlignment
Definition: richedit.h:660
WORD wNumbering
Definition: richedit.h:655
#define ID_EDIT_REDO
Definition: wordpad.h:69
#define GWL_STYLE
Definition: winuser.h:846
DWORD dwMask
Definition: richedit.h:654
#define GTL_NUMCHARS
Definition: richedit.h:1058
DWORD cbSize
Definition: winuser.h:3759
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ID_TOGGLE_FORMATBAR
Definition: wordpad.h:85
#define PFA_LEFT
Definition: richedit.h:921
#define EM_CANUNDO
Definition: winuser.h:1965
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define ID_ALIGN_LEFT
Definition: wordpad.h:54
#define MF_GRAYED
Definition: winuser.h:129
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
#define MIIM_DATA
Definition: winuser.h:721
LONG_PTR LRESULT
Definition: windef.h:209
#define ID_TOGGLE_RULER
Definition: wordpad.h:87
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by WndProc().

◆ OnNotify()

static LRESULT OnNotify ( HWND  hWnd,
LPARAM  lParam 
)
static

Definition at line 2004 of file wordpad.c.

2005 {
2006  HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
2007  HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
2008  NMHDR *pHdr = (NMHDR *)lParam;
2009  HWND hwndFontList = GetDlgItem(hwndReBar, IDC_FONTLIST);
2010  HWND hwndSizeList = GetDlgItem(hwndReBar, IDC_SIZELIST);
2011 
2012  if (pHdr->hwndFrom == hwndFontList || pHdr->hwndFrom == hwndSizeList)
2013  {
2014  if (pHdr->code == CBEN_ENDEDITW)
2015  {
2016  NMCBEENDEDITW *endEdit = (NMCBEENDEDITW *)lParam;
2017  if(pHdr->hwndFrom == hwndFontList)
2018  {
2019  on_fontlist_modified(endEdit->szText);
2020  } else if (pHdr->hwndFrom == hwndSizeList)
2021  {
2022  on_sizelist_modified(hwndSizeList,endEdit->szText);
2023  }
2024  }
2025  return 0;
2026  }
2027 
2028  if (pHdr->hwndFrom != hwndEditor)
2029  return 0;
2030 
2031  if (pHdr->code == EN_SELCHANGE)
2032  {
2033  SELCHANGE *pSC = (SELCHANGE *)lParam;
2034  char buf[128];
2035 
2036  update_font_list();
2037 
2038  sprintf( buf,"selection = %d..%d, line count=%ld",
2039  pSC->chrg.cpMin, pSC->chrg.cpMax,
2040  SendMessageW(hwndEditor, EM_GETLINECOUNT, 0, 0));
2042  SendMessageW(hWnd, WM_USER, 0, 0);
2043  return 1;
2044  }
2045  return 0;
2046 }
#define IDC_STATUSBAR
Definition: resource.h:12
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
HWND hWnd
Definition: settings.c:17
#define EN_SELCHANGE
Definition: richedit.h:193
static void update_font_list(void)
Definition: wordpad.c:424
LONG cpMax
Definition: richedit.h:501
#define IDC_FONTLIST
Definition: wordpad.h:168
UINT code
Definition: winuser.h:3134
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define IDC_SIZELIST
Definition: wordpad.h:169
static void on_fontlist_modified(LPWSTR wszNewFaceName)
Definition: wordpad.c:525
#define CBEN_ENDEDITW
Definition: commctrl.h:3872
#define IDC_EDITOR
Definition: wordpad.h:156
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
HWND hwndFrom
Definition: winuser.h:3132
#define WM_USER
Definition: winuser.h:1877
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
CHARRANGE chrg
Definition: richedit.h:686
static void on_sizelist_modified(HWND hwndSizeList, LPWSTR wszNewFontSize)
Definition: wordpad.c:327
#define IDC_REBAR
Definition: wordpad.h:159
WCHAR szText[CBEMAXSTRLEN]
Definition: commctrl.h:3910
LPARAM lParam
Definition: combotst.c:139
LONG cpMin
Definition: richedit.h:500
#define EM_GETLINECOUNT
Definition: winuser.h:1974

Referenced by DECLARE_INTERFACE_(), and WndProc().

◆ OnSize()

static LRESULT OnSize ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 2536 of file wordpad.c.

2537 {
2538  int nStatusSize = 0;
2539  RECT rc;
2541  HWND hwndStatusBar = GetDlgItem(hWnd, IDC_STATUSBAR);
2542  HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
2543  HWND hRulerWnd = GetDlgItem(hwndReBar, IDC_RULER);
2544  int rebarHeight = 0;
2545 
2546  if (hwndStatusBar)
2547  {
2548  SendMessageW(hwndStatusBar, WM_SIZE, 0, 0);
2549  if (IsWindowVisible(hwndStatusBar))
2550  {
2551  GetClientRect(hwndStatusBar, &rc);
2552  nStatusSize = rc.bottom - rc.top;
2553  } else
2554  {
2555  nStatusSize = 0;
2556  }
2557  }
2558  if (hwndReBar)
2559  {
2560  rebarHeight = SendMessageW(hwndReBar, RB_GETBARHEIGHT, 0, 0);
2561 
2562  MoveWindow(hwndReBar, 0, 0, LOWORD(lParam), rebarHeight, TRUE);
2563  }
2564  if (hwndEditor)
2565  {
2566  GetClientRect(hWnd, &rc);
2567  MoveWindow(hwndEditor, 0, rebarHeight, rc.right, rc.bottom-nStatusSize-rebarHeight, TRUE);
2568  }
2569 
2570  redraw_ruler(hRulerWnd);
2571 
2573 }
void redraw_ruler(HWND hRulerWnd)
Definition: print.c:288
#define TRUE
Definition: types.h:120
#define IDC_STATUSBAR
Definition: resource.h:12
#define RB_GETBARHEIGHT
Definition: commctrl.h:1604
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
LONG right
Definition: windef.h:308
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_RULER
Definition: wordpad.h:170
BOOL preview_isactive(void)
Definition: print.c:781
#define IDC_EDITOR
Definition: wordpad.h:156
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_SIZE
Definition: winuser.h:1593
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define IDC_PREVIEW
Definition: wordpad.h:171
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI IsWindowVisible(_In_ HWND)
LONG bottom
Definition: windef.h:309
#define IDC_REBAR
Definition: wordpad.h:159
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by update_window(), and WndProc().

◆ OnUser()

static LRESULT OnUser ( HWND  hWnd)
static

Definition at line 1952 of file wordpad.c.

1953 {
1954  HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
1955  HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
1956  HWND hwndToolBar = GetDlgItem(hwndReBar, IDC_TOOLBAR);
1957  HWND hwndFormatBar = GetDlgItem(hwndReBar, IDC_FORMATBAR);
1958  int from, to;
1959  CHARFORMAT2W fmt;
1960  PARAFORMAT2 pf;
1961  GETTEXTLENGTHEX gt;
1962 
1963  ZeroMemory(&fmt, sizeof(fmt));
1964  <