ReactOS 0.4.15-dev-8419-g7f0e8a3
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,
87} UNIT;
UNIT
Definition: wordpad.c:83
@ UNIT_PT
Definition: wordpad.c:86
@ UNIT_INCH
Definition: wordpad.c:85
@ UNIT_CM
Definition: wordpad.c:84

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}
int fontHeight
Definition: appswitch.c:47
#define MAX_STRING_LEN
Definition: precomp.h:36
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
GLuint buffer
Definition: glext.h:5915
GLenum const GLvoid * fontName
Definition: glext.h:11715
#define CBEM_GETITEMW
Definition: commctrl.h:3843
#define CBEIF_TEXT
Definition: commctrl.h:3786
#define CBEM_INSERTITEMW
Definition: commctrl.h:3841
#define CBEIF_LPARAM
Definition: commctrl.h:3791
NEWTEXTMETRICW ntmTm
Definition: wingdi.h:2675
LONG tmInternalLeading
Definition: wingdi.h:2647
#define MAKELONG(a, b)
Definition: typedefs.h:249
LONG_PTR LPARAM
Definition: windef.h:208
#define RASTER_FONTTYPE
Definition: wingdi.h:1107
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180

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}
static const WCHAR stringFormat[]
Definition: wordpad.c:55
GLsizeiptr size
Definition: glext.h:5919
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

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 BTNS_BUTTON
Definition: commctrl.h:998
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TB_ADDBUTTONSW
Definition: commctrl.h:1266
#define ZeroMemory
Definition: winbase.h:1712

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}
#define BTNS_SEP
Definition: commctrl.h:999

Referenced by NtLdrAddOptions(), and OnCreate().

◆ append_current_units()

static void append_current_units ( LPWSTR  buffer)
static

Definition at line 1385 of file wordpad.c.

1386{
1387 static const WCHAR space[] = {' ', 0};
1390}
static WCHAR units_cmW[MAX_STRING_LEN]
Definition: wordpad.c:75
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);
454 pf.wAlignment = PFA_LEFT;
456}
static HWND hEditorWnd
Definition: wordpad.c:61
#define PFA_LEFT
Definition: richedit.h:921
#define PFM_ALIGNMENT
Definition: richedit.h:841
#define EM_SETPARAFORMAT
Definition: richedit.h:104
WORD wAlignment
Definition: richedit.h:673
DWORD dwMask
Definition: richedit.h:667
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 1429 of file wordpad.c.

1430{
1431 switch(message)
1432 {
1433 case WM_INITDIALOG:
1434 {
1436 SYSTEMTIME st;
1437 HWND hListWnd = GetDlgItem(hWnd, IDC_DATETIME);
1438 GetLocalTime(&st);
1439
1442 SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1445 SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1447 SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1448
1449 SendMessageW(hListWnd, LB_SETSEL, TRUE, 0);
1450 }
1451 break;
1452
1453 case WM_COMMAND:
1454 switch(LOWORD(wParam))
1455 {
1456 case IDC_DATETIME:
1457 if (HIWORD(wParam) != LBN_DBLCLK)
1458 break;
1459 /* Fall through */
1460
1461 case IDOK:
1462 {
1463 LRESULT index;
1464 HWND hListWnd = GetDlgItem(hWnd, IDC_DATETIME);
1465
1466 index = SendMessageW(hListWnd, LB_GETCURSEL, 0, 0);
1467
1468 if(index != LB_ERR)
1469 {
1471 SendMessageW(hListWnd, LB_GETTEXT, index, (LPARAM)&buffer);
1473 }
1474 }
1475 /* Fall through */
1476
1477 case IDCANCEL:
1479 return TRUE;
1480 }
1481 }
1482 return FALSE;
1483}
HWND hWnd
Definition: settings.c:17
#define index(s, c)
Definition: various.h:29
WPARAM wParam
Definition: combotst.c:138
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
GLuint index
Definition: glext.h:6031
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1093
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:993
#define LOCALE_USER_DEFAULT
#define LOWORD(l)
Definition: pedump.c:82
Definition: tftpd.h:60
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LRESULT
Definition: windef.h:209
#define DATE_LONGDATE
Definition: winnls.h:197
#define DATE_SHORTDATE
Definition: winnls.h:196
#define LB_ERR
Definition: winuser.h:2432
#define IDCANCEL
Definition: winuser.h:831
#define LB_GETTEXT
Definition: winuser.h:2049
#define LBN_DBLCLK
Definition: winuser.h:2071
#define WM_COMMAND
Definition: winuser.h:1740
#define EM_REPLACESEL
Definition: winuser.h:2006
#define WM_INITDIALOG
Definition: winuser.h:1739
#define LB_ADDSTRING
Definition: winuser.h:2031
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define LB_SETSEL
Definition: winuser.h:2068
#define LB_GETCURSEL
Definition: winuser.h:2039
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define IDC_DATETIME
Definition: wordpad.h:161
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by OnCommand().

◆ dialog_about()

static void dialog_about ( void  )
static

Definition at line 1018 of file wordpad.c.

1019{
1022}
static HWND hMainWnd
Definition: wordpad.c:60
static const WCHAR wszAppTitle[]
Definition: wordpad.c:51
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static HICON
Definition: imagelist.c:84
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2247
#define LR_SHARED
Definition: winuser.h:1100
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDI_WORDPAD
Definition: wordpad.h:186

Referenced by OnCommand().

◆ dialog_choose_font()

static void dialog_choose_font ( void  )
static

Definition at line 566 of file wordpad.c.

