ReactOS  0.4.12-dev-43-g63b00d8
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 <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 _WIN32_IE   0x0400
 
#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

◆ _WIN32_IE

#define _WIN32_IE   0x0400

Definition at line 23 of file wordpad.c.

◆ U

#define U (   x)    (x)

Definition at line 44 of file wordpad.c.

Referenced by __tcp_enter_cwr(), _mesa_expand_bitmap(), _mesa_init_all_x86_64_transform_asm(), _mesa_init_stencil(), _mesa_pack_colormask(), _swrast_Bitmap(), _TIFFVSetField(), adns__querysend_tcp(), af_face_globals_compute_style_coverage(), af_glyph_hints_reload(), apc(), append_file_test(), AVIFILE_ComputeMoviStart(), AVISplitter_InitializeStreams(), BindInfo_GetBindInfo(), cf2_interpT2CharString(), cff_compute_bias(), cff_parse_num(), cff_parser_run(), cff_ps_get_font_extra(), cff_subfont_load(), check_reg_type(), check_ssl_policy(), check_tiff_format(), compare_cms_signer_info(), compare_metadata(), compareAltNameEntry(), compareDistPointName(), continue_binding(), convert_8_to_32(), create_assembly(), create_bitmap(), create_dib(), create_emf(), create_file_test(), create_mfpict(), CDefView::CreateViewWindow3(), CtxClose(), CtxHello(), CtxOpen(), d3d9_opcode(), d3d9_register(), d3d_viewport_TransformVertices(), D3DXCreatePolygon(), DataObject_DAdvise(), DataObjectImpl_GetData(), DDSD_to_DDSD2(), deskey(), device_clear_render_targets(), dialog_viewproperties(), Ext2InitializeVcb(), f_mkfs(), fill_texture(), fill_tree(), fill_treeview_sort_test(), XMLStorage::XMLPos::filter(), find_arb_pshader(), fixedtables(), ft_bitmap_assure_buffer(), FT_Get_FSType_Flags(), ft_lzwstate_io(), ft_multo64(), FT_Render_Glyph_Internal(), FT_Set_Pixel_Sizes(), ft_stroke_border_close(), ft_trig_downscale(), get_sfnt_table(), get_stgdef(), gxv_array_getlimits_ushort(), gxv_feat_name_index_validate(), gxv_just_justData_lookuptable_validate(), gxv_just_pcLookupTable_validate(), gxv_opbd_validate(), gxv_trak_trackTable_validate(), hello_CtxClose(), hello_CtxOpen(), hook_WaitForInputIdle(), HTTP_HttpAddRequestHeadersW(), HvpWriteHive(), HvpWriteLog(), HvSyncHive(), hweight64(), inflate(), inflate_fast(), inflate_table(), inflateBackInit_(), inflateCopy(), inflateResetKeep(), lzx_write_bits(), m_CtxClose(), m_CtxHello(), m_CtxOpen(), m_CtxOpen2(), mailslot_test(), marshal_STGMEDIUM(), mdr_GetValue(), MENU_MenuBarCalcSize(), mix24(), mixer_test_controlA(), mixer_test_controlW(), ntlm_CreateSignature(), obj_DO_GetDataHere(), pfr_phy_font_load(), pixel_shader_init(), png_access_version_number(), Protocol_Start(), PS_Conv_EexecDecode(), query_image_section(), r_verify_pidl(), read_file_test(), read_pipe_test(), rpcrt4_ncacn_http_write(), sample_2d_ewa(), setdec(), setdec64(), sfnt_load_face(), shader_arb_generate_pshader(), shader_arb_select(), shader_get_registers_used(), shader_glsl_get_register_name(), shader_parse_dst_param(), shader_parse_src_param(), shader_sm1_read_immconst(), shader_sm4_read_param(), shader_usage_from_semantic_name(), shell_execute_ex_(), simulate_click(), START_TEST(), statusclb_OnDataAvailable(), stgmedium_cmp(), T1_Get_MM_Var(), T1_Get_Private_Dict(), t42_parse_sfnts(), tcp_recalc_ssthresh(), tcp_select_initial_window(), test_alertable(), test_appsearch_reglocator(), test_async_file_errors(), test_boundsrect(), test_buttons(), test_callback(), test_cancelio(), test_CList(), test_copy(), test_create_database_binary(), test_CreateDispTypeInfo(), test_createfromwmf(), test_CreateTypeLib(), test_custom_default_button(), test_data_cache(), test_data_cache_cache(), test_data_cache_dib_contents_stream(), test_decode_msg_get_param(), test_decodeAltName(), test_decodeAuthorityInfoAccess(), test_decodeAuthorityKeyId2(), test_decodeCMSSignerInfo(), test_decodeCRLDistPoints(), test_decodeCRLIssuingDistPoint(), test_decodeNameConstraints(), test_decodeSPCLink(), test_decodeSPCPEImage(), test_decodeSpOpusInfo(), test_default_data(), test_delete_items(), test_dik_codes(), test_directory_sort(), test_disableowner(), test_dump_typelib(), test_edit_control_limittext(), test_emfonly(), test_empty(), test_encodeAltName(), test_encodeAuthorityInfoAccess(), test_encodeAuthorityKeyId2(), test_encodeCMSSignerInfo(), test_encodeCRLDistPoints(), test_encodeCRLIssuingDistPoint(), test_encodeNameConstraints(), test_encodeSPCLink(), test_encodeSPCPEImage(), test_encodeSpOpusInfo(), test_expandinvisible(), test_file_all_information(), test_file_all_name_information(), test_file_basic_information(), test_file_completion_information(), test_file_link_information(), test_file_name_information(), test_file_rename_information(), test_findOIDInfo(), test_flags_NtQueryDirectoryFile(), test_fm2_enummatchingfilters(), test_focus(), test_GetAdaptersAddresses(), test_getdatahere(), test_GetDataHere_Proxy(), test_getitemtext(), test_htreeitem_layout(), test_import_resolution(), test_ImportDescriptors(), test_inheritance(), test_inputdesktop(), test_installprops(), test_iocp_fileio(), test_iocp_setcompletion(), test_IPersistStream(), test_IStream_invalid_operations(), test_Loader(), test_loadwmf(), test_LockFile(), test_messages(), test_metadata_APE(), test_metadata_cHRM(), test_metadata_gAMA(), test_metadata_GIF_comment(), test_metadata_IFD(), test_metadata_tEXt(), test_nonalertable(), test_nonole_clipboard(), test_nopage(), test_ntncdf(), test_ntncdf_async(), test_NtQueryDirectoryFile(), test_NtQueryDirectoryFile_case(), test_NtQueryDirectoryFile_classes(), test_offset_in_overlapped_structure(), test_OpenFileById(), test_overlapped(), test_PathIsValidCharA(), test_PathIsValidCharW(), test_PdhCollectQueryDataEx(), test_profile_int(), test_propertytovariant(), test_PSM_ADDPAGE(), test_PSM_INSERTPAGE(), test_PSPropertyKeyFromString(), test_PSStringFromPropertyKey(), test_query_attribute_information_file(), test_query_ea(), test_query_volume_information_file(), test_queryreader(), test_read_write(), test_readdirectorychanges(), test_readdirectorychanges_null(), test_readfileex_pending(), test_register_filter(), test_register_filter_with_null_clsMinorType(), test_RegQueryValueExPerformanceData(), test_render_filter_priority(), test_SetDocString(), test_SetFuncAndParamNames(), test_SetupCreateDiskSpaceListA(), test_SetupCreateDiskSpaceListW(), test_SetupDuplicateDiskSpaceListA(), test_SetupDuplicateDiskSpaceListW(), test_SetVarHelpContext(), test_SHCreateStreamOnFileEx_CopyTo(), test_signed_msg_encoding(), test_signed_msg_get_param(), test_signed_msg_open(), test_storage_refcount(), test_StrRetToBSTR(), test_StrRetToStringNW(), test_StrStrNIW(), test_StrStrNW(), test_StrXXX_overflows(), test_SuspendThread(), test_SystemInfo(), test_tcp_tx_full_window_lost(), test_title(), test_TVM_SORTCHILDREN(), test_TVS_SINGLEEXPAND(), test_urlcacheA(), test_validtypes(), test_VarDecAdd(), test_VarDecDiv(), test_VarDecMul(), test_VarFix(), test_varianttoproperty(), test_VarInt(), test_VarMod(), test_VarNeg(), test_VarNot(), test_VarRound(), test_WaitCommEvent(), test_waittxempty(), test_wintrust(), test_wiznavigation(), test_WM_KEYDOWN(), testCodepage(), testGetIpNetTable(), testGetIpStatistics(), testGetIpStatisticsEx(), testGetTcpStatistics(), testGetTcpStatisticsEx(), testGetTcpTable(), testObjTrust(), testPropsHelper(), testSetTcpEntry(), testTDA(), tex_coordindex(), texture2d_depth_blt_fbo(), TIFFClampDoubleToUInt32(), TIFFReadDirectory(), TIFFRGBAImageBegin(), tt_cmap_init(), tt_face_load_font_dir(), tt_face_load_hdmx(), tt_face_load_kern(), tt_face_load_maxp(), updatewindow(), vbo_get_minmax_index(), walk_constant_heap(), wine_dbgstr_propvariant(), wined3d_vertex_declaration_create_from_fvf(), and woff_open_font().