567{
569 LOGFONTW lf;
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 HDC hDC
Definition: 3dtext.c:33
static void set_font(LPCWSTR wszFaceName)
Definition: wordpad.c:479
#define CF_EFFECTS
Definition: commdlg.h:68
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66
#define CF_NOVERTFONTS
Definition: commdlg.h:86
#define BOLD_FONTTYPE
Definition: commdlg.h:90
#define CF_NOSCRIPTSEL
Definition: commdlg.h:85
#define ITALIC_FONTTYPE
Definition: commdlg.h:91
#define CF_SCREENFONTS
Definition: commdlg.h:59
BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
Definition: fontdlg.c:184
static HDC
Definition: imagelist.c:92
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define CFM_STRIKEOUT
Definition: richedit.h:335
#define CFE_STRIKEOUT
Definition: richedit.h:409
#define CFE_BOLD
Definition: richedit.h:406
#define CFE_ITALIC
Definition: richedit.h:407
#define SCF_SELECTION
Definition: richedit.h:235
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define CFE_UNDERLINE
Definition: richedit.h:408
#define CFM_ITALIC
Definition: richedit.h:333
#define CFM_SIZE
Definition: richedit.h:362
#define CFM_BOLD
Definition: richedit.h:332
#define CFM_UNDERLINE
Definition: richedit.h:334
#define CFM_COLOR
Definition: richedit.h:361
Definition: dsound.c:943
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define FW_BOLD
Definition: wingdi.h:378
#define LOGPIXELSY
Definition: wingdi.h:719
#define FW_NORMAL
Definition: wingdi.h:373
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by OnCommand().

◆ dialog_find()

static void dialog_find ( LPFINDREPLACEW  fr,
BOOL  replace 
)
static

Definition at line 1314 of file wordpad.c.

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

Referenced by OnCommand().

◆ dialog_viewproperties()

static void dialog_viewproperties ( void  )
static

Definition at line 1122 of file wordpad.c.

1123{
1124 PROPSHEETPAGEW psp[2];
1125 PROPSHEETHEADERW psh;
1126 size_t i;
1129
1130 psp[0].dwSize = sizeof(PROPSHEETPAGEW);
1131 psp[0].dwFlags = PSP_USETITLE;
1132 U(psp[0]).pszTemplate = MAKEINTRESOURCEW(IDD_FORMATOPTS);
1133 psp[0].pfnDlgProc = formatopts_proc;
1134 psp[0].hInstance = hInstance;
1135 psp[0].lParam = reg_formatindex(SF_TEXT);
1136 psp[0].pfnCallback = NULL;
1138 for(i = 1; i < sizeof(psp)/sizeof(psp[0]); i++)
1139 {
1140 psp[i].dwSize = psp[0].dwSize;
1141 psp[i].dwFlags = psp[0].dwFlags;
1142 U(psp[i]).pszTemplate = U(psp[0]).pszTemplate;
1143 psp[i].pfnDlgProc = psp[0].pfnDlgProc;
1144 psp[i].hInstance = psp[0].hInstance;
1146 psp[i].pfnCallback = psp[0].pfnCallback;
1148 }
1149
1150 psh.dwSize = sizeof(psh);
1152 psh.hwndParent = hMainWnd;
1153 psh.hInstance = hInstance;
1155 psh.nPages = sizeof(psp)/sizeof(psp[0]);
1156 U3(psh).ppsp = ppsp;
1157 U(psh).pszIcon = MAKEINTRESOURCEW(IDI_WORDPAD);
1158
1159 if(fileFormat & SF_RTF)
1160 U2(psh).nStartPage = 1;
1161 else
1162 U2(psh).nStartPage = 0;
1163 PropertySheetW(&psh);
1166}
void target_device(HWND hMainWnd, DWORD wordWrap)
Definition: print.c:209
int reg_formatindex(WPARAM format)
Definition: registry.c:330
static void set_bar_states(void)
Definition: wordpad.c:711
#define U(x)
Definition: wordpad.c:45
#define U3(x)
Definition: wordpad.c:47
static DWORD wordWrap[2]
Definition: wordpad.c:67
#define U2(x)
Definition: wordpad.c:46
static WPARAM fileFormat
Definition: wordpad.c:69
static INT_PTR CALLBACK formatopts_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1024
HINSTANCE hInstance
Definition: charmap.c:19
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2913
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
#define PSP_USETITLE
Definition: prsht.h:26
struct _PROPSHEETPAGEW PROPSHEETPAGEW
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
#define PSH_USEICONID
Definition: prsht.h:42
const PROPSHEETPAGEW * LPCPROPSHEETPAGEW
Definition: prsht.h:245
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
#define SF_RTF
Definition: richedit.h:721
#define SF_TEXT
Definition: richedit.h:720
HINSTANCE hInstance
Definition: prsht.h:296
DWORD dwSize
Definition: prsht.h:293
DWORD dwFlags
Definition: prsht.h:294
HWND hwndParent
Definition: prsht.h:295
LPCWSTR pszCaption
Definition: prsht.h:301
DLGPROC pfnDlgProc
Definition: prsht.h:226
DWORD dwSize
Definition: prsht.h:214
DWORD dwFlags
Definition: prsht.h:215
LPARAM lParam
Definition: prsht.h:227
LPCWSTR pszTitle
Definition: prsht.h:225
HINSTANCE hInstance
Definition: prsht.h:216
#define IDD_FORMATOPTS
Definition: wordpad.h:177
#define STRING_VIEWPROPS_TITLE
Definition: wordpad.h:214
#define STRING_VIEWPROPS_RICHTEXT
Definition: wordpad.h:216
#define STRING_VIEWPROPS_TEXT
Definition: wordpad.h:215

Referenced by OnCommand().

◆ DialogOpenFile()

static void DialogOpenFile ( void  )
static

Definition at line 993 of file wordpad.c.

994{
996
997 WCHAR wszFile[MAX_PATH] = {'\0'};
998 static const WCHAR wszDefExt[] = {'r','t','f','\0'};
999
1000 ZeroMemory(&ofn, sizeof(ofn));
1001
1002 ofn.lStructSize = sizeof(ofn);
1008 ofn.lpstrDefExt = wszDefExt;
1010
1011 if(GetOpenFileNameW(&ofn))
1012 {
1015 }
1016}
static void DoOpenFile(LPCWSTR szOpenFileName)
Definition: wordpad.c:764
static int fileformat_number(WPARAM format)
Definition: wordpad.c:458
static BOOL prompt_save_changes(void)
Definition: wordpad.c:940
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
Definition: wordpad.c:72
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
OPENFILENAME ofn
Definition: sndrec32.cpp:56
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nFilterIndex
Definition: commdlg.h:335
HWND hwndOwner
Definition: commdlg.h:330
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
static const WCHAR wszFile[]
Definition: urlmon_main.c:386

Referenced by OnCommand().

◆ DialogSaveFile()

static BOOL DialogSaveFile ( void  )
static

Definition at line 909 of file wordpad.c.

910{
912
913 WCHAR wszFile[MAX_PATH] = {'\0'};
914 static const WCHAR wszDefExt[] = {'r','t','f','\0'};
915
916 ZeroMemory(&sfn, sizeof(sfn));
917
918 sfn.lStructSize = sizeof(sfn);
924 sfn.lpstrDefExt = wszDefExt;
926
927 while(GetSaveFileNameW(&sfn))
928 {
930 {
933 continue;
934 }
936 }
937 return FALSE;
938}
static BOOL DoSaveFile(LPCWSTR wszSaveFileName, WPARAM format)
Definition: wordpad.c:840
static WPARAM fileformat_flags(int format)
Definition: wordpad.c:472
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:137
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4801
OPENFILENAMEW sfn
Definition: eventvwr.c:101
HWND hwndOwner
Definition: commdlg.h:361
DWORD Flags
Definition: commdlg.h:373
LPWSTR lpstrFile
Definition: commdlg.h:367
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
DWORD lStructSize
Definition: commdlg.h:360
DWORD nMaxFile
Definition: commdlg.h:368
LPCWSTR lpstrFilter
Definition: commdlg.h:363
DWORD nFilterIndex
Definition: commdlg.h:366
#define MB_YESNO
Definition: winuser.h:817
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define IDYES
Definition: winuser.h:835
#define STRING_SAVE_LOSEFORMATTING
Definition: wordpad.h:238

Referenced by OnCommand(), and prompt_save_changes().

◆ DoLoadStrings()

static void DoLoadStrings ( void  )
static

Definition at line 97 of file wordpad.c.

98{
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
129
134}
static WCHAR wszDefaultFileName[MAX_STRING_LEN]
Definition: wordpad.c:73
static WCHAR units_ptW[MAX_STRING_LEN]
Definition: wordpad.c:78
static WCHAR units_inchW[MAX_STRING_LEN]
Definition: wordpad.c:77
static WCHAR wszSaveChanges[MAX_STRING_LEN]
Definition: wordpad.c:74
static WCHAR units_inW[MAX_STRING_LEN]
Definition: wordpad.c:76
GLfloat GLfloat p
Definition: glext.h:8902
#define STRING_ALL_FILES
Definition: notepad_res.h:68
#define STRING_TEXT_FILES_TXT
Definition: notepad_res.h:69
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define STRING_UNITS_IN
Definition: wordpad.h:230
#define STRING_UNITS_PT
Definition: wordpad.h:232
#define STRING_DEFAULT_FILENAME
Definition: wordpad.h:234
#define STRING_UNITS_CM
Definition: wordpad.h:229
#define STRING_RICHTEXT_FILES_RTF
Definition: wordpad.h:202
#define STRING_UNITS_INCH
Definition: wordpad.h:231
#define STRING_PROMPT_SAVE_CHANGES
Definition: wordpad.h:235
#define STRING_TEXT_FILES_UNICODE_TXT
Definition: wordpad.h:201

Referenced by OnCreate().

◆ DoOpenFile()

static void DoOpenFile ( LPCWSTR  szOpenFileName)
static

Definition at line 764 of file wordpad.c.

765{
768 char fileStart[5];
769 DWORD readOut;
771
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}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
void registry_set_filelist(LPCWSTR newFile, HWND hMainWnd)
Definition: registry.c:269
static void clear_formatting(void)
Definition: wordpad.c:448
static void ShowOpenError(DWORD Code)
Definition: wordpad.c:748
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:71
static void set_fileformat(WPARAM format)
Definition: wordpad.c:739
static void update_font_list(void)
Definition: wordpad.c:424
static DWORD CALLBACK stream_in(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
Definition: wordpad.c:183
static void set_caption(LPCWSTR wszNewFileName)
Definition: wordpad.c:228
#define CloseHandle
Definition: compat.h:739
#define FILE_BEGIN
Definition: compat.h:761
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetFilePointer
Definition: compat.h:743
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define es
Definition: i386-dis.c:440
_In_ HANDLE hFile
Definition: mswsock.h:90
#define EM_STREAMIN
Definition: richedit.h:106
#define SF_UNICODE
Definition: richedit.h:724
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:1005
#define SHARD_PATHW
Definition: shlobj.h:1176
#define DWORD_PTR
Definition: treelist.c:76
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MB_OK
Definition: winuser.h:790
#define EM_SETMODIFY
Definition: winuser.h:2013
#define STRING_OLE_STORAGE_NOT_SUPPORTED
Definition: wordpad.h:240
unsigned char BYTE
Definition: xxhash.c:193

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{
844 LRESULT ret;
845
846#ifdef __REACTOS__
847 /* Use OPEN_ALWAYS instead of CREATE_ALWAYS in order to succeed
848 * even if the file has HIDDEN or SYSTEM attributes */
851#else
852 hFile = CreateFileW(wszSaveFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
854#endif
855
857 {
859 return FALSE;
860 }
861
862 if(format == (SF_TEXT | SF_UNICODE))
863 {
864 static const BYTE unicode[] = {0xff,0xfe};
865 DWORD writeOut;
866 WriteFile(hFile, &unicode, sizeof(unicode), &writeOut, 0);
867
868 if(writeOut != sizeof(unicode))
869 {
871 return FALSE;
872 }
873 }
874
875 stream.dwCookie = (DWORD_PTR)hFile;
876 stream.pfnCallback = stream_out;
877
879
880#ifdef __REACTOS__
881 /* Truncate the file and close it */
883#endif
885
887
888 if(!ret)
889 {
891 gt.flags = GTL_DEFAULT;
892 gt.codepage = 1200;
893
895 return FALSE;
896 }
897
898 lstrcpyW(wszFileName, wszSaveFileName);
900 if (wszFileName[0])
902
905
906 return TRUE;
907}
static void ShowWriteError(DWORD Code)
Definition: wordpad.c:824
static DWORD CALLBACK stream_out(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
Definition: wordpad.c:196
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
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 CREATE_ALWAYS
Definition: disk.h:72
#define OPEN_ALWAYS
Definition: disk.h:70
#define GENERIC_WRITE
Definition: nt_native.h:90
#define GTL_DEFAULT
Definition: richedit.h:1054
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
#define EM_STREAMOUT
Definition: richedit.h:107
Definition: parse.h:23
int ret

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}
static void add_font(LPCWSTR fontName, DWORD fontType, HWND hListWnd, const NEWTEXTMETRICEXW *ntmc)
Definition: wordpad.c:536
LPARAM lParam
Definition: combotst.c:139
HANDLE HWND
Definition: compat.h:19
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define CB_ERR
Definition: winuser.h:2435
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1940

Referenced by populate_font_list().

◆ file_basename()

LPWSTR file_basename ( LPWSTR  path)

Definition at line 212 of file wordpad.c.

213{
215
216 while(pos > path)
217 {
218 if(*pos == '\\' || *pos == '/')
219 {
220 pos++;
221 break;
222 }
223 pos--;
224 }
225 return pos;
226}

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}
GLbitfield flags
Definition: glext.h:7161

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}
static unsigned int number
Definition: dsound.c:1479

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 1024 of file wordpad.c.

1025{
1026 switch(message)
1027 {
1028 case WM_INITDIALOG:
1029 {
1031 int wrap = -1;
1032 char id[4];
1034
1035 sprintf(id, "%d\n", (int)ps->lParam);
1036 SetWindowTextA(hIdWnd, id);
1037 if(wordWrap[ps->lParam] == ID_WORDWRAP_NONE)
1039 else if(wordWrap[ps->lParam] == ID_WORDWRAP_WINDOW)
1041 else if(wordWrap[ps->lParam] == ID_WORDWRAP_MARGIN)
1043
1044 if(wrap != -1)
1047
1048 if(barState[ps->lParam] & (1 << BANDID_TOOLBAR))
1050 if(barState[ps->lParam] & (1 << BANDID_FORMATBAR))
1052 if(barState[ps->lParam] & (1 << BANDID_RULER))
1054 if(barState[ps->lParam] & (1 << BANDID_STATUSBAR))
1056 }
1057 break;
1058
1059 case WM_COMMAND:
1060 switch(LOWORD(wParam))
1061 {
1062 case IDC_PAGEFMT_WN:
1063 case IDC_PAGEFMT_WW:
1064 case IDC_PAGEFMT_WM:
1066 LOWORD(wParam));
1067 break;
1068
1069 case IDC_PAGEFMT_TB:
1070 case IDC_PAGEFMT_FB:
1071 case IDC_PAGEFMT_RU:
1072 case IDC_PAGEFMT_SB:
1075 break;
1076 }
1077 break;
1078 case WM_NOTIFY:
1079 {
1081 if(header->code == PSN_APPLY)
1082 {
1084 char sid[4];
1085 int id;
1086
1087 GetWindowTextA(hIdWnd, sid, 4);
1088 id = atoi(sid);
1095
1097 barState[id] |= (1 << BANDID_TOOLBAR);
1098 else
1099 barState[id] &= ~(1 << BANDID_TOOLBAR);
1100
1102 barState[id] |= (1 << BANDID_FORMATBAR);
1103 else
1104 barState[id] &= ~(1 << BANDID_FORMATBAR);
1105
1107 barState[id] |= (1 << BANDID_RULER);
1108 else
1109 barState[id] &= ~(1 << BANDID_RULER);
1110
1112 barState[id] |= (1 << BANDID_STATUSBAR);
1113 else
1114 barState[id] &= ~(1 << BANDID_STATUSBAR);
1115 }
1116 }
1117 break;
1118 }
1119 return FALSE;
1120}
static DWORD barState[2]
Definition: wordpad.c:68
FT_UInt sid
Definition: cffcmap.c:139
#define wrap(journal, var)
Definition: recovery.c:207
GLuint id
Definition: glext.h:5910
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define PSN_APPLY
Definition: prsht.h:117
struct _PROPSHEETPAGEW * LPPROPSHEETPAGEW
#define WM_NOTIFY
Definition: richedit.h:61
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1302
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
struct tagNMHDR * LPNMHDR
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define ID_WORDWRAP_NONE
Definition: wordpad.h:110
#define BANDID_FORMATBAR
Definition: wordpad.h:95
#define BANDID_STATUSBAR
Definition: wordpad.h:97
#define IDC_PAGEFMT_RU
Definition: wordpad.h:122
#define BANDID_TOOLBAR
Definition: wordpad.h:94
#define IDC_PAGEFMT_SB
Definition: wordpad.h:123
#define IDC_PAGEFMT_WM
Definition: wordpad.h:126
#define IDC_PAGEFMT_ID
Definition: wordpad.h:127
#define IDC_PAGEFMT_FB
Definition: wordpad.h:121
#define IDC_PAGEFMT_TB
Definition: wordpad.h:120
#define ID_WORDWRAP_MARGIN
Definition: wordpad.h:112
#define IDC_PAGEFMT_WW
Definition: wordpad.h:125
#define ID_WORDWRAP_WINDOW
Definition: wordpad.h:111
#define IDC_PAGEFMT_WN
Definition: wordpad.h:124
#define BANDID_RULER
Definition: wordpad.h:96

Referenced by dialog_viewproperties().

◆ get_comboexlist_selection()

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

Definition at line 1400 of file wordpad.c.

1401{
1402 COMBOBOXEXITEMW cbItem;
1403 COMBOBOXINFO cbInfo;
1404 HWND hCombo, hList;
1405 int idx, result;
1406
1407 hCombo = (HWND)SendMessageW(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
1408 if (!hCombo)
1409 return FALSE;
1410 cbInfo.cbSize = sizeof(COMBOBOXINFO);
1411 result = SendMessageW(hCombo, CB_GETCOMBOBOXINFO, 0, (LPARAM)&cbInfo);
1412 if (!result)
1413 return FALSE;
1414 hList = cbInfo.hwndList;
1416 if (idx < 0)
1417 return FALSE;
1418
1419 ZeroMemory(&cbItem, sizeof(cbItem));
1420 cbItem.mask = CBEIF_TEXT;
1421 cbItem.iItem = idx;
1422 cbItem.pszText = wszBuffer;
1423 cbItem.cchTextMax = bufferLength-1;
1424 result = SendMessageW(hComboEx, CBEM_GETITEMW, 0, (LPARAM)&cbItem);
1425
1426 return result != 0;
1427}
unsigned int idx
Definition: utils.c:41
GLuint64EXT * result
Definition: glext.h:11304
HWND hList
Definition: livecd.c:10
#define CBEM_GETCOMBOCONTROL
Definition: commctrl.h:3832
_In_opt_ PVOID _In_ ULONG bufferLength
Definition: wdfdriver.h:109
#define CB_GETCOMBOBOXINFO
Definition: winuser.h:1941
struct tagCOMBOBOXINFO COMBOBOXINFO

Referenced by OnCommand().

◆ handle_findmsg()

static LRESULT handle_findmsg ( LPFINDREPLACEW  pFr)
static

Definition at line 1221 of file wordpad.c.

1222{
1223 if(pFr->Flags & FR_DIALOGTERM)
1224 {
1225 hFindWnd = 0;
1226 pFr->Flags = FR_FINDNEXT;
1227 return 0;
1228 }
1229
1230 if(pFr->Flags & FR_FINDNEXT || pFr->Flags & FR_REPLACE || pFr->Flags & FR_REPLACEALL)
1231 {
1232 FINDREPLACE_custom *custom_data = (FINDREPLACE_custom*)pFr->lCustData;
1233 DWORD flags;
1234 FINDTEXTEXW ft;
1235 CHARRANGE sel;
1236 LRESULT ret = -1;
1237 HMENU hMenu = GetMenu(hMainWnd);
1239
1240 mi.cbSize = sizeof(mi);
1241 mi.fMask = MIIM_DATA;
1242 mi.dwItemData = 1;
1244
1245 /* Make sure find field is saved. */
1246 if (pFr->lpstrFindWhat != custom_data->findBuffer)
1247 {
1248 lstrcpynW(custom_data->findBuffer, pFr->lpstrFindWhat,
1249 sizeof(custom_data->findBuffer) / sizeof(WCHAR));
1250 pFr->lpstrFindWhat = custom_data->findBuffer;
1251 }
1252
1253 SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&sel.cpMin, (LPARAM)&sel.cpMax);
1254 if(custom_data->endPos == -1) {
1255 custom_data->endPos = sel.cpMin;
1256 custom_data->wrapped = FALSE;
1257 }
1258
1259 flags = FR_DOWN | (pFr->Flags & (FR_MATCHCASE | FR_WHOLEWORD));
1260 ft.lpstrText = pFr->lpstrFindWhat;
1261
1262 /* Only replace the existing selection if it is an exact match. */
1263 if (sel.cpMin != sel.cpMax &&
1264 (pFr->Flags & FR_REPLACE || pFr->Flags & FR_REPLACEALL))
1265 {
1266 ft.chrg = sel;
1268 if (ft.chrgText.cpMin == sel.cpMin && ft.chrgText.cpMax == sel.cpMax) {
1270 SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&sel.cpMin, (LPARAM)&sel.cpMax);
1271 }
1272 }
1273
1274 /* Search from the start of the selection, but exclude the first character
1275 * from search if there is a selection. */
1276 ft.chrg.cpMin = sel.cpMin;
1277 if (sel.cpMin != sel.cpMax)
1278 ft.chrg.cpMin++;
1279
1280 /* Search to the end, then wrap around and search from the start. */
1281 if (!custom_data->wrapped) {
1282 ft.chrg.cpMax = -1;
1284 if (ret == -1) {
1285 custom_data->wrapped = TRUE;
1286 ft.chrg.cpMin = 0;
1287 }
1288 }
1289
1290 if (ret == -1) {
1291 ft.chrg.cpMax = custom_data->endPos + lstrlenW(pFr->lpstrFindWhat) - 1;
1292 if (ft.chrg.cpMax > ft.chrg.cpMin)
1294 }
1295
1296 if (ret == -1) {
1297 custom_data->endPos = -1;
1302 } else {
1303 SendMessageW(hEditorWnd, EM_SETSEL, ft.chrgText.cpMin, ft.chrgText.cpMax);
1305
1306 if (pFr->Flags & FR_REPLACEALL)
1307 return handle_findmsg(pFr);
1308 }
1309 }
1310
1311 return 0;
1312}
static LRESULT handle_findmsg(LPFINDREPLACEW pFr)
Definition: wordpad.c:1221
#define FR_WHOLEWORD
Definition: commdlg.h:145
#define FR_REPLACE
Definition: commdlg.h:142
#define FR_DIALOGTERM
Definition: commdlg.h:126
#define FR_REPLACEALL
Definition: commdlg.h:143
#define FR_MATCHCASE
Definition: commdlg.h:136
#define FR_FINDNEXT
Definition: commdlg.h:131
#define lstrcpynW
Definition: compat.h:738
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define EM_SCROLLCARET
Definition: richedit.h:81
#define EM_FINDTEXTEXW
Definition: richedit.h:148
DWORD cbSize
Definition: winuser.h:3784
static MONITORINFO mi
Definition: win.c:7338
#define MB_TASKMODAL
Definition: winuser.h:816
BOOL WINAPI SetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define EM_SETSEL
Definition: winuser.h:2018
#define MB_ICONASTERISK
Definition: winuser.h:784
#define MIIM_DATA
Definition: winuser.h:726
HMENU WINAPI GetMenu(_In_ HWND)
#define ID_FIND_NEXT
Definition: wordpad.h:45
#define STRING_SEARCH_FINISHED
Definition: wordpad.h:236

Referenced by handle_findmsg(), OnCommand(), and WndProc().

◆ HandleCommandLine()

static void HandleCommandLine ( LPWSTR  cmdline)
static

Definition at line 1168 of file wordpad.c.

1169{
1171 BOOL opt_print = FALSE;
1172
1173 /* skip white space */
1174 while (*cmdline == ' ') cmdline++;
1175
1176 /* skip executable name */
1177 delimiter = (*cmdline == '"' ? '"' : ' ');
1178
1179 if (*cmdline == delimiter) cmdline++;
1180 while (*cmdline && *cmdline != delimiter) cmdline++;
1181 if (*cmdline == delimiter) cmdline++;
1182
1183 while (*cmdline)
1184 {
1185 while (isspace(*cmdline)) cmdline++;
1186
1187 if (*cmdline == '-' || *cmdline == '/')
1188 {
1189 if (!cmdline[2] || isspace(cmdline[2]))
1190 {
1191 switch (cmdline[1])
1192 {
1193 case 'P':
1194 case 'p':
1195 opt_print = TRUE;
1196 cmdline += 2;
1197 continue;
1198 }
1199 }
1200 /* a filename starting by / */
1201 }
1202 break;
1203 }
1204
1205 if (*cmdline)
1206 {
1207 /* file name is passed on the command line */
1208 if (cmdline[0] == '"')
1209 {
1210 cmdline++;
1211 cmdline[lstrlenW(cmdline) - 1] = 0;
1212 }
1215 }
1216
1217 if (opt_print)
1219}
#define isspace(c)
Definition: acclib.h:69
unsigned int BOOL
Definition: ntddk_ex.h:94
const char * delimiter
Definition: string.c:1566
TCHAR * cmdline
Definition: stretchblt.cpp:32
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define STRING_PRINTING_NOT_IMPLEMENTED
Definition: wordpad.h:245

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}

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;
152}
GLenum const GLfloat * params
Definition: glext.h:5645
int WINAPI MessageBoxIndirectW(_In_ CONST MSGBOXPARAMSW *lpmbp)

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 1485 of file wordpad.c.

1486{
1487 switch(message)
1488 {
1489 case WM_INITDIALOG:
1490 {
1493 HWND hListWnd = GetDlgItem(hWnd, IDC_NEWFILE);
1494
1496 SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1498 SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1500 SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1501
1502 SendMessageW(hListWnd, LB_SETSEL, TRUE, 0);
1503 }
1504 break;
1505
1506 case WM_COMMAND:
1507 switch(LOWORD(wParam))
1508 {
1509 case IDOK:
1510 {
1511 LRESULT index;
1512 HWND hListWnd = GetDlgItem(hWnd, IDC_NEWFILE);
1513 index = SendMessageW(hListWnd, LB_GETCURSEL, 0, 0);
1514
1515 if(index != LB_ERR)
1517 }
1518 return TRUE;
1519
1520 case IDCANCEL:
1522 return TRUE;
1523 }
1524 }
1525 return FALSE;
1526}
#define STRING_NEWFILE_TXT_UNICODE
Definition: wordpad.h:206
#define STRING_NEWFILE_RICHTEXT
Definition: wordpad.h:204
#define IDC_NEWFILE
Definition: wordpad.h:162
#define STRING_NEWFILE_TXT
Definition: wordpad.h:205
#define ID_NEWFILE_ABORT
Definition: wordpad.h:114

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}
static BOOL validate_endptr(LPCWSTR endptr, UNIT *punit)
Definition: wordpad.c:256
GLuint GLuint num
Definition: glext.h:9618
_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
#define errno
Definition: errno.h:18

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 1392 of file wordpad.c.

1393{
1394 static const WCHAR fmt[] = {'%','.','2','f',' ','%','s','\0'};
1395 float converted = (float)number / (float)TWIPS_PER_INCH *(float)CENTMM_PER_INCH / 1000.0;
1396
1397 sprintfW(buffer, fmt, converted, units_cmW);
1398}
#define sprintfW
Definition: unicode.h:64
#define TWIPS_PER_INCH
Definition: wordpad.h:24
#define CENTMM_PER_INCH
Definition: wordpad.h:25

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 str1, LPCWSTR str2)
Definition: locale.c:4242

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}
static BOOL number_from_string(LPCWSTR string, float *num, UNIT *punit)
Definition: wordpad.c:295
static void set_size(float size)
Definition: wordpad.c:316
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define MB_ICONINFORMATION
Definition: winuser.h:802
#define STRING_INVALID_NUMBER
Definition: wordpad.h:239

Referenced by OnCommand(), and OnNotify().

◆ OnCommand()

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

Definition at line 2068 of file wordpad.c.