◆ U2

◆ U3

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 22 of file wordpad.c.

Enumeration Type Documentation

◆ UNIT

Enumerator
UNIT_CM 
UNIT_INCH 
UNIT_PT 

Definition at line 81 of file wordpad.c.

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

Function Documentation

◆ add_font()

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

Definition at line 535 of file wordpad.c.

Referenced by enum_font_proc().

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

◆ add_size()

static void add_size ( HWND  hSizeListWnd,
unsigned  size 
)
static

Definition at line 352 of file wordpad.c.

Referenced by populate_size_list().

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

◆ AddButton()

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

Definition at line 154 of file wordpad.c.

Referenced by OnCreate().

155 {
156  TBBUTTON button;
157 
158  ZeroMemory(&button, sizeof(button));
159  button.iBitmap = nImage;
160  button.idCommand = nCommand;
161  button.fsState = TBSTATE_ENABLED;
162  button.fsStyle = BTNS_BUTTON;
163  button.dwData = 0;
164  button.iString = -1;
165  SendMessageW(hwndToolBar, TB_ADDBUTTONSW, 1, (LPARAM)&button);
166 }
#define ZeroMemory
Definition: winbase.h:1635
BYTE fsStyle
Definition: commctrl.h:922
#define BTNS_BUTTON
Definition: commctrl.h:968
LONG_PTR LPARAM
Definition: windef.h:208
INT_PTR iString
Definition: commctrl.h:929
DWORD_PTR dwData
Definition: commctrl.h:928
int iBitmap
Definition: commctrl.h:919
int idCommand
Definition: commctrl.h:920
#define TB_ADDBUTTONSW
Definition: commctrl.h:1236
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TBSTATE_ENABLED
Definition: commctrl.h:944
BYTE fsState
Definition: commctrl.h:921

◆ AddSeparator()

static void AddSeparator ( HWND  hwndToolBar)
static

Definition at line 168 of file wordpad.c.

Referenced by OnCreate().

169 {
170  TBBUTTON button;
171 
172  ZeroMemory(&button, sizeof(button));
173  button.iBitmap = -1;
174  button.idCommand = 0;
175  button.fsState = 0;
176  button.fsStyle = BTNS_SEP;
177  button.dwData = 0;
178  button.iString = -1;
179  SendMessageW(hwndToolBar, TB_ADDBUTTONSW, 1, (LPARAM)&button);
180 }
#define ZeroMemory
Definition: winbase.h:1635
BYTE fsStyle
Definition: commctrl.h:922
LONG_PTR LPARAM
Definition: windef.h:208
INT_PTR iString
Definition: commctrl.h:929
DWORD_PTR dwData
Definition: commctrl.h:928
int iBitmap
Definition: commctrl.h:919
#define BTNS_SEP
Definition: commctrl.h:969
int idCommand
Definition: commctrl.h:920
#define TB_ADDBUTTONSW
Definition: commctrl.h:1236
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BYTE fsState
Definition: commctrl.h:921

◆ append_current_units()

static void append_current_units ( LPWSTR  buffer)
static

Definition at line 1368 of file wordpad.c.

Referenced by tabstops_proc().

1369 {
1370  static const WCHAR space[] = {' ', 0};
1371  lstrcatW(buffer, space);
1373 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint buffer
Definition: glext.h:5915
static WCHAR units_cmW[MAX_STRING_LEN]
Definition: wordpad.c:74
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

◆ clear_formatting()

static void clear_formatting ( void  )
static

Definition at line 447 of file wordpad.c.

Referenced by DoOpenFile(), and OnCommand().

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

◆ datetime_proc()

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

Definition at line 1412 of file wordpad.c.

Referenced by OnCommand().

1413 {
1414  switch(message)
1415  {
1416  case WM_INITDIALOG:
1417  {
1419  SYSTEMTIME st;
1420  HWND hListWnd = GetDlgItem(hWnd, IDC_DATETIME);
1421  GetLocalTime(&st);
1422 
1424  MAX_STRING_LEN);
1425  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1427  MAX_STRING_LEN);
1428  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1430  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1431 
1432  SendMessageW(hListWnd, LB_SETSEL, TRUE, 0);
1433  }
1434  break;
1435 
1436  case WM_COMMAND:
1437  switch(LOWORD(wParam))
1438  {
1439  case IDC_DATETIME:
1440  if (HIWORD(wParam) != LBN_DBLCLK)
1441  break;
1442  /* Fall through */
1443 
1444  case IDOK:
1445  {
1446  LRESULT index;
1447  HWND hListWnd = GetDlgItem(hWnd, IDC_DATETIME);
1448 
1449  index = SendMessageW(hListWnd, LB_GETCURSEL, 0, 0);
1450 
1451  if(index != LB_ERR)
1452  {
1453  WCHAR buffer[MAX_STRING_LEN];
1454  SendMessageW(hListWnd, LB_GETTEXT, index, (LPARAM)&buffer);
1456  }
1457  }
1458  /* Fall through */
1459 
1460  case IDCANCEL:
1461  EndDialog(hWnd, wParam);
1462  return TRUE;
1463  }
1464  }
1465  return FALSE;
1466 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define LB_ADDSTRING
Definition: winuser.h:1992
#define LB_SETSEL
Definition: winuser.h:2029
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
GLuint buffer
Definition: glext.h:5915
#define MAX_STRING_LEN
Definition: precomp.h:36
static HWND hEditorWnd
Definition: wordpad.c:60
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define LB_ERR
Definition: winuser.h:2386
LONG_PTR LPARAM
Definition: windef.h:208
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
#define IDC_DATETIME
Definition: wordpad.h:161
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LBN_DBLCLK
Definition: winuser.h:2032
#define index(s, c)
Definition: various.h:29
#define LB_GETTEXT
Definition: winuser.h:2010
#define WM_COMMAND
Definition: winuser.h:1716
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:916
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DATE_LONGDATE
Definition: winnls.h:194
#define LB_GETCURSEL
Definition: winuser.h:2000
#define HIWORD(l)
Definition: typedefs.h:246
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1016
#define WM_INITDIALOG
Definition: winuser.h:1715
#define LOWORD(l)
Definition: pedump.c:82
#define EM_REPLACESEL
Definition: winuser.h:1967

◆ dialog_about()

static void dialog_about ( void  )
static

Definition at line 1001 of file wordpad.c.

Referenced by OnCommand().

1002 {
1004  ShellAboutW(hMainWnd, wszAppTitle, 0, icon);
1005 }
static HICON
Definition: imagelist.c:84
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
#define IDI_WORDPAD
Definition: wordpad.h:186
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
static HWND hMainWnd
Definition: wordpad.c:59
BOOL WINAPI ShellAboutW(HWND hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON hIcon)
static const WCHAR wszAppTitle[]
Definition: wordpad.c:50
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ dialog_choose_font()

static void dialog_choose_font ( void  )
static

Definition at line 565 of file wordpad.c.

Referenced by OnCommand().