2069{
2070 HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
2071 static FINDREPLACEW findreplace;
2072
2073 if ((HWND)lParam == hwndEditor)
2074 return 0;
2075
2076 switch(LOWORD(wParam))
2077 {
2078
2079 case ID_FILE_EXIT:
2080 PostMessageW(hWnd, WM_CLOSE, 0, 0);
2081 break;
2082
2083 case ID_FILE_NEW:
2084 {
2087
2088 if(ret != ID_NEWFILE_ABORT)
2089 {
2091 {
2092 SETTEXTEX st;
2093
2095 wszFileName[0] = '\0';
2096
2098
2099 st.flags = ST_DEFAULT;
2100 st.codepage = 1200;
2102
2106 }
2107 }
2108 }
2109 break;
2110
2111 case ID_FILE_OPEN:
2113 break;
2114
2115 case ID_FILE_SAVE:
2116 if(wszFileName[0])
2117 {
2119 break;
2120 }
2121 /* Fall through */
2122
2123 case ID_FILE_SAVEAS:
2125 break;
2126
2127 case ID_FILE_RECENT1:
2128 case ID_FILE_RECENT2:
2129 case ID_FILE_RECENT3:
2130 case ID_FILE_RECENT4:
2131 {
2132 HMENU hMenu = GetMenu(hWnd);
2134
2135 mi.cbSize = sizeof(MENUITEMINFOW);
2136 mi.fMask = MIIM_DATA;
2137 if(GetMenuItemInfoW(hMenu, LOWORD(wParam), FALSE, &mi))
2138 DoOpenFile((LPWSTR)mi.dwItemData);
2139 }
2140 break;
2141
2142 case ID_FIND:
2143 dialog_find(&findreplace, FALSE);
2144 break;
2145
2146 case ID_FIND_NEXT:
2147 handle_findmsg(&findreplace);
2148 break;
2149
2150 case ID_REPLACE:
2151 dialog_find(&findreplace, TRUE);
2152 break;
2153
2154 case ID_FONTSETTINGS:
2156 break;
2157
2158 case ID_PRINT:
2161 break;
2162
2163 case ID_PRINT_QUICK:
2166 break;
2167
2168 case ID_PREVIEW:
2169 {
2171 DWORD tmp = barState[index];
2174 barState[index] = tmp;
2176
2178
2179 SetMenu(hWnd, NULL);
2180 InvalidateRect(0, 0, TRUE);
2181 }
2182 break;
2183
2184 case ID_PRINTSETUP:
2187 break;
2188
2189 case ID_FORMAT_BOLD:
2190 case ID_FORMAT_ITALIC:
2192 {
2194 int effects = CFE_BOLD;
2195
2196 ZeroMemory(&fmt, sizeof(fmt));
2197 fmt.cbSize = sizeof(fmt);
2199
2200 fmt.dwMask = CFM_BOLD;
2201
2203 {
2204 effects = CFE_ITALIC;
2205 fmt.dwMask = CFM_ITALIC;
2206 } else if (LOWORD(wParam) == ID_FORMAT_UNDERLINE)
2207 {
2208 effects = CFE_UNDERLINE;
2209 fmt.dwMask = CFM_UNDERLINE;
2210 }
2211
2212 fmt.dwEffects ^= effects;
2213
2215 break;
2216 }
2217
2218 case ID_FORMAT_COLOR:
2219 {
2220 HWND hReBarWnd = GetDlgItem(hWnd, IDC_REBAR);
2221 HWND hFormatBarWnd = GetDlgItem(hReBarWnd, IDC_FORMATBAR);
2222 HMENU hPop;
2223 RECT itemrc;
2224 POINT pt;
2225 int mid;
2226 int itemidx = SendMessageW(hFormatBarWnd, TB_COMMANDTOINDEX, ID_FORMAT_COLOR, 0);
2227
2228 SendMessageW(hFormatBarWnd, TB_GETITEMRECT, itemidx, (LPARAM)&itemrc);
2229 pt.x = itemrc.left;
2230 pt.y = itemrc.bottom;
2231 ClientToScreen(hFormatBarWnd, &pt);
2232 hPop = GetSubMenu(hColorPopupMenu, 0);
2235 pt.x, pt.y, 0, hWnd, 0);
2236 if (mid >= ID_COLOR_FIRST && mid <= ID_COLOR_AUTOMATIC)
2237 {
2239
2240 ZeroMemory(&fmt, sizeof(fmt));
2241 fmt.cbSize = sizeof(fmt);
2243
2244 fmt.dwMask = CFM_COLOR;
2245
2246 if (mid < ID_COLOR_AUTOMATIC) {
2247 fmt.crTextColor = textcolors[mid - ID_COLOR_FIRST];
2248 fmt.dwEffects &= ~CFE_AUTOCOLOR;
2249 } else {
2250 fmt.dwEffects |= CFE_AUTOCOLOR;
2251 }
2252
2254 }
2255 break;
2256 }
2257
2258 case ID_EDIT_CUT:
2259 PostMessageW(hwndEditor, WM_CUT, 0, 0);
2260 break;
2261
2262 case ID_EDIT_COPY:
2263 PostMessageW(hwndEditor, WM_COPY, 0, 0);
2264 break;
2265
2266 case ID_EDIT_PASTE:
2267 PostMessageW(hwndEditor, WM_PASTE, 0, 0);
2268 break;
2269
2270 case ID_EDIT_CLEAR:
2271 PostMessageW(hwndEditor, WM_CLEAR, 0, 0);
2272 break;
2273
2274 case ID_EDIT_SELECTALL:
2275 {
2276 CHARRANGE range = {0, -1};
2277 SendMessageW(hwndEditor, EM_EXSETSEL, 0, (LPARAM)&range);
2278 /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
2279 return 0;
2280 }
2281
2282 case ID_EDIT_GETTEXT:
2283 {
2284 int nLen = GetWindowTextLengthW(hwndEditor);
2285 LPWSTR data = HeapAlloc( GetProcessHeap(), 0, (nLen+1)*sizeof(WCHAR) );
2286 TEXTRANGEW tr;
2287
2288 GetWindowTextW(hwndEditor, data, nLen+1);
2290
2292 data = HeapAlloc(GetProcessHeap(), 0, (nLen+1)*sizeof(WCHAR));
2293 tr.chrg.cpMin = 0;
2294 tr.chrg.cpMax = nLen;
2295 tr.lpstrText = data;
2296 SendMessageW(hwndEditor, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
2298 HeapFree( GetProcessHeap(), 0, data );
2299
2300 /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
2301 return 0;
2302 }
2303
2304 case ID_EDIT_CHARFORMAT:
2306 {
2308
2309 ZeroMemory(&cf, sizeof(cf));
2310 cf.cbSize = sizeof(cf);
2311 cf.dwMask = 0;
2312 SendMessageW(hwndEditor, EM_GETCHARFORMAT,
2314 return 0;
2315 }
2316
2317 case ID_EDIT_PARAFORMAT:
2318 {
2319 PARAFORMAT2 pf;
2320 ZeroMemory(&pf, sizeof(pf));
2321 pf.cbSize = sizeof(pf);
2322 SendMessageW(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
2323 return 0;
2324 }
2325
2327 {
2328 CHARRANGE range = {0, -1};
2329 char buf[128];
2330 WCHAR *data = NULL;
2331
2332 SendMessageW(hwndEditor, EM_EXGETSEL, 0, (LPARAM)&range);
2333 data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data) * (range.cpMax-range.cpMin+1));
2334 SendMessageW(hwndEditor, EM_GETSELTEXT, 0, (LPARAM)data);
2335 sprintf(buf, "Start = %d, End = %d", range.cpMin, range.cpMax);
2336 MessageBoxA(hWnd, buf, "Editor", MB_OK);
2339 /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
2340 return 0;
2341 }
2342
2343 case ID_EDIT_READONLY:
2344 {
2345 LONG nStyle = GetWindowLongW(hwndEditor, GWL_STYLE);
2346 if (nStyle & ES_READONLY)
2347 SendMessageW(hwndEditor, EM_SETREADONLY, 0, 0);
2348 else
2349 SendMessageW(hwndEditor, EM_SETREADONLY, 1, 0);
2350 return 0;
2351 }
2352
2353 case ID_EDIT_MODIFIED:
2354 if (SendMessageW(hwndEditor, EM_GETMODIFY, 0, 0))
2355 SendMessageW(hwndEditor, EM_SETMODIFY, 0, 0);
2356 else
2357 SendMessageW(hwndEditor, EM_SETMODIFY, 1, 0);
2358 return 0;
2359
2360 case ID_EDIT_UNDO:
2361 SendMessageW(hwndEditor, EM_UNDO, 0, 0);
2362 return 0;
2363
2364 case ID_EDIT_REDO:
2365 SendMessageW(hwndEditor, EM_REDO, 0, 0);
2366 return 0;
2367
2368 case ID_BULLET:
2369 {
2370 PARAFORMAT pf;
2371
2372 pf.cbSize = sizeof(pf);
2373 pf.dwMask = PFM_NUMBERING;
2374 SendMessageW(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
2375
2376 pf.dwMask |= PFM_OFFSET;
2377
2378 if(pf.wNumbering == PFN_BULLET)
2379 {
2380 pf.wNumbering = 0;
2381 pf.dxOffset = 0;
2382 } else
2383 {
2385 pf.dxOffset = 720;
2386 }
2387
2388 SendMessageW(hwndEditor, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
2389 }
2390 break;
2391
2392 case ID_ALIGN_LEFT:
2393 case ID_ALIGN_CENTER:
2394 case ID_ALIGN_RIGHT:
2395 {
2396 PARAFORMAT2 pf;
2397
2398 pf.cbSize = sizeof(pf);
2399 pf.dwMask = PFM_ALIGNMENT;
2400 switch(LOWORD(wParam)) {
2401 case ID_ALIGN_LEFT: pf.wAlignment = PFA_LEFT; break;
2402 case ID_ALIGN_CENTER: pf.wAlignment = PFA_CENTER; break;
2403 case ID_ALIGN_RIGHT: pf.wAlignment = PFA_RIGHT; break;
2404 }
2405 SendMessageW(hwndEditor, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
2406 break;
2407 }
2408
2409 case ID_BACK_1:
2410 SendMessageW(hwndEditor, EM_SETBKGNDCOLOR, 1, 0);
2411 break;
2412
2413 case ID_BACK_2:
2414 SendMessageW(hwndEditor, EM_SETBKGNDCOLOR, 0, RGB(255,255,192));
2415 break;
2416
2417 case ID_TOGGLE_TOOLBAR:
2419 update_window();
2420 break;
2421
2426 update_window();
2427 break;
2428
2431 update_window();
2432 break;
2433
2434 case ID_TOGGLE_RULER:
2436 update_window();
2437 break;
2438
2439 case ID_DATETIME:
2441 break;
2442
2443 case ID_PARAFORMAT:
2445 break;
2446
2447 case ID_TABSTOPS:
2449 break;
2450
2451 case ID_ABOUT:
2452 dialog_about();
2453 break;
2454
2455 case ID_VIEWPROPERTIES:
2457 break;
2458
2459 case IDC_FONTLIST:
2460 if (HIWORD(wParam) == CBN_SELENDOK)
2461 {
2463 HWND hwndFontList = (HWND)lParam;
2466 }
2467 break;
2468
2469 case IDC_SIZELIST:
2470 if (HIWORD(wParam) == CBN_SELENDOK)
2471 {
2473 HWND hwndSizeList = (HWND)lParam;
2475 on_sizelist_modified(hwndSizeList, buffer);
2476 }
2477 break;
2478
2479 default:
2480 SendMessageW(hwndEditor, WM_COMMAND, wParam, lParam);
2481 break;
2482 }
2483 return 0;
2484}
#define ID_EDIT_COPY
Definition: resource.h:48
#define ID_FILE_EXIT
Definition: resource.h:46
#define ID_EDIT_PASTE
Definition: resource.h:49
#define ID_FILE_OPEN
Definition: resource.h:41
#define ID_FILE_SAVEAS
Definition: resource.h:43
#define ID_FILE_NEW
Definition: resource.h:40
#define ID_FILE_SAVE
Definition: resource.h:42
void print_quick(HWND hMainWnd, LPWSTR wszFileName)
Definition: print.c:537
void dialog_printsetup(HWND hMainWnd)
Definition: print.c:498
void init_preview(HWND hMainWnd, LPWSTR wszFileName)
Definition: print.c:735
void dialog_print(HWND hMainWnd, LPWSTR wszFileName)
Definition: print.c:549
static void dialog_about(void)
Definition: wordpad.c:1018
static BOOL is_bar_visible(int bandId)
Definition: wordpad.c:660
static void set_toolbar_state(int bandId, BOOL show)
Definition: wordpad.c:675
static void dialog_choose_font(void)
Definition: wordpad.c:566
static HMENU hColorPopupMenu
Definition: wordpad.c:63
static void set_statusbar_state(BOOL show)
Definition: wordpad.c:703
static INT_PTR CALLBACK newfile_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1485
static void update_window(void)
Definition: wordpad.c:651
static INT_PTR CALLBACK tabstops_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1653
static BOOL get_comboexlist_selection(HWND hComboEx, LPWSTR wszBuffer, UINT bufferLength)
Definition: wordpad.c:1400
static INT_PTR CALLBACK datetime_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1429
static void dialog_viewproperties(void)
Definition: wordpad.c:1122
static void on_sizelist_modified(HWND hwndSizeList, LPWSTR wszNewFontSize)
Definition: wordpad.c:327
static INT_PTR CALLBACK paraformat_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1528
static void dialog_find(LPFINDREPLACEW fr, BOOL replace)
Definition: wordpad.c:1314
static void DialogOpenFile(void)
Definition: wordpad.c:993
static void on_fontlist_modified(LPWSTR wszNewFaceName)
Definition: wordpad.c:525
static const COLORREF textcolors[]
Definition: wordpad.c:2060
static BOOL DialogSaveFile(void)
Definition: wordpad.c:909
#define ID_ABOUT
Definition: charmap.c:17
#define LF_FACESIZE
Definition: dimm.idl:39
#define pt(x, y)
Definition: drawing.c:79
#define RGB(r, g, b)
Definition: precomp.h:71
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLint * range
Definition: glext.h:7539
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ES_READONLY
Definition: pedump.c:675
long LONG
Definition: pedump.c:60
#define TB_GETITEMRECT
Definition: commctrl.h:1133
#define TB_COMMANDTOINDEX
Definition: commctrl.h:1111
#define PFA_RIGHT
Definition: richedit.h:922
#define PFA_CENTER
Definition: richedit.h:923
#define EM_REDO
Definition: richedit.h:117
#define PFM_NUMBERING
Definition: richedit.h:843
#define EM_GETSELTEXT
Definition: richedit.h:95
#define ST_DEFAULT
Definition: richedit.h:1070
#define CFE_AUTOCOLOR
Definition: richedit.h:414
#define PFM_OFFSET
Definition: richedit.h:840
#define EM_SETBKGNDCOLOR
Definition: richedit.h:100
#define EM_SETTEXTEX
Definition: richedit.h:131
#define EM_GETPARAFORMAT
Definition: richedit.h:94
#define PFN_BULLET
Definition: richedit.h:905
#define EM_GETTEXTRANGE
Definition: richedit.h:108
#define EM_EXSETSEL
Definition: richedit.h:88
#define EM_EXGETSEL
Definition: richedit.h:85
DWORD dwMask
Definition: richedit.h:654
LONG dxOffset
Definition: richedit.h:659
UINT cbSize
Definition: richedit.h:653
WORD wNumbering
Definition: richedit.h:655
UINT codepage
Definition: richedit.h:1066
DWORD flags
Definition: richedit.h:1065
CHARRANGE chrg
Definition: richedit.h:514
LPWSTR lpstrText
Definition: richedit.h:515
LONG bottom
Definition: windef.h:309
LONG left
Definition: windef.h:306
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1384
#define EM_SETREADONLY
Definition: winuser.h:2015
#define WM_CLOSE
Definition: winuser.h:1621
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
#define WM_PASTE
Definition: winuser.h:1863
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EM_GETMODIFY
Definition: winuser.h:1994
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4399
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define TPM_NONOTIFY
Definition: winuser.h:2386
#define WM_CUT
Definition: winuser.h:1861
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define TPM_TOPALIGN
Definition: winuser.h:2383
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define TPM_LEFTALIGN
Definition: winuser.h:2377
#define EM_UNDO
Definition: winuser.h:2021
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define TPM_LEFTBUTTON
Definition: winuser.h:2379
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define WM_COPY
Definition: winuser.h:1862
#define CBN_SELENDOK
Definition: winuser.h:1981
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define WM_CLEAR
Definition: winuser.h:1864
#define TPM_RETURNCMD
Definition: winuser.h:2387
#define GWL_STYLE
Definition: winuser.h:852
struct tagMENUITEMINFOW MENUITEMINFOW
#define IDC_FORMATBAR
Definition: wordpad.h:158
#define ID_FILE_RECENT3
Definition: wordpad.h:35
#define IDC_EDITOR
Definition: wordpad.h:156
#define ID_COLOR_FIRST
Definition: wordpad.h:136
#define ID_FIND
Definition: wordpad.h:44
#define ID_EDIT_UNDO
Definition: wordpad.h:68
#define ID_EDIT_REDO
Definition: wordpad.h:69
#define BANDID_FONTLIST
Definition: wordpad.h:98
#define ID_TOGGLE_TOOLBAR
Definition: wordpad.h:84
#define ID_EDIT_MODIFIED
Definition: wordpad.h:64
#define ID_FORMAT_BOLD
Definition: wordpad.h:79
#define ID_EDIT_SELECTIONINFO
Definition: wordpad.h:62
#define ID_FILE_RECENT4
Definition: wordpad.h:36
#define BANDID_SIZELIST
Definition: wordpad.h:99
#define ID_FORMAT_UNDERLINE
Definition: wordpad.h:81
#define IDC_SIZELIST
Definition: wordpad.h:169
#define ID_TOGGLE_FORMATBAR
Definition: wordpad.h:85
#define IDD_PARAFORMAT
Definition: wordpad.h:175
#define ID_TOGGLE_STATUSBAR
Definition: wordpad.h:86
#define ID_FORMAT_COLOR
Definition: wordpad.h:82
#define ID_EDIT_SELECTALL
Definition: wordpad.h:61
#define ID_VIEWPROPERTIES
Definition: wordpad.h:134
#define ID_FILE_RECENT2
Definition: wordpad.h:34
#define ID_FORMAT_ITALIC
Definition: wordpad.h:80
#define ID_ALIGN_CENTER
Definition: wordpad.h:55
#define ID_PARAFORMAT
Definition: wordpad.h:130
#define ID_EDIT_GETTEXT
Definition: wordpad.h:70
#define ID_EDIT_READONLY
Definition: wordpad.h:63
#define IDC_REBAR
Definition: wordpad.h:159
#define ID_COLOR_AUTOMATIC
Definition: wordpad.h:153
#define ID_PRINTSETUP
Definition: wordpad.h:41
#define ID_FONTSETTINGS
Definition: wordpad.h:77
#define ID_BACK_1
Definition: wordpad.h:58
#define ID_REPLACE
Definition: wordpad.h:46
#define ID_PREVIEW
Definition: wordpad.h:40
#define ID_BULLET
Definition: wordpad.h:75
#define ID_EDIT_DEFCHARFORMAT
Definition: wordpad.h:67
#define ID_EDIT_PARAFORMAT
Definition: wordpad.h:66
#define ID_EDIT_CUT
Definition: wordpad.h:72
#define ID_DATETIME
Definition: wordpad.h:129
#define ID_FILE_RECENT1
Definition: wordpad.h:33
#define ID_PRINT_QUICK
Definition: wordpad.h:42
#define IDC_FONTLIST
Definition: wordpad.h:168
#define ID_TABSTOPS
Definition: wordpad.h:131
#define ID_EDIT_CLEAR
Definition: wordpad.h:74
#define ID_TOGGLE_RULER
Definition: wordpad.h:87
#define ID_ALIGN_LEFT
Definition: wordpad.h:54
#define ID_EDIT_CHARFORMAT
Definition: wordpad.h:65
#define ID_ALIGN_RIGHT
Definition: wordpad.h:56
#define ID_PRINT
Definition: wordpad.h:39
#define IDD_DATETIME
Definition: wordpad.h:173
#define IDD_NEWFILE
Definition: wordpad.h:174
#define IDD_TABSTOPS
Definition: wordpad.h:176
#define ID_BACK_2
Definition: wordpad.h:59

Referenced by WndProc().

◆ OnCreate()

static LRESULT OnCreate ( HWND  hWnd)
static

Definition at line 1805 of file wordpad.c.

1806{
1807 HWND hToolBarWnd, hFormatBarWnd, hReBarWnd, hFontListWnd, hSizeListWnd, hRulerWnd;
1809 HANDLE hDLL;
1811 int nStdBitmaps = 0;
1812 REBARINFO rbi;
1813 REBARBANDINFOW rbb;
1814 static const WCHAR wszRichEditDll[] = {'R','I','C','H','E','D','2','0','.','D','L','L','\0'};
1815 static const WCHAR wszRichEditText[] = {'R','i','c','h','E','d','i','t',' ','t','e','x','t','\0'};
1816
1818
1822
1823 rbi.cbSize = sizeof(rbi);
1824 rbi.fMask = 0;
1825 rbi.himl = NULL;
1826 if(!SendMessageW(hReBarWnd, RB_SETBARINFO, 0, (LPARAM)&rbi))
1827 return -1;
1828
1832 NULL, 0,
1833 24, 24, 16, 16, sizeof(TBBUTTON));
1834
1835 ab.hInst = HINST_COMMCTRL;
1836 ab.nID = IDB_STD_SMALL_COLOR;
1837 nStdBitmaps = SendMessageW(hToolBarWnd, TB_ADDBITMAP, 0, (LPARAM)&ab);
1838
1839 AddButton(hToolBarWnd, nStdBitmaps+STD_FILENEW, ID_FILE_NEW);
1840 AddButton(hToolBarWnd, nStdBitmaps+STD_FILEOPEN, ID_FILE_OPEN);
1841 AddButton(hToolBarWnd, nStdBitmaps+STD_FILESAVE, ID_FILE_SAVE);
1842 AddSeparator(hToolBarWnd);
1843 AddButton(hToolBarWnd, nStdBitmaps+STD_PRINT, ID_PRINT_QUICK);
1844 AddButton(hToolBarWnd, nStdBitmaps+STD_PRINTPRE, ID_PREVIEW);
1845 AddSeparator(hToolBarWnd);
1846 AddButton(hToolBarWnd, nStdBitmaps+STD_FIND, ID_FIND);
1847 AddSeparator(hToolBarWnd);
1848 AddButton(hToolBarWnd, nStdBitmaps+STD_CUT, ID_EDIT_CUT);
1849 AddButton(hToolBarWnd, nStdBitmaps+STD_COPY, ID_EDIT_COPY);
1850 AddButton(hToolBarWnd, nStdBitmaps+STD_PASTE, ID_EDIT_PASTE);
1851 AddButton(hToolBarWnd, nStdBitmaps+STD_UNDO, ID_EDIT_UNDO);
1852 AddButton(hToolBarWnd, nStdBitmaps+STD_REDOW, ID_EDIT_REDO);
1853 AddSeparator(hToolBarWnd);
1854 AddButton(hToolBarWnd, 0, ID_DATETIME);
1855
1856 SendMessageW(hToolBarWnd, TB_AUTOSIZE, 0, 0);
1857
1861 rbb.cx = 0;
1862 rbb.hwndChild = hToolBarWnd;
1863 rbb.cxMinChild = 0;
1864 rbb.cyChild = rbb.cyMinChild = HIWORD(SendMessageW(hToolBarWnd, TB_GETBUTTONSIZE, 0, 0));
1865 rbb.wID = BANDID_TOOLBAR;
1866
1867 SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1868
1869 hFontListWnd = CreateWindowExW(0, WC_COMBOBOXEXW, NULL,
1871 0, 0, 200, 150, hReBarWnd, (HMENU)IDC_FONTLIST, hInstance, NULL);
1872
1873 rbb.hwndChild = hFontListWnd;
1874 rbb.cx = 200;
1875 rbb.wID = BANDID_FONTLIST;
1876
1877 SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1878
1879 hSizeListWnd = CreateWindowExW(0, WC_COMBOBOXEXW, NULL,
1881 0, 0, 50, 150, hReBarWnd, (HMENU)IDC_SIZELIST, hInstance, NULL);
1882
1883 rbb.hwndChild = hSizeListWnd;
1884 rbb.cx = 50;
1885 rbb.fStyle ^= RBBS_BREAK;
1886 rbb.wID = BANDID_SIZELIST;
1887
1888 SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1889
1890 hFormatBarWnd = CreateToolbarEx(hReBarWnd,
1892 IDC_FORMATBAR, 8, hInstance, IDB_FORMATBAR, NULL, 0, 16, 16, 16, 16, sizeof(TBBUTTON));
1893
1894 AddButton(hFormatBarWnd, 0, ID_FORMAT_BOLD);
1895 AddButton(hFormatBarWnd, 1, ID_FORMAT_ITALIC);
1896 AddButton(hFormatBarWnd, 2, ID_FORMAT_UNDERLINE);
1897 AddButton(hFormatBarWnd, 3, ID_FORMAT_COLOR);
1898 AddSeparator(hFormatBarWnd);
1899 AddButton(hFormatBarWnd, 4, ID_ALIGN_LEFT);
1900 AddButton(hFormatBarWnd, 5, ID_ALIGN_CENTER);
1901 AddButton(hFormatBarWnd, 6, ID_ALIGN_RIGHT);
1902 AddSeparator(hFormatBarWnd);
1903 AddButton(hFormatBarWnd, 7, ID_BULLET);
1904
1905 SendMessageW(hFormatBarWnd, TB_AUTOSIZE, 0, 0);
1906
1907 rbb.hwndChild = hFormatBarWnd;
1908 rbb.wID = BANDID_FORMATBAR;
1909
1910 SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1911
1913 0, 0, 200, 10, hReBarWnd, (HMENU)IDC_RULER, hInstance, NULL);
1914
1915
1916 rbb.hwndChild = hRulerWnd;
1917 rbb.wID = BANDID_RULER;
1918 rbb.fStyle |= RBBS_BREAK;
1919
1920 SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1921
1922 hDLL = LoadLibraryW(wszRichEditDll);
1923 if(!hDLL)
1924 {
1927 PostQuitMessage(1);
1928 }
1929
1933 0, 0, 1000, 100, hWnd, (HMENU)IDC_EDITOR, hInstance, NULL);
1934
1935 if (!hEditorWnd)
1936 {
1937 fprintf(stderr, "Error code %u\n", GetLastError());
1938 return -1;
1939 }
1941
1945
1947
1948 populate_font_list(hFontListWnd);
1949 populate_size_list(hSizeListWnd);
1950 DoLoadStrings();
1952
1954
1959
1960 return 0;
1961}
#define IDC_STATUSBAR
Definition: resource.h:12
void registry_read_formatopts_all(DWORD barState[], DWORD wordWrap[])
Definition: registry.c:398
void registry_read_options(void)
Definition: registry.c:335
void registry_read_filelist(HWND hMainWnd)
Definition: registry.c:217
static void DoLoadStrings(void)
Definition: wordpad.c:97
static void populate_font_list(HWND hListWnd)
Definition: wordpad.c:631
static void AddButton(HWND hwndToolBar, int nImage, int nCommand)
Definition: wordpad.c:155
static UINT ID_FINDMSGSTRING
Definition: wordpad.c:65
static void set_default_font(void)
Definition: wordpad.c:501
static void AddSeparator(HWND hwndToolBar)
Definition: wordpad.c:169
static void populate_size_list(HWND hSizeListWnd)
Definition: wordpad.c:365
HWND WINAPI CreateStatusWindowW(LONG style, LPCWSTR text, HWND parent, UINT wid)
Definition: commctrl.c:795
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 FINDMSGSTRINGW
Definition: commdlg.h:28
#define LoadLibraryW(x)
Definition: compat.h:747
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:522
#define assert(x)
Definition: debug.h:53
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
UCHAR ab[sizeof("Hello World!") -1]
Definition: fdi.c:106
HRESULT setup_richedit_olecallback(HWND hEditorWnd)
Definition: olecallback.c:203
#define WS_CHILD
Definition: pedump.c:617
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define ES_WANTRETURN
Definition: pedump.c:676
#define WS_BORDER
Definition: pedump.c:625
#define ES_NOHIDESEL
Definition: pedump.c:673
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_HSCROLL
Definition: pedump.c:628
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define ES_MULTILINE
Definition: pedump.c:667
#define STD_COPY
Definition: commctrl.h:1072
#define RBBS_BREAK
Definition: commctrl.h:1489
#define REBARBANDINFOW_V6_SIZE
Definition: commctrl.h:1542
#define TB_AUTOSIZE
Definition: commctrl.h:1137
#define STD_PRINT
Definition: commctrl.h:1085
#define STD_FILENEW
Definition: commctrl.h:1077
#define REBARCLASSNAMEW
Definition: commctrl.h:1463
#define RBBIM_CHILDSIZE
Definition: commctrl.h:1507
#define RB_INSERTBANDW
Definition: commctrl.h:1583
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define HINST_COMMCTRL
Definition: commctrl.h:1063
#define STD_PASTE
Definition: commctrl.h:1073
#define RBBIM_CHILD
Definition: commctrl.h:1506
#define STD_PRINTPRE
Definition: commctrl.h:1080
#define TB_GETBUTTONSIZE
Definition: commctrl.h:1160
#define WC_COMBOBOXEXW
Definition: commctrl.h:3781
#define STD_FILEOPEN
Definition: commctrl.h:1078
#define RBBS_NOGRIPPER
Definition: commctrl.h:1497
#define RBBS_CHILDEDGE
Definition: commctrl.h:1491
#define STD_CUT
Definition: commctrl.h:1071
#define STD_FILESAVE
Definition: commctrl.h:1079
#define CCS_NODIVIDER
Definition: commctrl.h:2248
#define CCS_TOP
Definition: commctrl.h:2242
#define STD_UNDO
Definition: commctrl.h:1074
#define STD_REDOW
Definition: commctrl.h:1075
#define RBBIM_ID
Definition: commctrl.h:1510
#define RBS_VARHEIGHT
Definition: commctrl.h:1471
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2246
#define CCS_NOMOVEY
Definition: commctrl.h:2243
#define RBBIM_STYLE
Definition: commctrl.h:1502
#define RB_SETBARINFO
Definition: commctrl.h:1578
#define RBBIM_SIZE
Definition: commctrl.h:1508
#define STD_FIND
Definition: commctrl.h:1083
#define WC_STATICW
Definition: commctrl.h:4680
#define TB_ADDBITMAP
Definition: commctrl.h:1056
#define IDB_STD_SMALL_COLOR
Definition: commctrl.h:1064
#define EM_SETEVENTMASK
Definition: richedit.h:102
static const WCHAR RICHEDIT_CLASS20W[]
Definition: richedit.h:50
#define ENM_SELCHANGE
Definition: richedit.h:478
#define ES_SELECTIONBAR
Definition: richedit.h:230
HIMAGELIST himl
Definition: commctrl.h:1483
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
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)
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
#define CBS_DROPDOWN
Definition: winuser.h:283
#define CBS_SORT
Definition: winuser.h:292
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define IDC_RULER
Definition: wordpad.h:170
#define IDB_TOOLBAR
Definition: wordpad.h:183
#define IDB_FORMATBAR
Definition: wordpad.h:184
#define STRING_LOAD_RICHED_FAILED
Definition: wordpad.h:237
#define IDC_TOOLBAR
Definition: wordpad.h:157

Referenced by WndProc().

◆ OnInitPopupMenu()

static LRESULT OnInitPopupMenu ( HWND  hWnd,
WPARAM  wParam 
)
static

Definition at line 2486 of file wordpad.c.

2487{
2488 HMENU hMenu = (HMENU)wParam;
2489 HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
2491 PARAFORMAT pf;
2492 int nAlignment = -1;
2493 int selFrom, selTo;
2494 GETTEXTLENGTHEX gt;
2495 LRESULT textLength;
2497
2498 SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&selFrom, (LPARAM)&selTo);
2499 EnableMenuItem(hMenu, ID_EDIT_COPY, (selFrom == selTo) ? MF_GRAYED : MF_ENABLED);
2500 EnableMenuItem(hMenu, ID_EDIT_CUT, (selFrom == selTo) ? MF_GRAYED : MF_ENABLED);
2501
2502 pf.cbSize = sizeof(PARAFORMAT);
2503 SendMessageW(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
2507 SendMessageW(hwndEditor, EM_GETMODIFY, 0, 0) ? MF_CHECKED : MF_UNCHECKED);
2508 if (pf.dwMask & PFM_ALIGNMENT)
2509 nAlignment = pf.wAlignment;
2510 CheckMenuItem(hMenu, ID_ALIGN_LEFT, (nAlignment == PFA_LEFT) ? MF_CHECKED : MF_UNCHECKED);
2511 CheckMenuItem(hMenu, ID_ALIGN_CENTER, (nAlignment == PFA_CENTER) ? MF_CHECKED : MF_UNCHECKED);
2512 CheckMenuItem(hMenu, ID_ALIGN_RIGHT, (nAlignment == PFA_RIGHT) ? MF_CHECKED : MF_UNCHECKED);
2514 EnableMenuItem(hMenu, ID_EDIT_UNDO, SendMessageW(hwndEditor, EM_CANUNDO, 0, 0) ?
2516 EnableMenuItem(hMenu, ID_EDIT_REDO, SendMessageW(hwndEditor, EM_CANREDO, 0, 0) ?
2518
2521
2524
2527
2529
2530 gt.flags = GTL_NUMCHARS;
2531 gt.codepage = 1200;
2532 textLength = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)&gt, 0);
2533 EnableMenuItem(hMenu, ID_FIND, textLength ? MF_ENABLED : MF_GRAYED);
2534
2535 mi.cbSize = sizeof(mi);
2536 mi.fMask = MIIM_DATA;
2537
2539
2540 EnableMenuItem(hMenu, ID_FIND_NEXT, (textLength && mi.dwItemData) ? MF_ENABLED : MF_GRAYED);
2541
2542 EnableMenuItem(hMenu, ID_REPLACE, textLength ? MF_ENABLED : MF_GRAYED);
2543
2544 return 0;
2545}
#define EM_CANREDO
Definition: richedit.h:118
#define GTL_NUMCHARS
Definition: richedit.h:1058
struct _paraformat PARAFORMAT
HWND hwndStatus
Definition: solitaire.cpp:14
WORD wAlignment
Definition: richedit.h:660
#define MF_CHECKED
Definition: winuser.h:132
#define MF_UNCHECKED
Definition: winuser.h:204
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define EM_CANUNDO
Definition: winuser.h:1983
#define MF_ENABLED
Definition: winuser.h:128
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_GRAYED
Definition: winuser.h:129