566 {
567  CHOOSEFONTW cf;
568  LOGFONTW lf;
570  HDC hDC = GetDC(hMainWnd);
571 
572  ZeroMemory(&cf, sizeof(cf));
573  cf.lStructSize = sizeof(cf);
574  cf.hwndOwner = hMainWnd;
575  cf.lpLogFont = &lf;
577 
578  ZeroMemory(&fmt, sizeof(fmt));
579  fmt.cbSize = sizeof(fmt);
580 
583  cf.lpLogFont->lfItalic = (fmt.dwEffects & CFE_ITALIC) != 0;
585  cf.lpLogFont->lfUnderline = (fmt.dwEffects & CFE_UNDERLINE) != 0;
586  cf.lpLogFont->lfStrikeOut = (fmt.dwEffects & CFE_STRIKEOUT) != 0;
587  cf.lpLogFont->lfHeight = -MulDiv(fmt.yHeight / 20, GetDeviceCaps(hDC, LOGPIXELSY), 72);
588  cf.rgbColors = fmt.crTextColor;
589 
590  if(ChooseFontW(&cf))
591  {
592  ZeroMemory(&fmt, sizeof(fmt));
593  fmt.cbSize = sizeof(fmt);
595  fmt.yHeight = cf.iPointSize * 2;
596 
597  if(cf.nFontType & BOLD_FONTTYPE)
598  fmt.dwEffects |= CFE_BOLD;
599  if(cf.nFontType & ITALIC_FONTTYPE)
600  fmt.dwEffects |= CFE_ITALIC;
601  if(cf.lpLogFont->lfUnderline)
602  fmt.dwEffects |= CFE_UNDERLINE;
603  if(cf.lpLogFont->lfStrikeOut)
604  fmt.dwEffects |= CFE_STRIKEOUT;
605 
606  fmt.crTextColor = cf.rgbColors;
607 
610  }
611 }
static IClassFactory * cf
#define HDC
Definition: msvc.h:22
INT iPointSize
Definition: commdlg.h:283
#define CFE_UNDERLINE
Definition: richedit.h:408
HDC WINAPI GetDC(_In_opt_ HWND)
#define CF_EFFECTS
Definition: commdlg.h:68
const char * fmt
Definition: wsprintf.c:30
#define ZeroMemory
Definition: winbase.h:1635
#define CFM_ITALIC
Definition: richedit.h:333
static HWND hEditorWnd
Definition: wordpad.c:60
WORD nFontType
Definition: commdlg.h:291
#define ITALIC_FONTTYPE
Definition: commdlg.h:91
#define CFE_BOLD
Definition: richedit.h:406
HWND hwndOwner
Definition: commdlg.h:280
LONG_PTR LPARAM
Definition: windef.h:208
BYTE lfItalic
Definition: wingdi.h:1879
#define CF_SCREENFONTS
Definition: commdlg.h:59
BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont)
Definition: fontdlg.c:185
#define EM_SETCHARFORMAT
Definition: richedit.h:101
LPLOGFONTW lpLogFont
Definition: commdlg.h:282
#define CFM_COLOR
Definition: richedit.h:361
LONG lfHeight
Definition: wingdi.h:1874
DWORD dwEffects
Definition: richedit.h:307
#define CFM_UNDERLINE
Definition: richedit.h:334
#define CF_NOSCRIPTSEL
Definition: commdlg.h:85
DWORD rgbColors
Definition: commdlg.h:285
#define CFM_SIZE
Definition: richedit.h:362
DWORD Flags
Definition: commdlg.h:284
WCHAR szFaceName[LF_FACESIZE]
Definition: richedit.h:313
static HWND hMainWnd
Definition: wordpad.c:59
#define CFE_ITALIC
Definition: richedit.h:407
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define CFM_STRIKEOUT
Definition: richedit.h:335
COLORREF crTextColor
Definition: richedit.h:310
DWORD lStructSize
Definition: commdlg.h:279
static HDC hDC
Definition: 3dtext.c:33
#define FW_BOLD
Definition: wingdi.h:376
#define lstrcpyW
Definition: compat.h:406
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define CFM_BOLD
Definition: richedit.h:332
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD dwMask
Definition: richedit.h:306
#define FW_NORMAL
Definition: wingdi.h:371
static void set_font(LPCWSTR wszFaceName)
Definition: wordpad.c:478
LONG lfWeight
Definition: wingdi.h:1878
#define CFE_STRIKEOUT
Definition: richedit.h:409
BYTE lfStrikeOut
Definition: wingdi.h:1881
#define SCF_SELECTION
Definition: richedit.h:235
BYTE lfUnderline
Definition: wingdi.h:1880
#define LOGPIXELSY
Definition: wingdi.h:717
WCHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1887
#define CF_NOVERTFONTS
Definition: commdlg.h:86
LONG yHeight
Definition: richedit.h:308
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66
#define BOLD_FONTTYPE
Definition: commdlg.h:90

◆ dialog_find()

static void dialog_find ( LPFINDREPLACEW  fr,
BOOL  replace 
)
static

Definition at line 1297 of file wordpad.c.

Referenced by OnCommand().

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

◆ dialog_viewproperties()

static void dialog_viewproperties ( void  )
static

Definition at line 1105 of file wordpad.c.

Referenced by OnCommand().

1106 {
1107  PROPSHEETPAGEW psp[2];
1108  PROPSHEETHEADERW psh;
1109  size_t i;
1111  LPCPROPSHEETPAGEW ppsp = (LPCPROPSHEETPAGEW)&psp;
1112 
1113  psp[0].dwSize = sizeof(PROPSHEETPAGEW);
1114  psp[0].dwFlags = PSP_USETITLE;
1115  U(psp[0]).pszTemplate = MAKEINTRESOURCEW(IDD_FORMATOPTS);
1116  psp[0].pfnDlgProc = formatopts_proc;
1117  psp[0].hInstance = hInstance;
1118  psp[0].lParam = reg_formatindex(SF_TEXT);
1119  psp[0].pfnCallback = NULL;
1121  for(i = 1; i < sizeof(psp)/sizeof(psp[0]); i++)
1122  {
1123  psp[i].dwSize = psp[0].dwSize;
1124  psp[i].dwFlags = psp[0].dwFlags;
1125  U(psp[i]).pszTemplate = U(psp[0]).pszTemplate;
1126  psp[i].pfnDlgProc = psp[0].pfnDlgProc;
1127  psp[i].hInstance = psp[0].hInstance;
1128  psp[i].lParam = reg_formatindex(SF_RTF);
1129  psp[i].pfnCallback = psp[0].pfnCallback;
1131  }
1132 
1133  psh.dwSize = sizeof(psh);
1135  psh.hwndParent = hMainWnd;
1136  psh.hInstance = hInstance;
1138  psh.nPages = sizeof(psp)/sizeof(psp[0]);
1139  U3(psh).ppsp = ppsp;
1140  U(psh).pszIcon = MAKEINTRESOURCEW(IDI_WORDPAD);
1141 
1142  if(fileFormat & SF_RTF)
1143  U2(psh).nStartPage = 1;
1144  else
1145  U2(psh).nStartPage = 0;
1146  PropertySheetW(&psh);
1147  set_bar_states();
1149 }
HWND hwndParent
Definition: prsht.h:277
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
#define IDI_WORDPAD
Definition: wordpad.h:186
#define SF_RTF
Definition: richedit.h:721
#define U(x)
Definition: wordpad.c:44
static DWORD wordWrap[2]
Definition: wordpad.c:66
#define STRING_VIEWPROPS_TITLE
Definition: wordpad.h:214
#define U3(x)
Definition: wordpad.c:46
GLenum GLclampf GLint i
Definition: glfuncs.h:14
DWORD dwSize
Definition: prsht.h:205
#define PSH_USEICONID
Definition: prsht.h:42
LPCWSTR pszCaption
Definition: prsht.h:283
DLGPROC pfnDlgProc
Definition: prsht.h:217
struct _PROPSHEETPAGEW PROPSHEETPAGEW
smooth NULL
Definition: ftsmooth.c:416
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2896
LPCWSTR pszTitle
Definition: prsht.h:216
static void set_bar_states(void)
Definition: wordpad.c:710
#define SF_TEXT
Definition: richedit.h:720
#define IDD_FORMATOPTS
Definition: wordpad.h:177
HINSTANCE hInstance
Definition: prsht.h:278
#define STRING_VIEWPROPS_RICHTEXT
Definition: wordpad.h:216
DWORD dwSize
Definition: prsht.h:275
HINSTANCE hInstance
Definition: wordpad.c:3
DWORD dwFlags
Definition: prsht.h:276
static WPARAM fileFormat
Definition: wordpad.c:68
static HWND hMainWnd
Definition: wordpad.c:59
static INT_PTR CALLBACK formatopts_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: wordpad.c:1007
LPARAM lParam
Definition: prsht.h:218
#define STRING_VIEWPROPS_TEXT
Definition: wordpad.h:215
HINSTANCE hInstance
Definition: prsht.h:207
#define U2(x)
Definition: wordpad.c:45
#define PSP_USETITLE
Definition: prsht.h:26
const PROPSHEETPAGEW * LPCPROPSHEETPAGEW
Definition: prsht.h:227
void target_device(HWND hMainWnd, DWORD wordWrap)
Definition: print.c:209
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
DWORD dwFlags
Definition: prsht.h:206
int reg_formatindex(WPARAM format)
Definition: registry.c:330

◆ DialogOpenFile()