Referenced by WndProc().

◆ OnNotify()

static LRESULT OnNotify ( HWND  hWnd,
LPARAM  lParam 
)
static

Definition at line 2015 of file wordpad.c.

2016{
2017 HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
2018 HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
2019 NMHDR *pHdr = (NMHDR *)lParam;
2020 HWND hwndFontList = GetDlgItem(hwndReBar, IDC_FONTLIST);
2021 HWND hwndSizeList = GetDlgItem(hwndReBar, IDC_SIZELIST);
2022
2023 if (pHdr->hwndFrom == hwndFontList || pHdr->hwndFrom == hwndSizeList)
2024 {
2025 if (pHdr->code == CBEN_ENDEDITW)
2026 {
2027 NMCBEENDEDITW *endEdit = (NMCBEENDEDITW *)lParam;
2028 if(pHdr->hwndFrom == hwndFontList)
2029 {
2030 on_fontlist_modified(endEdit->szText);
2031 } else if (pHdr->hwndFrom == hwndSizeList)
2032 {
2033 on_sizelist_modified(hwndSizeList,endEdit->szText);
2034 }
2035 }
2036 return 0;
2037 }
2038
2039 if (pHdr->hwndFrom != hwndEditor)
2040 return 0;
2041
2042 if (pHdr->code == EN_SELCHANGE)
2043 {
2044 SELCHANGE *pSC = (SELCHANGE *)lParam;
2045 char buf[128];
2046
2048
2049 sprintf( buf,"selection = %d..%d, line count=%ld",
2050 pSC->chrg.cpMin, pSC->chrg.cpMax,
2051 SendMessageW(hwndEditor, EM_GETLINECOUNT, 0, 0));
2053 SendMessageW(hWnd, WM_USER, 0, 0);
2054 return 1;
2055 }
2056 return 0;
2057}
#define CBEN_ENDEDITW
Definition: commctrl.h:3876
#define EN_SELCHANGE
Definition: richedit.h:193
WCHAR szText[CBEMAXSTRLEN]
Definition: commctrl.h:3914
CHARRANGE chrg
Definition: richedit.h:686
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157
#define WM_USER
Definition: winuser.h:1895
#define EM_GETLINECOUNT
Definition: winuser.h:1992

Referenced by DECLARE_INTERFACE_(), and WndProc().

◆ OnSize()

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

Definition at line 2547 of file wordpad.c.

2548{
2549 int nStatusSize = 0;
2550 RECT rc;
2552 HWND hwndStatusBar = GetDlgItem(hWnd, IDC_STATUSBAR);
2553 HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
2554 HWND hRulerWnd = GetDlgItem(hwndReBar, IDC_RULER);
2555 int rebarHeight = 0;
2556
2557 if (hwndStatusBar)
2558 {
2559 SendMessageW(hwndStatusBar, WM_SIZE, 0, 0);
2560 if (IsWindowVisible(hwndStatusBar))
2561 {
2562 GetClientRect(hwndStatusBar, &rc);
2563 nStatusSize = rc.bottom - rc.top;
2564 } else
2565 {
2566 nStatusSize = 0;
2567 }
2568 }
2569 if (hwndReBar)
2570 {
2571 rebarHeight = SendMessageW(hwndReBar, RB_GETBARHEIGHT, 0, 0);
2572
2573 MoveWindow(hwndReBar, 0, 0, LOWORD(lParam), rebarHeight, TRUE);
2574 }
2575 if (hwndEditor)
2576 {
2577 GetClientRect(hWnd, &rc);
2578 MoveWindow(hwndEditor, 0, rebarHeight, rc.right, rc.bottom-nStatusSize-rebarHeight, TRUE);
2579 }
2580
2581 redraw_ruler(hRulerWnd);
2582
2584}
void redraw_ruler(HWND hRulerWnd)
Definition: print.c:288
BOOL preview_isactive(void)
Definition: print.c:779
#define RB_GETBARHEIGHT
Definition: commctrl.h:1608
LONG right
Definition: windef.h:308
LONG top
Definition: windef.h:307
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SIZE
Definition: winuser.h:1611
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define IDC_PREVIEW
Definition: wordpad.h:171

Referenced by update_window(), and WndProc().

◆ OnUser()

static LRESULT OnUser ( HWND  hWnd)
static

Definition at line 1963 of file wordpad.c.

1964{
1965 HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
1966 HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
1967 HWND hwndToolBar = GetDlgItem(hwndReBar, IDC_TOOLBAR);
1968 HWND hwndFormatBar = GetDlgItem(hwndReBar, IDC_FORMATBAR);
1969 int from, to;
1971 PARAFORMAT2 pf;
1972 GETTEXTLENGTHEX gt;
1973
1974 ZeroMemory(&fmt, sizeof(fmt));
1975 fmt.cbSize = sizeof(fmt);
1976
1977 ZeroMemory(&pf, sizeof(pf));
1978 pf.cbSize = sizeof(pf);
1979
1980 gt.flags = GTL_NUMCHARS;
1981 gt.codepage = 1200;
1982
1983 SendMessageW(hwndToolBar, TB_ENABLEBUTTON, ID_FIND,
1984 SendMessageW(hwndEditor, EM_GETTEXTLENGTHEX, (WPARAM)&gt, 0) ? 1 : 0);
1985
1986 SendMessageW(hwndEditor, EM_GETCHARFORMAT, TRUE, (LPARAM)&fmt);
1987
1988 SendMessageW(hwndEditor, EM_GETSEL, (WPARAM)&from, (LPARAM)&to);
1990 SendMessageW(hwndEditor, EM_CANUNDO, 0, 0));
1992 SendMessageW(hwndEditor, EM_CANREDO, 0, 0));
1993 SendMessageW(hwndToolBar, TB_ENABLEBUTTON, ID_EDIT_CUT, from == to ? 0 : 1);
1994 SendMessageW(hwndToolBar, TB_ENABLEBUTTON, ID_EDIT_COPY, from == to ? 0 : 1);
1995
1996 SendMessageW(hwndFormatBar, TB_CHECKBUTTON, ID_FORMAT_BOLD, (fmt.dwMask & CFM_BOLD) &&
1997 (fmt.dwEffects & CFE_BOLD));
1998 SendMessageW(hwndFormatBar, TB_INDETERMINATE, ID_FORMAT_BOLD, !(fmt.dwMask & CFM_BOLD));
1999 SendMessageW(hwndFormatBar, TB_CHECKBUTTON, ID_FORMAT_ITALIC, (fmt.dwMask & CFM_ITALIC) &&
2000 (fmt.dwEffects & CFE_ITALIC));
2001 SendMessageW(hwndFormatBar, TB_INDETERMINATE, ID_FORMAT_ITALIC, !(fmt.dwMask & CFM_ITALIC));
2002 SendMessageW(hwndFormatBar, TB_CHECKBUTTON, ID_FORMAT_UNDERLINE, (fmt.dwMask & CFM_UNDERLINE) &&
2003 (fmt.dwEffects & CFE_UNDERLINE));
2005
2006 SendMessageW(hwndEditor, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
2010
2012 return 0;
2013}
#define TB_CHECKBUTTON
Definition: commctrl.h:1043
#define TB_ENABLEBUTTON
Definition: commctrl.h:1042
#define TB_INDETERMINATE
Definition: commctrl.h:1046
CardRegion * from
Definition: spigame.cpp:19
WORD wNumbering
Definition: richedit.h:668

Referenced by WndProc().

◆ paraformat_proc()

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

Definition at line 1528 of file wordpad.c.

1529{
1530 static const WORD ALIGNMENT_VALUES[] = {PFA_LEFT, PFA_RIGHT, PFA_CENTER};
1531
1532 switch(message)
1533 {
1534 case WM_INITDIALOG:
1535 {
1538 HWND hListWnd = GetDlgItem(hWnd, IDC_PARA_ALIGN);
1539 HWND hLeftWnd = GetDlgItem(hWnd, IDC_PARA_LEFT);
1540 HWND hRightWnd = GetDlgItem(hWnd, IDC_PARA_RIGHT);
1541 HWND hFirstWnd = GetDlgItem(hWnd, IDC_PARA_FIRST);
1542 PARAFORMAT2 pf;
1543 int index = 0;
1544
1547 SendMessageW(hListWnd, CB_ADDSTRING, 0, (LPARAM)buffer);
1550 SendMessageW(hListWnd, CB_ADDSTRING, 0, (LPARAM)buffer);
1553 SendMessageW(hListWnd, CB_ADDSTRING, 0, (LPARAM)buffer);
1554
1555 pf.cbSize = sizeof(pf);
1559
1560 if(pf.wAlignment == PFA_RIGHT)
1561 index ++;
1562 else if(pf.wAlignment == PFA_CENTER)
1563 index += 2;
1564
1565 SendMessageW(hListWnd, CB_SETCURSEL, index, 0);
1566
1568 SetWindowTextW(hLeftWnd, buffer);
1570 SetWindowTextW(hRightWnd, buffer);
1572 SetWindowTextW(hFirstWnd, buffer);
1573 }
1574 break;
1575
1576 case WM_COMMAND:
1577 switch(LOWORD(wParam))
1578 {
1579 case IDOK:
1580 {
1581 HWND hListWnd = GetDlgItem(hWnd, IDC_PARA_ALIGN);
1582 HWND hLeftWnd = GetDlgItem(hWnd, IDC_PARA_LEFT);
1583 HWND hRightWnd = GetDlgItem(hWnd, IDC_PARA_RIGHT);
1584 HWND hFirstWnd = GetDlgItem(hWnd, IDC_PARA_FIRST);
1586 int index;
1587 float num;
1588 int ret = 0;
1589 PARAFORMAT pf;
1590 UNIT unit;
1591
1592 index = SendMessageW(hListWnd, CB_GETCURSEL, 0, 0);
1593 pf.wAlignment = ALIGNMENT_VALUES[index];
1594
1597 ret++;
1601 ret++;
1605 ret++;
1607
1608 if(ret != 3)
1609 {
1612 return FALSE;
1613 } else
1614 {
1615 if (pf.dxOffset + pf.dxStartIndent < 0
1616 && pf.dxStartIndent < 0)
1617 {
1618 /* The first line is before the left edge, so
1619 * make sure it is at the left edge. */
1620 pf.dxOffset = -pf.dxStartIndent;
1621 } else if (pf.dxOffset < 0) {
1622 /* The second and following lines are before
1623 * the left edge, so set it to be at the left
1624 * edge, and adjust the first line since it
1625 * is relative to it. */
1626 pf.dxStartIndent = max(pf.dxStartIndent + pf.dxOffset, 0);
1627 pf.dxOffset = 0;
1628 }
1629 /* Internally the dxStartIndent is the absolute
1630 * offset for the first line and dxOffset is
1631 * to it value as opposed how it is displayed with
1632 * the first line being the relative value.
1633 * These two lines make the adjustments. */
1635 pf.dxOffset = pf.dxOffset - pf.dxStartIndent;
1636
1637 pf.cbSize = sizeof(pf);
1641 }
1642 }
1643 /* Fall through */
1644
1645 case IDCANCEL:
1647 return TRUE;
1648 }
1649 }
1650 return FALSE;
1651}
static void number_with_units(LPWSTR buffer, int number)
Definition: wordpad.c:1392
static int units_to_twips(UNIT unit, float number)
Definition: wordpad.c:1363
unsigned short WORD
Definition: ntddk_ex.h:93
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
#define PFM_RIGHTINDENT
Definition: richedit.h:839
#define PFM_STARTINDENT
Definition: richedit.h:838
LONG dxRightIndent
Definition: richedit.h:671
LONG dxOffset
Definition: richedit.h:672
LONG dxStartIndent
Definition: richedit.h:670
LONG dxRightIndent
Definition: richedit.h:658
LONG dxStartIndent
Definition: richedit.h:657
#define max(a, b)
Definition: svc.c:63
#define CB_SETCURSEL
Definition: winuser.h:1961
#define CB_ADDSTRING
Definition: winuser.h:1936
#define CB_GETCURSEL
Definition: winuser.h:1943
#define IDC_PARA_LEFT
Definition: wordpad.h:163
#define STRING_ALIGN_CENTER
Definition: wordpad.h:212
#define IDC_PARA_RIGHT
Definition: wordpad.h:164
#define STRING_ALIGN_RIGHT
Definition: wordpad.h:211
#define IDC_PARA_FIRST
Definition: wordpad.h:165
#define IDC_PARA_ALIGN
Definition: wordpad.h:166
#define STRING_ALIGN_LEFT
Definition: wordpad.h:210

Referenced by OnCommand().

◆ populate_font_list()

static void populate_font_list ( HWND  hListWnd)
static

Definition at line 631 of file wordpad.c.

632{
634 LOGFONTW fontinfo;
635 HWND hListEditWnd = (HWND)SendMessageW(hListWnd, CBEM_GETEDITCONTROL, 0, 0);
637
638 fontinfo.lfCharSet = DEFAULT_CHARSET;
639 *fontinfo.lfFaceName = '\0';
640 fontinfo.lfPitchAndFamily = 0;
641
643 (LPARAM)hListWnd, 0);
644
645 ZeroMemory(&fmt, sizeof(fmt));
646 fmt.cbSize = sizeof(fmt);
648 SendMessageW(hListEditWnd, WM_SETTEXT, 0, (LPARAM)fmt.szFaceName);
649}
static int CALLBACK enum_font_proc(const LOGFONTW *lpelfe, const TEXTMETRICW *lpntme, DWORD FontType, LPARAM lParam)
Definition: wordpad.c:615
HDC hdc
Definition: main.c:9
#define CBEM_GETEDITCONTROL
Definition: commctrl.h:3833
#define SCF_DEFAULT
Definition: richedit.h:234
BYTE lfCharSet
Definition: dimm.idl:67
BYTE lfPitchAndFamily
Definition: dimm.idl:71
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define WM_SETTEXT
Definition: winuser.h:1617

Referenced by OnCreate().

◆ populate_size_list()