static void DialogOpenFile ( void  )
static

Definition at line 976 of file wordpad.c.

Referenced by OnCommand().

977 {
979 
980  WCHAR wszFile[MAX_PATH] = {'\0'};
981  static const WCHAR wszDefExt[] = {'r','t','f','\0'};
982 
983  ZeroMemory(&ofn, sizeof(ofn));
984 
985  ofn.lStructSize = sizeof(ofn);
987  ofn.hwndOwner = hMainWnd;
988  ofn.lpstrFilter = wszFilter;
989  ofn.lpstrFile = wszFile;
990  ofn.nMaxFile = MAX_PATH;
991  ofn.lpstrDefExt = wszDefExt;
993 
994  if(GetOpenFileNameW(&ofn))
995  {
996  if(prompt_save_changes())
997  DoOpenFile(ofn.lpstrFile);
998  }
999 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
DWORD Flags
Definition: commdlg.h:373
LPCWSTR lpstrFilter
Definition: commdlg.h:363
__wchar_t WCHAR
Definition: xmlstorage.h:180
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
Definition: wordpad.c:71
LPWSTR lpstrFile
Definition: commdlg.h:367
OPENFILENAME ofn
Definition: main.cpp:37
#define ZeroMemory
Definition: winbase.h:1635
DWORD lStructSize
Definition: commdlg.h:360
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
static const WCHAR wszFile[]
Definition: urlmon_main.c:386
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4221
static BOOL prompt_save_changes(void)
Definition: wordpad.c:923
DWORD nFilterIndex
Definition: commdlg.h:366
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define MAX_PATH
Definition: compat.h:26
DWORD nMaxFile
Definition: commdlg.h:368
static WPARAM fileFormat
Definition: wordpad.c:68
static HWND hMainWnd
Definition: wordpad.c:59
HWND hwndOwner
Definition: commdlg.h:361
static int fileformat_number(WPARAM format)
Definition: wordpad.c:457
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
static void DoOpenFile(LPCWSTR szOpenFileName)
Definition: wordpad.c:763
#define OFN_ENABLESIZING
Definition: commdlg.h:101

◆ DialogSaveFile()

static BOOL DialogSaveFile ( void  )
static

Definition at line 892 of file wordpad.c.

Referenced by OnCommand(), and prompt_save_changes().

893 {
895 
896  WCHAR wszFile[MAX_PATH] = {'\0'};
897  static const WCHAR wszDefExt[] = {'r','t','f','\0'};
898 
899  ZeroMemory(&sfn, sizeof(sfn));
900 
901  sfn.lStructSize = sizeof(sfn);
903  sfn.hwndOwner = hMainWnd;
904  sfn.lpstrFilter = wszFilter;
905  sfn.lpstrFile = wszFile;
906  sfn.nMaxFile = MAX_PATH;
907  sfn.lpstrDefExt = wszDefExt;
909 
910  while(GetSaveFileNameW(&sfn))
911  {
912  if(fileformat_flags(sfn.nFilterIndex-1) != SF_RTF)
913  {
916  continue;
917  }
919  }
920  return FALSE;
921 }
DWORD Flags
Definition: commdlg.h:373
LPCWSTR lpstrFilter
Definition: commdlg.h:363
#define IDYES
Definition: winuser.h:829
#define SF_RTF
Definition: richedit.h:721
__wchar_t WCHAR
Definition: xmlstorage.h:180
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
Definition: wordpad.c:71
LPWSTR lpstrFile
Definition: commdlg.h:367
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4286
DWORD lStructSize
Definition: commdlg.h:360
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
#define MB_YESNO
Definition: winuser.h:811
static const WCHAR wszFile[]
Definition: urlmon_main.c:386
#define STRING_SAVE_LOSEFORMATTING
Definition: wordpad.h:238
DWORD nFilterIndex
Definition: commdlg.h:366
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
OPENFILENAMEW sfn
Definition: eventvwr.c:118
static BOOL DoSaveFile(LPCWSTR wszSaveFileName, WPARAM format)
Definition: wordpad.c:837
#define MAX_PATH
Definition: compat.h:26
DWORD nMaxFile
Definition: commdlg.h:368
static WPARAM fileFormat
Definition: wordpad.c:68
static WPARAM fileformat_flags(int format)
Definition: wordpad.c:471
static HWND hMainWnd
Definition: wordpad.c:59
HWND hwndOwner
Definition: commdlg.h:361
static int fileformat_number(WPARAM format)
Definition: wordpad.c:457
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
static const WCHAR wszAppTitle[]
Definition: wordpad.c:50
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:136
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define OFN_ENABLESIZING
Definition: commdlg.h:101

◆ DoLoadStrings()

static void DoLoadStrings ( void  )
static

Definition at line 96 of file wordpad.c.

Referenced by OnCreate().

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

◆ DoOpenFile()

static void DoOpenFile ( LPCWSTR  szOpenFileName)
static

Definition at line 763 of file wordpad.c.

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

764 {
765  HANDLE hFile;
766  EDITSTREAM es;
767  char fileStart[5];
768  DWORD readOut;
770 
771  hFile = CreateFileW(szOpenFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
773  if (hFile == INVALID_HANDLE_VALUE)
774  {
776  return;
777  }
778 
779  ReadFile(hFile, fileStart, 5, &readOut, NULL);
780  SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
781 
782  if(readOut >= 2 && (BYTE)fileStart[0] == 0xff && (BYTE)fileStart[1] == 0xfe)
783  {
784  format = SF_TEXT | SF_UNICODE;
785  SetFilePointer(hFile, 2, NULL, FILE_BEGIN);
786  } else if(readOut >= 5)
787  {
788  static const char header[] = "{\\rtf";
789  static const BYTE STG_magic[] = { 0xd0,0xcf,0x11,0xe0 };
790 
791  if(!memcmp(header, fileStart, 5))
792  format = SF_RTF;
793  else if (!memcmp(STG_magic, fileStart, sizeof(STG_magic)))
794  {
795  CloseHandle(hFile);
798  return;
799  }
800  }
801 
802  es.dwCookie = (DWORD_PTR)hFile;
803  es.pfnCallback = stream_in;
804 
806  set_fileformat(format);
807  SendMessageW(hEditorWnd, EM_STREAMIN, format, (LPARAM)&es);
808 
809  CloseHandle(hFile);
810 
812 
813  set_caption(szOpenFileName);
814 
815  lstrcpyW(wszFileName, szOpenFileName);
817  registry_set_filelist(szOpenFileName, hMainWnd);
819 }
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:70
void registry_set_filelist(LPCWSTR newFile, HWND hMainWnd)
Definition: registry.c:269
#define CloseHandle
Definition: compat.h:398
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define DWORD_PTR
Definition: treelist.c:76
static void ShowOpenError(DWORD Code)
Definition: wordpad.c:747
#define SF_RTF
Definition: richedit.h:721
static void set_fileformat(WPARAM format)
Definition: wordpad.c:738
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static void update_font_list(void)
Definition: wordpad.c:423
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
static HWND hEditorWnd
Definition: wordpad.c:60
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FILE_SHARE_READ
Definition: compat.h:125
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
UINT_PTR WPARAM
Definition: windef.h:207
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
EDITSTREAMCALLBACK pfnCallback
Definition: richedit.h:524
LONG_PTR LPARAM
Definition: windef.h:208
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#define EM_STREAMIN
Definition: richedit.h:106
#define SF_TEXT
Definition: richedit.h:720
static DWORD CALLBACK stream_in(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
Definition: wordpad.c:182
unsigned long DWORD
Definition: ntddk_ex.h:95
static HWND hMainWnd
Definition: wordpad.c:59
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
#define EM_SETMODIFY
Definition: winuser.h:1974
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned char BYTE
Definition: ntddk_ex.h:96
#define FILE_BEGIN
Definition: winbase.h:112
static const WCHAR wszAppTitle[]
Definition: wordpad.c:50
#define lstrcpyW
Definition: compat.h:406
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD_PTR dwCookie
Definition: richedit.h:522
#define MB_OK
Definition: winuser.h:784
#define STRING_OLE_STORAGE_NOT_SUPPORTED
Definition: wordpad.h:240
#define CreateFileW
Definition: compat.h:400
static void clear_formatting(void)
Definition: wordpad.c:447
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:136
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define es
Definition: i386-dis.c:431
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
static void set_caption(LPCWSTR wszNewFileName)
Definition: wordpad.c:227
struct CFHEADER header
Definition: fdi.c:109
#define SF_UNICODE
Definition: richedit.h:724

◆ DoSaveFile()

static BOOL DoSaveFile ( LPCWSTR  wszSaveFileName,
WPARAM  format 
)
static

Definition at line 837 of file wordpad.c.

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

838 {
839  HANDLE hFile;
841  LRESULT ret;
842 
843  hFile = CreateFileW(wszSaveFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
845 
846  if(hFile == INVALID_HANDLE_VALUE)
847  {
849  return FALSE;
850  }
851 
852  if(format == (SF_TEXT | SF_UNICODE))
853  {
854  static const BYTE unicode[] = {0xff,0xfe};
855  DWORD writeOut;
856  WriteFile(hFile, &unicode, sizeof(unicode), &writeOut, 0);
857 
858  if(writeOut != sizeof(unicode))
859  {
860  CloseHandle(hFile);
861  return FALSE;
862  }
863  }
864 
865  stream.dwCookie = (DWORD_PTR)hFile;
866  stream.pfnCallback = stream_out;
867 
868  ret = SendMessageW(hEditorWnd, EM_STREAMOUT, format, (LPARAM)&stream);
869 
870  CloseHandle(hFile);
871 
873 
874  if(!ret)
875  {
876  GETTEXTLENGTHEX gt;
877  gt.flags = GTL_DEFAULT;
878  gt.codepage = 1200;
879 
881  return FALSE;
882  }
883 
884  lstrcpyW(wszFileName, wszSaveFileName);
888 
889  return TRUE;
890 }
#define GTL_DEFAULT
Definition: richedit.h:1054
static void ShowWriteError(DWORD Code)
Definition: wordpad.c:821
static WCHAR wszFileName[MAX_PATH]
Definition: wordpad.c:70
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define DWORD_PTR
Definition: treelist.c:76
static void set_fileformat(WPARAM format)
Definition: wordpad.c:738
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
static HWND hEditorWnd
Definition: wordpad.c:60
static DWORD CALLBACK stream_out(DWORD_PTR cookie, LPBYTE buffer, LONG cb, LONG *pcb)
Definition: wordpad.c:195
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
UINT_PTR WPARAM
Definition: windef.h:207
EDITSTREAMCALLBACK pfnCallback
Definition: richedit.h:524
LONG_PTR LPARAM
Definition: windef.h:208
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define SF_TEXT
Definition: richedit.h:720
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
GLuint GLuint stream
Definition: glext.h:7522
#define EM_SETMODIFY
Definition: winuser.h:1974
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned char BYTE
Definition: ntddk_ex.h:96
#define EM_STREAMOUT
Definition: richedit.h:107
#define CREATE_ALWAYS
Definition: disk.h:72
#define lstrcpyW
Definition: compat.h:406
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD_PTR dwCookie
Definition: richedit.h:522
#define CreateFileW
Definition: compat.h:400
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
LONG_PTR LRESULT
Definition: windef.h:209
static void set_caption(LPCWSTR wszNewFileName)
Definition: wordpad.c:227
#define SF_UNICODE
Definition: richedit.h:724

◆ enum_font_proc()

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

Definition at line 614 of file wordpad.c.

Referenced by populate_font_list().

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

◆ file_basename()

LPWSTR file_basename ( LPWSTR  path)

Definition at line 211 of file wordpad.c.

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

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

◆ fileformat_flags()

static WPARAM fileformat_flags ( int  format)
static

Definition at line 471 of file wordpad.c.

Referenced by DialogSaveFile(), and newfile_proc().

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

◆ fileformat_number()

static int fileformat_number ( WPARAM  format)
static

Definition at line 457 of file wordpad.c.

Referenced by DialogOpenFile(), and DialogSaveFile().

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

◆ formatopts_proc()

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

Definition at line 1007 of file wordpad.c.

Referenced by dialog_viewproperties().

1008 {
1009  switch(message)
1010  {
1011  case WM_INITDIALOG:
1012  {
1014  int wrap = -1;
1015  char id[4];
1016  HWND hIdWnd = GetDlgItem(hWnd, IDC_PAGEFMT_ID);
1017 
1018  sprintf(id, "%d\n", (int)ps->lParam);
1019  SetWindowTextA(hIdWnd, id);
1020  if(wordWrap[ps->lParam] == ID_WORDWRAP_NONE)
1021  wrap = IDC_PAGEFMT_WN;
1022  else if(wordWrap[ps->lParam] == ID_WORDWRAP_WINDOW)
1023  wrap = IDC_PAGEFMT_WW;
1024  else if(wordWrap[ps->lParam] == ID_WORDWRAP_MARGIN)
1025  wrap = IDC_PAGEFMT_WM;
1026 
1027  if(wrap != -1)
1029  IDC_PAGEFMT_WM, wrap);
1030 
1031  if(barState[ps->lParam] & (1 << BANDID_TOOLBAR))
1033  if(barState[ps->lParam] & (1 << BANDID_FORMATBAR))
1035  if(barState[ps->lParam] & (1 << BANDID_RULER))
1037  if(barState[ps->lParam] & (1 << BANDID_STATUSBAR))
1039  }
1040  break;
1041 
1042  case WM_COMMAND:
1043  switch(LOWORD(wParam))
1044  {
1045  case IDC_PAGEFMT_WN:
1046  case IDC_PAGEFMT_WW:
1047  case IDC_PAGEFMT_WM:
1049  LOWORD(wParam));
1050  break;
1051 
1052  case IDC_PAGEFMT_TB:
1053  case IDC_PAGEFMT_FB:
1054  case IDC_PAGEFMT_RU:
1055  case IDC_PAGEFMT_SB:
1056  CheckDlgButton(hWnd, LOWORD(wParam),
1057  !IsDlgButtonChecked(hWnd, LOWORD(wParam)));
1058  break;
1059  }
1060  break;
1061  case WM_NOTIFY:
1062  {
1064  if(header->code == PSN_APPLY)
1065  {
1066  HWND hIdWnd = GetDlgItem(hWnd, IDC_PAGEFMT_ID);
1067  char sid[4];
1068  int id;
1069 
1070  GetWindowTextA(hIdWnd, sid, 4);
1071  id = atoi(sid);
1074  else if(IsDlgButtonChecked(hWnd, IDC_PAGEFMT_WW))
1076  else if(IsDlgButtonChecked(hWnd, IDC_PAGEFMT_WM))
1078 
1080  barState[id] |= (1 << BANDID_TOOLBAR);
1081  else
1082  barState[id] &= ~(1 << BANDID_TOOLBAR);
1083 
1085  barState[id] |= (1 << BANDID_FORMATBAR);
1086  else
1087  barState[id] &= ~(1 << BANDID_FORMATBAR);
1088 
1090  barState[id] |= (1 << BANDID_RULER);
1091  else
1092  barState[id] &= ~(1 << BANDID_RULER);
1093 
1095  barState[id] |= (1 << BANDID_STATUSBAR);
1096  else
1097  barState[id] &= ~(1 << BANDID_STATUSBAR);
1098  }
1099  }
1100  break;
1101  }
1102  return FALSE;
1103 }
#define ID_WORDWRAP_MARGIN
Definition: wordpad.h:112
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define ID_WORDWRAP_NONE
Definition: wordpad.h:110
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1296
#define IDC_PAGEFMT_WM
Definition: wordpad.h:126
#define ID_WORDWRAP_WINDOW
Definition: wordpad.h:111
static DWORD wordWrap[2]
Definition: wordpad.c:66
#define BANDID_STATUSBAR
Definition: wordpad.h:97
FT_UInt sid
Definition: cffcmap.c:139
static DWORD barState[2]
Definition: wordpad.c:67
#define BANDID_TOOLBAR
Definition: wordpad.h:94
#define BANDID_FORMATBAR
Definition: wordpad.h:95
#define PSN_APPLY
Definition: prsht.h:117
WPARAM wParam
Definition: combotst.c:138
struct tagNMHDR * LPNMHDR
UINT code
Definition: winuser.h:3112
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define BANDID_RULER
Definition: wordpad.h:96
#define IDC_PAGEFMT_RU
Definition: wordpad.h:122
struct _PROPSHEETPAGEW * LPPROPSHEETPAGEW
#define IDC_PAGEFMT_FB
Definition: wordpad.h:121
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
#define IDC_PAGEFMT_WW
Definition: wordpad.h:125
#define IDC_PAGEFMT_SB
Definition: wordpad.h:123
LPARAM lParam
Definition: prsht.h:218
#define WM_COMMAND
Definition: winuser.h:1716
#define IDC_PAGEFMT_ID
Definition: wordpad.h:127
#define IDC_PAGEFMT_WN
Definition: wordpad.h:124
#define IDC_PAGEFMT_TB
Definition: wordpad.h:120
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
GLenum GLuint id
Definition: glext.h:5579
#define wrap(journal, var)
Definition: recovery.c:207
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
struct CFHEADER header
Definition: fdi.c:109
#define WM_NOTIFY
Definition: richedit.h:61

◆ get_comboexlist_selection()

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

Definition at line 1383 of file wordpad.c.

Referenced by OnCommand().

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

◆ handle_findmsg()

static LRESULT handle_findmsg ( LPFINDREPLACEW  pFr)
static

Definition at line 1204 of file wordpad.c.

Referenced by OnCommand(), and WndProc().

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

◆ HandleCommandLine()

static void HandleCommandLine ( LPWSTR  cmdline)
static

Definition at line 1151 of file wordpad.c.

Referenced by WinMain().

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

◆ is_bar_visible()

static BOOL is_bar_visible ( int  bandId)
static

Definition at line 659 of file wordpad.c.

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

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

◆ MessageBoxWithResStringW()

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

Definition at line 136 of file wordpad.c.

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

137 {
139 
140  params.cbSize = sizeof(params);
141  params.hwndOwner = hWnd;
142  params.hInstance = GetModuleHandleW(0);
143  params.lpszText = lpText;
144  params.lpszCaption = lpCaption;
145  params.dwStyle = uType;
146  params.lpszIcon = NULL;
147  params.dwContextHelpId = 0;
148  params.lpfnMsgBoxCallback = NULL;
149  params.dwLanguageId = 0;
150  return MessageBoxIndirectW(&params);
151 }
DWORD dwLanguageId
Definition: winuser.h:3287
HWND hWnd
Definition: settings.c:17
LPCWSTR lpszText
Definition: winuser.h:3281
GLenum const GLfloat * params
Definition: glext.h:5645
LPCWSTR lpszIcon
Definition: winuser.h:3284
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszCaption
Definition: winuser.h:3282
DWORD_PTR dwContextHelpId
Definition: winuser.h:3285
HWND hwndOwner
Definition: winuser.h:3279
HINSTANCE hInstance
Definition: winuser.h:3280
MSGBOXCALLBACK lpfnMsgBoxCallback
Definition: winuser.h:3286
int WINAPI MessageBoxIndirectW(_In_ CONST MSGBOXPARAMSW *)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
DWORD dwStyle
Definition: winuser.h:3283

◆ newfile_proc()

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

Definition at line 1468 of file wordpad.c.

Referenced by OnCommand().

1469 {
1470  switch(message)
1471  {
1472  case WM_INITDIALOG:
1473  {
1476  HWND hListWnd = GetDlgItem(hWnd, IDC_NEWFILE);
1477 
1478  LoadStringW(hInstance, STRING_NEWFILE_RICHTEXT, buffer, MAX_STRING_LEN);
1479  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1480  LoadStringW(hInstance, STRING_NEWFILE_TXT, buffer, MAX_STRING_LEN);
1481  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1483  SendMessageW(hListWnd, LB_ADDSTRING, 0, (LPARAM)&buffer);
1484 
1485  SendMessageW(hListWnd, LB_SETSEL, TRUE, 0);
1486  }
1487  break;
1488 
1489  case WM_COMMAND:
1490  switch(LOWORD(wParam))
1491  {
1492  case IDOK:
1493  {
1494  LRESULT index;
1495  HWND hListWnd = GetDlgItem(hWnd, IDC_NEWFILE);
1496  index = SendMessageW(hListWnd, LB_GETCURSEL, 0, 0);
1497 
1498  if(index != LB_ERR)
1499  EndDialog(hWnd, MAKELONG(fileformat_flags(index),0));
1500  }
1501  return TRUE;
1502 
1503  case IDCANCEL:
1505  return TRUE;
1506  }
1507  }
1508  return FALSE;
1509 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define STRING_NEWFILE_RICHTEXT
Definition: wordpad.h:204
#define LB_ADDSTRING
Definition: winuser.h:1992
#define LB_SETSEL
Definition: winuser.h:2029
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint buffer
Definition: glext.h:5915
#define MAX_STRING_LEN
Definition: precomp.h:36
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define LB_ERR
Definition: winuser.h:2386
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define ID_NEWFILE_ABORT
Definition: wordpad.h:114
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HINSTANCE hInstance
Definition: wordpad.c:3
static WPARAM fileformat_flags(int format)
Definition: wordpad.c:471
#define index(s, c)
Definition: various.h:29
#define WM_COMMAND
Definition: winuser.h:1716
#define STRING_NEWFILE_TXT_UNICODE
Definition: wordpad.h:206
#define IDC_NEWFILE
Definition: wordpad.h:162
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETCURSEL
Definition: winuser.h:2000
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_INITDIALOG
Definition: winuser.h:1715
#define LOWORD(l)
Definition: pedump.c:82
#define STRING_NEWFILE_TXT
Definition: wordpad.h:205

◆ number_from_string()

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

Definition at line 294 of file wordpad.c.

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

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

◆ number_with_units()

static void number_with_units ( LPWSTR  buffer,
int  number 
)
static

Definition at line 1375 of file wordpad.c.

Referenced by paraformat_proc(), and tabstops_proc().

1376 {
1377  static const WCHAR fmt[] = {'%','.','2','f',' ','%','s','\0'};
1378  float converted = (float)number / (float)TWIPS_PER_INCH *(float)CENTMM_PER_INCH / 1000.0;
1379 
1380  sprintfW(buffer, fmt, converted, units_cmW);
1381 }
#define CENTMM_PER_INCH
Definition: wordpad.h:25
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint buffer
Definition: glext.h:5915
static WCHAR units_cmW[MAX_STRING_LEN]
Definition: wordpad.c:74
static size_t double number
Definition: printf.c:64
#define TWIPS_PER_INCH
Definition: wordpad.h:24
#define sprintfW
Definition: unicode.h:58
Definition: dsound.c:943

◆ on_fontlist_modified()

static void on_fontlist_modified ( LPWSTR  wszNewFaceName)
static

Definition at line 524 of file wordpad.c.

Referenced by OnCommand(), and OnNotify().

525 {
527  ZeroMemory(&format, sizeof(format));
528  format.cbSize = sizeof(format);
530 
531  if(lstrcmpW(format.szFaceName, wszNewFaceName))
532  set_font(wszNewFaceName);
533 }
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define ZeroMemory
Definition: winbase.h:1635
static HWND hEditorWnd
Definition: wordpad.c:60
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
LONG_PTR LPARAM
Definition: windef.h:208
WCHAR szFaceName[LF_FACESIZE]
Definition: richedit.h:313
#define EM_GETCHARFORMAT
Definition: richedit.h:91
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static void set_font(LPCWSTR wszFaceName)
Definition: wordpad.c:478
#define SCF_SELECTION
Definition: richedit.h:235

◆ on_sizelist_modified()

static void on_sizelist_modified ( HWND  hwndSizeList,
LPWSTR  wszNewFontSize 
)
static

Definition at line 326 of file wordpad.c.

Referenced by OnCommand(), and OnNotify().

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

◆ OnCommand()

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

Definition at line 2051 of file wordpad.c.

Referenced by WndProc().

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

◆ OnCreate()

static LRESULT OnCreate ( HWND  hWnd)
static

Definition at line 1788 of file wordpad.c.

Referenced by WndProc().

1789 {
1790  HWND hToolBarWnd, hFormatBarWnd, hReBarWnd, hFontListWnd, hSizeListWnd, hRulerWnd;
1792  HANDLE hDLL;
1793  TBADDBITMAP ab;
1794  int nStdBitmaps = 0;
1795  REBARINFO rbi;
1796  REBARBANDINFOW rbb;
1797  static const WCHAR wszRichEditDll[] = {'R','I','C','H','E','D','2','0','.','D','L','L','\0'};
1798  static const WCHAR wszRichEditText[] = {'R','i','c','h','E','d','i','t',' ','t','e','x','t','\0'};
1799 
1801 
1804  CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hWnd, (HMENU)IDC_REBAR, hInstance, NULL);
1805 
1806  rbi.cbSize = sizeof(rbi);
1807  rbi.fMask = 0;
1808  rbi.himl = NULL;
1809  if(!SendMessageW(hReBarWnd, RB_SETBARINFO, 0, (LPARAM)&rbi))
1810  return -1;
1811 
1813  IDC_TOOLBAR,
1814  1, hInstance, IDB_TOOLBAR,
1815  NULL, 0,
1816  24, 24, 16, 16, sizeof(TBBUTTON));
1817 
1818  ab.hInst = HINST_COMMCTRL;
1819  ab.nID = IDB_STD_SMALL_COLOR;
1820  nStdBitmaps = SendMessageW(hToolBarWnd, TB_ADDBITMAP, 0, (LPARAM)&ab);
1821 
1822  AddButton(hToolBarWnd, nStdBitmaps+STD_FILENEW, ID_FILE_NEW);
1823  AddButton(hToolBarWnd, nStdBitmaps+STD_FILEOPEN, ID_FILE_OPEN);
1824  AddButton(hToolBarWnd, nStdBitmaps+STD_FILESAVE, ID_FILE_SAVE);
1825  AddSeparator(hToolBarWnd);
1826  AddButton(hToolBarWnd, nStdBitmaps+STD_PRINT, ID_PRINT_QUICK);
1827  AddButton(hToolBarWnd, nStdBitmaps+STD_PRINTPRE, ID_PREVIEW);
1828  AddSeparator(hToolBarWnd);
1829  AddButton(hToolBarWnd, nStdBitmaps+STD_FIND, ID_FIND);
1830  AddSeparator(hToolBarWnd);
1831  AddButton(hToolBarWnd, nStdBitmaps+STD_CUT, ID_EDIT_CUT);
1832  AddButton(hToolBarWnd, nStdBitmaps+STD_COPY, ID_EDIT_COPY);
1833  AddButton(hToolBarWnd, nStdBitmaps+STD_PASTE, ID_EDIT_PASTE);
1834  AddButton(hToolBarWnd, nStdBitmaps+STD_UNDO, ID_EDIT_UNDO);
1835  AddButton(hToolBarWnd, nStdBitmaps+STD_REDOW, ID_EDIT_REDO);
1836  AddSeparator(hToolBarWnd);
1837  AddButton(hToolBarWnd, 0, ID_DATETIME);
1838 
1839  SendMessageW(hToolBarWnd, TB_AUTOSIZE, 0, 0);
1840 
1844  rbb.cx = 0;
1845  rbb.hwndChild = hToolBarWnd;
1846  rbb.cxMinChild = 0;
1847  rbb.cyChild = rbb.cyMinChild = HIWORD(SendMessageW(hToolBarWnd, TB_GETBUTTONSIZE, 0, 0));
1848  rbb.wID = BANDID_TOOLBAR;
1849 
1850  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1851 
1852  hFontListWnd = CreateWindowExW(0, WC_COMBOBOXEXW, NULL,
1854  0, 0, 200, 150, hReBarWnd, (HMENU)IDC_FONTLIST, hInstance, NULL);
1855 
1856  rbb.hwndChild = hFontListWnd;
1857  rbb.cx = 200;
1858  rbb.wID = BANDID_FONTLIST;
1859 
1860  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1861 
1862  hSizeListWnd = CreateWindowExW(0, WC_COMBOBOXEXW, NULL,
1864  0, 0, 50, 150, hReBarWnd, (HMENU)IDC_SIZELIST, hInstance, NULL);
1865 
1866  rbb.hwndChild = hSizeListWnd;
1867  rbb.cx = 50;
1868  rbb.fStyle ^= RBBS_BREAK;
1869  rbb.wID = BANDID_SIZELIST;
1870 
1871  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1872 
1873  hFormatBarWnd = CreateToolbarEx(hReBarWnd,
1875  IDC_FORMATBAR, 8, hInstance, IDB_FORMATBAR, NULL, 0, 16, 16, 16, 16, sizeof(TBBUTTON));
1876 
1877  AddButton(hFormatBarWnd, 0, ID_FORMAT_BOLD);
1878  AddButton(hFormatBarWnd, 1, ID_FORMAT_ITALIC);
1879  AddButton(hFormatBarWnd, 2, ID_FORMAT_UNDERLINE);
1880  AddButton(hFormatBarWnd, 3, ID_FORMAT_COLOR);
1881  AddSeparator(hFormatBarWnd);
1882  AddButton(hFormatBarWnd, 4, ID_ALIGN_LEFT);
1883  AddButton(hFormatBarWnd, 5, ID_ALIGN_CENTER);
1884  AddButton(hFormatBarWnd, 6, ID_ALIGN_RIGHT);
1885  AddSeparator(hFormatBarWnd);
1886  AddButton(hFormatBarWnd, 7, ID_BULLET);
1887 
1888  SendMessageW(hFormatBarWnd, TB_AUTOSIZE, 0, 0);
1889 
1890  rbb.hwndChild = hFormatBarWnd;
1891  rbb.wID = BANDID_FORMATBAR;
1892 
1893  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1894 
1895  hRulerWnd = CreateWindowExW(0, WC_STATICW, NULL, WS_VISIBLE | WS_CHILD,
1896  0, 0, 200, 10, hReBarWnd, (HMENU)IDC_RULER, hInstance, NULL);
1897 
1898 
1899  rbb.hwndChild = hRulerWnd;
1900  rbb.wID = BANDID_RULER;
1901  rbb.fStyle |= RBBS_BREAK;
1902 
1903  SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb);
1904 
1905  hDLL = LoadLibraryW(wszRichEditDll);
1906  if(!hDLL)
1907  {
1910  PostQuitMessage(1);
1911  }
1912 
1916  0, 0, 1000, 100, hWnd, (HMENU)IDC_EDITOR, hInstance, NULL);
1917 
1918  if (!hEditorWnd)
1919  {
1920  fprintf(stderr, "Error code %u\n", GetLastError());
1921  return -1;
1922  }
1923  assert(hEditorWnd);
1924 
1928 
1929  set_default_font();
1930 
1931  populate_font_list(hFontListWnd);
1932  populate_size_list(hSizeListWnd);
1933  DoLoadStrings();
1935 
1937 
1938  registry_read_filelist(hWnd);
1941  DragAcceptFiles(hWnd, TRUE);
1942 
1943  return 0;
1944 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define CBS_SORT
Definition: winuser.h:292
#define STD_PASTE
Definition: commctrl.h:1043
static void AddSeparator(HWND hwndToolBar)
Definition: wordpad.c:168
#define TRUE
Definition: types.h:120
#define IDC_STATUSBAR
Definition: resource.h:14
#define RBBIM_CHILD
Definition: commctrl.h:1476
#define RBS_VARHEIGHT
Definition: commctrl.h:1441
#define FINDMSGSTRINGW
Definition: commdlg.h:28
#define ID_FORMAT_UNDERLINE
Definition: wordpad.h:81
#define ID_FORMAT_COLOR
Definition: wordpad.h:82
static const WCHAR RICHEDIT_CLASS20W[]
Definition: richedit.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void DoLoadStrings(void)
Definition: wordpad.c:96
#define ENM_SELCHANGE
Definition: richedit.h:478
#define ID_PRINT_QUICK
Definition: wordpad.h:42
static DWORD wordWrap[2]
Definition: wordpad.c:66
#define ES_MULTILINE
Definition: pedump.c:667
#define ID_EDIT_COPY
Definition: resource.h:49
#define RBBS_BREAK
Definition: commctrl.h:1459
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:527
#define RBBIM_ID
Definition: commctrl.h:1480
static void populate_size_list(HWND hSizeListWnd)
Definition: wordpad.c:364
#define IDB_STD_SMALL_COLOR
Definition: commctrl.h:1034
#define assert(x)
Definition: debug.h:53
static DWORD barState[2]
Definition: wordpad.c:67
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define RBBS_CHILDEDGE
Definition: commctrl.h:1461
HWND WINAPI SetFocus(_In_opt_ HWND)
#define ID_FILE_OPEN
Definition: resource.h:42
static HWND hEditorWnd
Definition: wordpad.c:60
#define BANDID_TOOLBAR
Definition: wordpad.h:94
#define ID_FORMAT_BOLD
Definition: wordpad.h:79
#define STD_FILENEW
Definition: commctrl.h:1047
HINSTANCE hInst
Definition: commctrl.h:1029
#define WS_CHILD
Definition: pedump.c:617
#define ID_FIND
Definition: wordpad.h:44
#define BANDID_FORMATBAR
Definition: wordpad.h:95
#define ID_DATETIME
Definition: wordpad.h:129
#define WS_CLIPCHILDREN
Definition: pedump.c:619
HWND WINAPI CreateToolbarEx(HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HINSTANCE hBMInst, UINT_PTR wBMID, LPCTBBUTTON lpButtons, INT iNumButtons, INT dxButton, INT dyButton, INT dxBitmap, INT dyBitmap, UINT uStructSize)
Definition: commctrl.c:929
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define STD_PRINT
Definition: commctrl.h:1055
#define IDC_FONTLIST
Definition: wordpad.h:168
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define ID_ALIGN_RIGHT
Definition: wordpad.h:56
#define REBARBANDINFOW_V6_SIZE
Definition: commctrl.h:1512
#define REBARCLASSNAMEW
Definition: commctrl.h:1433
#define RBBIM_STYLE
Definition: commctrl.h:1472
#define RBBIM_SIZE
Definition: commctrl.h:1478
#define CCS_NODIVIDER
Definition: commctrl.h:2218
#define BTNS_BUTTON
Definition: commctrl.h:968
#define BANDID_RULER
Definition: wordpad.h:96
static void AddButton(HWND hwndToolBar, int nImage, int nCommand)
Definition: wordpad.c:154
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define TB_AUTOSIZE
Definition: commctrl.h:1107
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI CreateStatusWindowW(LONG style, LPCWSTR text, HWND parent, UINT wid)
Definition: commctrl.c:795
#define CW_USEDEFAULT
Definition: winuser.h:225
#define IDC_RULER
Definition: wordpad.h:170
#define ID_EDIT_UNDO
Definition: wordpad.h:68
#define ES_WANTRETURN
Definition: pedump.c:676
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
#define STD_COPY
Definition: commctrl.h:1042
#define CCS_TOP
Definition: commctrl.h:2212
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2216
#define RB_INSERTBANDW
Definition: commctrl.h:1553
#define IDC_SIZELIST
Definition: wordpad.h:169
#define ES_SELECTIONBAR
Definition: richedit.h:230
UCHAR ab[sizeof("Hello World!") -1]
Definition: fdi.c:114
#define ID_FILE_SAVE
Definition: resource.h:43
#define STRING_LOAD_RICHED_FAILED
Definition: wordpad.h:237
#define RB_SETBARINFO
Definition: commctrl.h:1548
#define EM_SETEVENTMASK
Definition: richedit.h:102
#define IDC_FORMATBAR
Definition: wordpad.h:158
#define STD_REDOW
Definition: commctrl.h:1045
#define ID_FILE_NEW
Definition: resource.h:41
#define TB_GETBUTTONSIZE
Definition: commctrl.h:1130
#define ES_AUTOVSCROLL
Definition: pedump.c:671
static UINT ID_FINDMSGSTRING
Definition: wordpad.c:64
#define ID_BULLET
Definition: wordpad.h:75
#define IDC_EDITOR
Definition: wordpad.h:156
#define ID_ALIGN_CENTER
Definition: wordpad.h:55
#define ID_PREVIEW
Definition: wordpad.h:40
static void set_default_font(void)
Definition: wordpad.c:500
#define ID_FORMAT_ITALIC
Definition: wordpad.h:80
#define IDC_TOOLBAR
Definition: wordpad.h:157
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:959
#define RBBIM_CHILDSIZE
Definition: commctrl.h:1477
#define ID_EDIT_CUT
Definition: wordpad.h:72
HINSTANCE hInstance
Definition: wordpad.c:3
#define ES_NOHIDESEL
Definition: pedump.c:673
#define WS_HSCROLL
Definition: pedump.c:628
#define TB_ADDBITMAP
Definition: commctrl.h:1026
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define STD_PRINTPRE
Definition: commctrl.h:1050
#define EM_SETMODIFY
Definition: winuser.h:1974
HIMAGELIST himl
Definition: commctrl.h:1453
#define ID_EDIT_REDO
Definition: wordpad.h:69
#define BANDID_SIZELIST
Definition: wordpad.h:99
static void populate_font_list(HWND hListWnd)
Definition: wordpad.c:630
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
#define WS_BORDER
Definition: pedump.c:625
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
static const WCHAR wszAppTitle[]
Definition: wordpad.c:50
#define STD_UNDO
Definition: commctrl.h:1044
#define CBS_DROPDOWN
Definition: winuser.h:283
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WC_COMBOBOXEXW
Definition: commctrl.h:3748
#define WS_VSCROLL
Definition: pedump.c:627
#define MB_OK
Definition: winuser.h:784
#define IDB_FORMATBAR
Definition: wordpad.h:184
#define BANDID_FONTLIST
Definition: wordpad.h:98
#define HINST_COMMCTRL
Definition: commctrl.h:1033
#define WC_STATICW
Definition: commctrl.h:4640
#define CCS_NOMOVEY
Definition: commctrl.h:2213
#define RBBS_NOGRIPPER
Definition: commctrl.h:1467
#define STD_FILESAVE
Definition: commctrl.h:1049
#define HIWORD(l)
Definition: typedefs.h:246
#define ID_EDIT_PASTE
Definition: resource.h:50
FILE * stderr
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
HRESULT setup_richedit_olecallback(HWND hEditorWnd)
Definition: olecallback.c:203
#define IDB_TOOLBAR
Definition: wordpad.h:183
static int MessageBoxWithResStringW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
Definition: wordpad.c:136
#define ID_ALIGN_LEFT
Definition: wordpad.h:54
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define STD_FIND
Definition: commctrl.h:1053
#define STD_FILEOPEN
Definition: commctrl.h:1048
#define WS_VISIBLE
Definition: pedump.c:620
void registry_read_filelist(HWND hMainWnd)
Definition: registry.c:217
#define IDC_REBAR
Definition: wordpad.h:159
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
void registry_read_options(void)
Definition: registry.c:335
void registry_read_formatopts_all(DWORD barState[], DWORD wordWrap[])
Definition: registry.c:398
UINT_PTR nID
Definition: commctrl.h:1030
#define STD_CUT
Definition: commctrl.h:1041

◆ OnInitPopupMenu()

static LRESULT OnInitPopupMenu ( HWND  hWnd,
WPARAM  wParam 
)
static

Definition at line 2469 of file wordpad.c.

Referenced by WndProc().

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

◆ OnNotify()

static LRESULT OnNotify ( HWND  hWnd,
LPARAM  lParam 
)
static

Definition at line 1998 of file wordpad.c.

Referenced by CTaskSwitchWnd::ContextSensitiveHelp(), DECLARE_INTERFACE_(), CShellBrowser::GetWindowProc(), and WndProc().

1999 {
2000  HWND hwndEditor = GetDlgItem(hWnd, IDC_EDITOR);
2001  HWND hwndReBar = GetDlgItem(hWnd, IDC_REBAR);
2002  NMHDR *pHdr = (NMHDR *)lParam;
2003  HWND hwndFontList = GetDlgItem(hwndReBar, IDC_FONTLIST);
2004  HWND hwndSizeList = GetDlgItem(hwndReBar, IDC_SIZELIST);
2005 
2006  if (pHdr->hwndFrom == hwndFontList || pHdr->hwndFrom == hwndSizeList)
2007  {
2008  if (pHdr->code == CBEN_ENDEDITW)
2009  {
2010  NMCBEENDEDITW *endEdit = (NMCBEENDEDITW *)lParam;
2011  if(pHdr->hwndFrom == hwndFontList)
2012  {
2013  on_fontlist_modified(endEdit->szText);
2014  } else if (pHdr->hwndFrom == hwndSizeList)
2015  {
2016  on_sizelist_modified(hwndSizeList,endEdit->szText);
2017  }
2018  }
2019  return 0;
2020  }
2021 
2022  if (pHdr->hwndFrom != hwndEditor)
2023  return 0;
2024 
2025  if (pHdr->code == EN_SELCHANGE)
2026  {
2027  SELCHANGE *pSC = (SELCHANGE *)lParam;
2028  char buf[128];
2029 
2030  update_font_list();
2031 
2032  sprintf( buf,"selection = %d..%d, line count=%ld",
2033  pSC->chrg.cpMin, pSC->chrg.cpMax,
2034  SendMessageW(hwndEditor, EM_GETLINECOUNT, 0, 0));
2036  SendMessageW(hWnd, WM_USER, 0, 0);
2037  return 1;
2038  }
2039  return 0;
2040 }
#define IDC_STATUSBAR
Definition: resource.h:14
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define EN_SELCHANGE
Definition: richedit.h:193
static void update_font_list(void)
Definition: wordpad.c:423
LONG cpMax
Definition: richedit.h:501
#define IDC_FONTLIST
Definition: wordpad.h:168
UINT code
Definition: winuser.h:3112
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define IDC_SIZELIST
Definition: wordpad.h:169
static void on_fontlist_modified(LPWSTR wszNewFaceName)
Definition: wordpad.c:524
#define CBEN_ENDEDITW
Definition: commctrl.h:3843
#define IDC_EDITOR
Definition: wordpad.h:156
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
HWND hwndFrom
Definition: winuser.h:3110
#define WM_USER
Definition: winuser.h:1856
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)