static void populate_size_list ( HWND  hSizeListWnd)
static

Definition at line 365 of file wordpad.c.

366{
367 HWND hReBarWnd = GetDlgItem(hMainWnd, IDC_REBAR);
368 HWND hFontListWnd = GetDlgItem(hReBarWnd, IDC_FONTLIST);
369 COMBOBOXEXITEMW cbFontItem;
371 HWND hListEditWnd = (HWND)SendMessageW(hSizeListWnd, CBEM_GETEDITCONTROL, 0, 0);
373 static const unsigned choices[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
374 WCHAR buffer[3];
375 size_t i;
377
378 ZeroMemory(&fmt, sizeof(fmt));
379 fmt.cbSize = sizeof(fmt);
381
382 cbFontItem.mask = CBEIF_LPARAM;
383 cbFontItem.iItem = SendMessageW(hFontListWnd, CB_FINDSTRINGEXACT, -1, (LPARAM)fmt.szFaceName);
384 SendMessageW(hFontListWnd, CBEM_GETITEMW, 0, (LPARAM)&cbFontItem);
385
386 fontStyle = (DWORD)LOWORD(cbFontItem.lParam);
387
388 SendMessageW(hSizeListWnd, CB_RESETCONTENT, 0, 0);
389
390 if((fontStyle & RASTER_FONTTYPE) && cbFontItem.iItem)
391 {
392 add_size(hSizeListWnd, (BYTE)MulDiv(HIWORD(cbFontItem.lParam), 72,
394 } else
395 {
396 for(i = 0; i < sizeof(choices)/sizeof(choices[0]); i++)
397 add_size(hSizeListWnd, choices[i]);
398 }
399
400 wsprintfW(buffer, stringFormat, fmt.yHeight / 20);
401 SendMessageW(hListEditWnd, WM_SETTEXT, 0, (LPARAM)buffer);
402}
static void add_size(HWND hSizeListWnd, unsigned size)
Definition: wordpad.c:353
GLenum const GLvoid GLbitfield fontStyle
Definition: glext.h:11715
#define DWORD
Definition: nt_native.h:44
#define CB_RESETCONTENT
Definition: winuser.h:1959

Referenced by OnCreate(), set_font(), and update_font_list().

◆ preview_exit()

static void preview_exit ( HWND  hMainWnd)
static

Definition at line 723 of file wordpad.c.

724{
727
730
732
733 SetMenu(hMainWnd, hMenu);
735
737}
#define IDM_MAINMENU
Definition: resources.h:3
void close_preview(HWND hMainWnd)
Definition: print.c:751
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)

Referenced by WndProc().

◆ preview_proc()

LRESULT CALLBACK preview_proc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1016 of file print.c.

1017{
1018 switch(msg)
1019 {
1020 case WM_CREATE:
1021 {
1024 FORMATRANGE fr;
1025 GETTEXTLENGTHEX gt = {GTL_DEFAULT, 1200};
1026 HDC hdc = GetDC(hWnd);
1027 HDC hdcTarget = make_dc();
1028
1033 fr.rcPage = preview.rcPage;
1034
1037
1039
1041 fr.hdcTarget = hdcTarget;
1042 fr.chrg.cpMin = 0;
1044 DeleteDC(fr.hdc);
1046 ReleaseDC(hWnd, hdc);
1047
1050 break;
1051 }
1052
1053 case WM_PAINT:
1054 return print_preview(hWnd);
1055
1056 case WM_SIZE:
1057 {
1060 break;
1061 }
1062
1063 case WM_VSCROLL:
1064 case WM_HSCROLL:
1065 {
1066 SCROLLINFO si;
1067 RECT rc;
1068 int nBar = (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ;
1069 int origPos;
1070
1071 GetClientRect(hWnd, &rc);
1072 si.cbSize = sizeof(si);
1073 si.fMask = SIF_ALL;
1074 GetScrollInfo(hWnd, nBar, &si);
1075 origPos = si.nPos;
1076 switch(LOWORD(wParam))
1077 {
1078 case SB_TOP: /* == SB_LEFT */
1079 si.nPos = si.nMin;
1080 break;
1081 case SB_BOTTOM: /* == SB_RIGHT */
1082 si.nPos = si.nMax;
1083 break;
1084 case SB_LINEUP: /* == SB_LINELEFT */
1085 si.nPos -= si.nPage / 10;
1086 break;
1087 case SB_LINEDOWN: /* == SB_LINERIGHT */
1088 si.nPos += si.nPage / 10;
1089 break;
1090 case SB_PAGEUP: /* == SB_PAGELEFT */
1091 si.nPos -= si.nPage;
1092 break;
1093 case SB_PAGEDOWN: /* SB_PAGERIGHT */
1094 si.nPos += si.nPage;
1095 break;
1096 case SB_THUMBTRACK:
1097 si.nPos = si.nTrackPos;
1098 break;
1099 }
1100 si.fMask = SIF_POS;
1101 SetScrollInfo(hWnd, nBar, &si, TRUE);
1102 GetScrollInfo(hWnd, nBar, &si);
1103 if (si.nPos != origPos)
1104 {
1105 int amount = origPos - si.nPos;
1106 if (msg == WM_VSCROLL)
1107 ScrollWindow(hWnd, 0, amount, NULL, NULL);
1108 else
1109 ScrollWindow(hWnd, amount, 0, NULL, NULL);
1110 }
1111 return 0;
1112 }
1113
1114 case WM_SETCURSOR:
1115 {
1116 POINT pt;
1117 RECT rc;
1118 int bHittest = 0;
1119 DWORD messagePos = GetMessagePos();
1120 pt.x = (short)LOWORD(messagePos);
1121 pt.y = (short)HIWORD(messagePos);
1123
1124 GetClientRect(hWnd, &rc);
1125 if (PtInRect(&rc, pt))
1126 {
1127 pt.x += GetScrollPos(hWnd, SB_HORZ);
1128 pt.y += GetScrollPos(hWnd, SB_VERT);
1129 bHittest = preview_page_hittest(pt);
1130 }
1131
1132 if (bHittest)
1135 else
1137
1138 return TRUE;
1139 }
1140
1141 case WM_LBUTTONDOWN:
1142 {
1143 int page;
1144 POINT pt;
1147 if ((page = preview_page_hittest(pt)) > 0)
1148 {
1150
1151 /* Convert point from client coordinate to unzoomed page
1152 * coordinate. */
1153 pt.x -= preview.spacing.cx;
1154 if (page > 1)
1156 pt.y -= preview.spacing.cy;
1157 pt.x /= preview.zoomratio;
1158 pt.y /= preview.zoomratio;
1159
1160 if (preview.zoomlevel == 0)
1162 preview.zoomlevel = (preview.zoomlevel + 1) % 3;
1163 preview.zoomratio = 0;
1165 {
1167 } else if (preview.pages_shown > 1) {
1168 if (page >= 2) preview.page++;
1170 } else {
1174 }
1175
1176 if (preview.zoomlevel > 0) {
1177 SCROLLINFO si;
1178 /* Convert the coordinate back to client coordinate. */
1179 pt.x *= preview.zoomratio;
1180 pt.y *= preview.zoomratio;
1181 pt.x += preview.spacing.cx;
1182 pt.y += preview.spacing.cy;
1183 /* Scroll to center view at that point on the page */
1184 si.cbSize = sizeof(si);
1185 si.fMask = SIF_PAGE;
1186 GetScrollInfo(hWnd, SB_HORZ, &si);
1187 pt.x -= si.nPage / 2;
1189 GetScrollInfo(hWnd, SB_VERT, &si);
1190 pt.y -= si.nPage / 2;
1192 }
1193 }
1194 }
1195
1196 default:
1197 return DefWindowProcW(hWnd, msg, wParam, lParam);
1198 }
1199
1200 return 0;
1201}
HDC hdcTarget
Definition: PatBlt.c:13
#define msg(x)
Definition: auth_time.c:54
#define IDC_ZOOM
Definition: resource.h:16
static void update_preview_sizes(HWND hwndPreview, BOOL zoomLevelUpdated)
Definition: print.c:649
static LONG twips_to_pixels(int twips, int dpi)
Definition: print.c:176
static previewinfo preview
Definition: print.c:56
static int preview_page_hittest(POINT pt)
Definition: print.c:995
static void update_preview(HWND hMainWnd)
Definition: print.c:920
static LRESULT print_preview(HWND hwndPreview)
Definition: print.c:829
static void toggle_num_pages(HWND hMainWnd)
Definition: print.c:972
static HDC make_dc(void)
Definition: print.c:145
static RECT get_print_rect(HDC hdc)
Definition: print.c:187
static void update_preview_buttons(HWND hMainWnd)
Definition: print.c:815
static RECT margins
Definition: print.c:55
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
HWND hMainWnd
Definition: magnifier.c:32
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
HDC hdcTarget
Definition: richedit.h:608
CHARRANGE chrg
Definition: richedit.h:611
RECT rcPage
Definition: richedit.h:610
SIZE bmScaledSize
Definition: print.c:45
SIZE spacing
Definition: print.c:46
int pages_shown
Definition: print.c:36
float zoomratio
Definition: print.c:47
SIZE bmSize
Definition: print.c:44
int saved_pages_shown
Definition: print.c:37
int zoomlevel
Definition: print.c:48
int page
Definition: print.c:35
RECT rcPage
Definition: print.c:43
int textlength
Definition: print.c:39
Definition: module.h:576
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define LOGPIXELSX
Definition: wingdi.h:718
BOOL WINAPI DeleteDC(_In_ HDC)
#define WM_PAINT
Definition: winuser.h:1620
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SB_THUMBTRACK
Definition: winuser.h:573
#define SB_LINEUP
Definition: winuser.h:564
#define WM_HSCROLL
Definition: winuser.h:1743
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
#define WM_VSCROLL
Definition: winuser.h:1744
#define WM_CREATE
Definition: winuser.h:1608
#define SB_VERT
Definition: winuser.h:553
#define SB_BOTTOM
Definition: winuser.h:577
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define SIF_PAGE
Definition: winuser.h:1233
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2149
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SIF_ALL
Definition: winuser.h:1232
#define SB_LINEDOWN
Definition: winuser.h:565
HWND WINAPI GetParent(_In_ HWND)
#define SB_TOP
Definition: winuser.h:578
#define SIF_POS
Definition: winuser.h:1234
#define WM_SETCURSOR
Definition: winuser.h:1636
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
BOOL WINAPI ScrollWindow(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT)
#define SB_PAGEUP
Definition: winuser.h:568
#define SB_HORZ
Definition: winuser.h:552
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by WinMain().

◆ prompt_save_changes()

static BOOL prompt_save_changes ( void  )
static

Definition at line 940 of file wordpad.c.

941{
942 if(!wszFileName[0])
943 {
945 gt.flags = GTL_NUMCHARS;
946 gt.codepage = 1200;
948 return TRUE;
949 }
950
952 {
953 return TRUE;
954 } else
955 {
956 LPWSTR displayFileName;
957 WCHAR *text;
958 int ret;
959
960 if(!wszFileName[0])
961 displayFileName = wszDefaultFileName;
962 else
963 displayFileName = file_basename(wszFileName);
964
966 (lstrlenW(displayFileName)+lstrlenW(wszSaveChanges))*sizeof(WCHAR));
967
968 if(!text)
969 return FALSE;
970
971 wsprintfW(text, wszSaveChanges, displayFileName);
972
974
976
977 switch(ret)
978 {
979 case IDNO:
980 return TRUE;
981
982 case IDYES:
983 if(wszFileName[0])
985 return DialogSaveFile();
986
987 default:
988 return FALSE;
989 }
990 }
991}
LPWSTR file_basename(LPWSTR path)
Definition: wordpad.c:212
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
const WCHAR * text
Definition: package.c:1799
#define IDNO
Definition: winuser.h:836
#define MB_YESNOCANCEL
Definition: winuser.h:818

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

◆ set_bar_states()

◆ set_caption()

static void set_caption ( LPCWSTR  wszNewFileName)
static

Definition at line