EditWindow.h 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  1. #ifndef __EditWindow_h__
  2. #define __EditWindow_h__
  3. /////////////////////////////////////////////////////////////////////////////
  4. // EditWindow.h | Declaration of the TCEditWindow class.
  5. #include <malloc.h>
  6. /////////////////////////////////////////////////////////////////////////////
  7. // TCEditWindow is a derivation of the ATL CWindowImpl template that
  8. // provides an encapsulation of a Windows edit control. It is closely modeled
  9. // after the MFC CEdit class. You should refer to that documentation for any
  10. // information missing from this class overview, such as notifications sent
  11. // from the control.
  12. //
  13. // The TCEditWindow class provides the functionality of a Windows edit
  14. // control. An edit control is a rectangular child window in which the user
  15. // can enter text.
  16. //
  17. // TCEditWindow inherits significant functionality from CWindowImpl, which
  18. // inherits from CWindow. To set and retrieve text from an TCEditWindow
  19. // object, use the CWindow member functions *SetWindowText* and
  20. // *GetWindowText*, which set or get the entire contents of an edit control,
  21. // even if it is a multiline control. Also, if an edit control is multiline,
  22. // you can get and set only part of the control's text by calling the
  23. // TCEditWindow member functions GetLine, SetSel, GetSel, and ReplaceSel.
  24. //
  25. // See Also: ATL::CWindowImpl, ATL::CWindow, CEdit (MFC)
  26. class TCEditWindow : public CWindowImpl<TCEditWindow>
  27. {
  28. // Group=Types
  29. public:
  30. // Declares a type definition to allow derived classes an easier way to
  31. // refer to the base class.
  32. typedef CWindowImpl<TCEditWindow> TCEditWindow_Base;
  33. // Declarations
  34. public:
  35. DECLARE_WND_SUPERCLASS(NULL, TEXT("EDIT"))
  36. // Message Map
  37. public:
  38. BEGIN_MSG_MAP(TCEditWindow)
  39. END_MSG_MAP()
  40. // Attributes / Operations
  41. public:
  42. BOOL CanUndo() const;
  43. int GetLineCount() const;
  44. BOOL GetModify() const;
  45. void SetModify(BOOL bModified = TRUE);
  46. void GetRect(LPRECT lpRect) const;
  47. void GetSel(int& nStartChar, int& nEndChar) const;
  48. DWORD GetSel() const;
  49. HLOCAL GetHandle() const;
  50. void SetHandle(HLOCAL hBuffer);
  51. int GetLine(int nIndex, BSTR* pbstr) const;
  52. int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const;
  53. void EmptyUndoBuffer();
  54. BOOL FmtLines(BOOL bAddEOL);
  55. void LimitText(int nChars = 0);
  56. int LineFromChar(int nIndex = -1) const;
  57. int LineIndex(int nLine = -1) const;
  58. int LineLength(int nLine = -1) const;
  59. void LineScroll(int nLines, int nChars = 0);
  60. void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo = FALSE);
  61. void SetPasswordChar(TCHAR ch);
  62. void SetRect(LPCRECT lpRect);
  63. void SetRectNP(LPCRECT lpRect);
  64. void SetSel(DWORD dwSelection, BOOL bNoScroll = FALSE);
  65. void SetSel(int nStartChar, int nEndChar, BOOL bNoScroll = FALSE);
  66. BOOL SetTabStops(int nTabStops, LPINT rgTabStops);
  67. void SetTabStops();
  68. BOOL SetTabStops(const int& cxEachStop); // takes an 'int'
  69. BOOL Undo();
  70. void Clear();
  71. void Copy();
  72. void Cut();
  73. void Paste();
  74. BOOL SetReadOnly(BOOL bReadOnly = TRUE);
  75. int GetFirstVisibleLine() const;
  76. TCHAR GetPasswordChar() const;
  77. void SetMargins(UINT nLeft, UINT nRight);
  78. DWORD GetMargins() const;
  79. void SetLimitText(UINT nMax);
  80. UINT GetLimitText() const;
  81. POINT PosFromChar(UINT nChar) const;
  82. int CharFromPos(POINT pt) const;
  83. // Operators
  84. public:
  85. const TCEditWindow& operator=(HWND hwnd);
  86. };
  87. /////////////////////////////////////////////////////////////////////////////
  88. // Group=Attributes / Operations
  89. /////////////////////////////////////////////////////////////////////////////
  90. // Description: Determines whether an edit-control operation can be undone.
  91. //
  92. // Call this function to determine if the last edit operation can be undone.
  93. //
  94. // Return Value: Nonzero if the last edit operation can be undone by a call
  95. // to the Undo member function; 0 if it cannot be undone.
  96. //
  97. // See Also: TCEditWindow::Undo, TCEditWindow::EmptyUndoBuffer, EM_CANUNDO
  98. inline BOOL TCEditWindow::CanUndo() const
  99. {
  100. assert(::IsWindow(m_hWnd));
  101. return (BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0);
  102. }
  103. /////////////////////////////////////////////////////////////////////////////
  104. // Description: Retrieves the number of lines in a multiple-line edit
  105. // control.
  106. //
  107. // Call this function to retrieve the number of lines in a multiple-line edit
  108. // control.
  109. //
  110. // GetLineCount is only processed by multiple-line edit controls.
  111. //
  112. // Return Value: An integer containing the number of lines in the
  113. // multiple-line edit control. If no text has been entered into the edit
  114. // control, the return value is 1.
  115. //
  116. // See Also: EM_GETLINECOUNT
  117. inline int TCEditWindow::GetLineCount() const
  118. {
  119. assert(::IsWindow(m_hWnd));
  120. return (int)::SendMessage(m_hWnd, EM_GETLINECOUNT, 0, 0);
  121. }
  122. /////////////////////////////////////////////////////////////////////////////
  123. // Description: Determines whether the contents of an edit control have been
  124. // modified.
  125. //
  126. // Call this function to determine whether the contents of an edit control
  127. // have been modified.
  128. //
  129. // Windows maintains an internal flag indicating whether the contents of the
  130. // edit control have been changed. This flag is cleared when the edit control
  131. // is first created and may also be cleared by calling the SetModify member
  132. // function.
  133. //
  134. // Return Value: Nonzero if the edit-control contents have been modified; 0
  135. // if they have remained unchanged.
  136. //
  137. // See Also: TCEditWindow::SetModify, EM_GETMODIFY
  138. inline BOOL TCEditWindow::GetModify() const
  139. {
  140. assert(::IsWindow(m_hWnd));
  141. return (BOOL)::SendMessage(m_hWnd, EM_GETMODIFY, 0, 0);
  142. }
  143. /////////////////////////////////////////////////////////////////////////////
  144. // Description: Sets or clears the modification flag for an edit control.
  145. //
  146. // Call this function to set or clear the modified flag for an edit control.
  147. // The modified flag indicates whether or not the text within the edit
  148. // control has been modified. It is automatically set whenever the user
  149. // changes the text. Its value may be retrieved with the GetModify member
  150. // function.
  151. //
  152. // Parameters:
  153. // bModified - A value of *TRUE* indicates that the text has been modified,
  154. // and a value of *FALSE* indicates it is unmodified. By default, the
  155. // modified flag is set.
  156. //
  157. //
  158. // See Also: TCEditWindow::GetModify, EM_SETMODIFY
  159. inline void TCEditWindow::SetModify(BOOL bModified)
  160. {
  161. assert(::IsWindow(m_hWnd));
  162. ::SendMessage(m_hWnd, EM_SETMODIFY, bModified, 0);
  163. }
  164. /////////////////////////////////////////////////////////////////////////////
  165. // Description: Gets the formatting rectangle of an edit control.
  166. //
  167. // Call this function to get the formatting rectangle of an edit control.
  168. // The formatting rectangle is the limiting rectangle of the text, which is
  169. // independent of the size of the edit-control window.
  170. //
  171. // The formatting rectangle of a multiple-line edit control can be modified
  172. // by the SetRect and SetRectNP member functions.
  173. //
  174. // Parameters:
  175. // lpRect - Points to the *RECT* structure that receives the formatting
  176. // rectangle.
  177. //
  178. // See Also: TCEditWindow::SetRect, TCEditWindow::SetRectNP, EM_GETRECT
  179. inline void TCEditWindow::GetRect(LPRECT lpRect) const
  180. {
  181. assert(::IsWindow(m_hWnd));
  182. ::SendMessage(m_hWnd, EM_GETRECT, 0, (LPARAM)lpRect);
  183. }
  184. /////////////////////////////////////////////////////////////////////////////
  185. // Description: Gets the starting and ending character positions of the
  186. // current selection in an edit control.
  187. //
  188. // Call this function to get the starting and ending character positions of
  189. // the current selection (if any) in an edit control, using either the return
  190. // value or the parameters.
  191. //
  192. // Parameters:
  193. // nStartChar - Reference to an integer that will receive the position of
  194. // the first character in the current selection.
  195. // nEndChar - Reference to an integer that will receive the position of the
  196. // first nonselected character past the end of the current selection.
  197. //
  198. // See Also: TCEditWindow::SetSel, EM_GETSEL
  199. inline void TCEditWindow::GetSel(int& nStartChar, int& nEndChar) const
  200. {
  201. assert(::IsWindow(m_hWnd));
  202. ::SendMessage(m_hWnd, EM_GETSEL, (WPARAM)&nStartChar,(LPARAM)&nEndChar);
  203. }
  204. /////////////////////////////////////////////////////////////////////////////
  205. // Return Value: The version that returns a DWORD returns a value that
  206. // contains the starting position in the low-order word and the position of
  207. // the first nonselected character after the end of the selection in the
  208. // high-order word.
  209. inline DWORD TCEditWindow::GetSel() const
  210. {
  211. assert(::IsWindow(m_hWnd));
  212. return ::SendMessage(m_hWnd, EM_GETSEL, 0, 0);
  213. }
  214. /////////////////////////////////////////////////////////////////////////////
  215. // Description: Retrieves a handle to the memory currently allocated for a
  216. // multiple-line edit control.
  217. //
  218. // Call this function to retrieve a handle to the memory currently allocated
  219. // for a multiple-line edit control. The handle is a local memory handle and
  220. // may be used by any of the Local Windows memory functions that take a local
  221. // memory handle as a parameter.
  222. //
  223. // GetHandle is processed only by multiple-line edit controls.
  224. //
  225. // Call GetHandle for a multiple-line edit control in a dialog box only if
  226. // the dialog box was created with the *DS_LOCALEDIT* style flag set. If the
  227. // *DS_LOCALEDIT* style is not set, you will still get a nonzero return
  228. // value, but you will not be able to use the returned value.
  229. //
  230. // Return Value: A local memory handle that identifies the buffer holding the
  231. // contents of the edit control. If an error occurs, such as sending the
  232. // message to a single-line edit control, the return value is 0.
  233. //
  234. // See Also: TCEditWindow::SetHandle, EM_GETHANDLE
  235. inline HLOCAL TCEditWindow::GetHandle() const
  236. {
  237. assert(::IsWindow(m_hWnd));
  238. return (HLOCAL)::SendMessage(m_hWnd, EM_GETHANDLE, 0, 0);
  239. }
  240. /////////////////////////////////////////////////////////////////////////////
  241. // Description: Sets the handle to the local memory that will be used by a
  242. // multiple-line edit control.
  243. //
  244. // Call this function to set the handle to the local memory that will be used
  245. // by a multiple-line edit control. The edit control will then use this
  246. // buffer to store the currently displayed text instead of allocating its own
  247. // buffer.
  248. //
  249. // This member function is processed only by multiple-line edit controls.
  250. //
  251. // Before an application sets a new memory handle, it should use the
  252. // GetHandle member function to get the handle to the current memory buffer
  253. // and free that memory using the *LocalFree* Windows function.
  254. //
  255. // SetHandle clears the undo buffer (the CanUndo member function then returns
  256. // 0) and the internal modification flag (the GetModify member function then
  257. // returns 0). The edit-control window is redrawn.
  258. //
  259. // You can use this member function in a multiple-line edit control in a
  260. // dialog box only if you have created the dialog box with the
  261. // *DS_LOCALEDIT* style flag set.
  262. //
  263. // Parameters:
  264. // hBuffer - Contains a handle to the local memory. This handle must have
  265. // been created by a previous call to the *LocalAlloc* Windows function using
  266. // the *LMEM_MOVEABLE* flag. The memory is assumed to contain a
  267. // null-terminated string. If this is not the case, the first byte of the
  268. // allocated memory should be set to 0.
  269. //
  270. // See Also: TCEditWindow::CanUndo, TCEditWindow::GetHandle,
  271. // TCEditWindow::GetModify, EM_SETHANDLE, LocalAlloc, LocalFree
  272. inline void TCEditWindow::SetHandle(HLOCAL hBuffer)
  273. {
  274. assert(::IsWindow(m_hWnd));
  275. ::SendMessage(m_hWnd, EM_SETHANDLE, (WPARAM)hBuffer, 0);
  276. }
  277. /////////////////////////////////////////////////////////////////////////////
  278. // Description: Retrieves a line of text from an edit control.
  279. //
  280. // Call this function to retrieve a line of text from an edit control. This
  281. // call is not processed for a single-line edit control.
  282. //
  283. // The copied line does not contain a null-termination character.
  284. //
  285. // Parameters:
  286. // nIndex - Specifies the line number to retrieve from a multiple-line edit
  287. // control. Line numbers are zero-based; a value of 0 specifies the first
  288. // line. This parameter is ignored by a single-line edit control.
  289. // pbstr - The address of a BSTR variable to receive the specified line of
  290. // text. The caller must free this BSTR using ::SysFreeString when it no
  291. // longer needs it.
  292. //
  293. // TODO: This could be made slightly more efficient by using
  294. // ::SysAllocStringLength since we already know the length in advance.
  295. //
  296. // TODO: The BSTR version of this does not appear to be initializing the
  297. // first word of the buffer. This should probably be fixed.
  298. //
  299. // Return Value: The number of bytes actually copied. The return value is 0
  300. // if the line number specified by nIndex is greater then the number of lines
  301. // in the edit control.
  302. //
  303. // See Also: TCEditWindow::LineLength, CWindow::GetWindowText, EM_GETLINE
  304. inline int TCEditWindow::GetLine(int nIndex, BSTR* pbstr) const
  305. {
  306. *pbstr = NULL;
  307. assert(::IsWindow(m_hWnd));
  308. int cchLine = LineLength(nIndex);
  309. if (!cchLine)
  310. return 0;
  311. LPTSTR psz = (LPTSTR)_alloca(cchLine + sizeof(TCHAR));
  312. int nResult = (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, LPARAM(psz));
  313. psz[nResult] = TEXT('\0');
  314. USES_CONVERSION;
  315. *pbstr = SysAllocString(T2OLE(psz));
  316. return nResult;
  317. }
  318. /////////////////////////////////////////////////////////////////////////////
  319. // Parameters:
  320. // pszBuffer - Points to the buffer that receives a copy of the line. The
  321. // first word of the buffer must specify the maximum number of bytes that can
  322. // be copied to the buffer.
  323. // nMaxLength - Specifies the maximum number of bytes that can be copied to
  324. // the buffer. GetLine places this value in the first word of
  325. // /pszBuffer/ before making the call to Windows.
  326. inline int TCEditWindow::GetLine(int nIndex, LPTSTR pszBuffer,
  327. int nMaxLength) const
  328. {
  329. assert(::IsWindow(m_hWnd));
  330. *(LPWORD)pszBuffer = (WORD)nMaxLength;
  331. return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)pszBuffer);
  332. }
  333. /////////////////////////////////////////////////////////////////////////////
  334. // Description: Resets (clears) the undo flag of an edit control.
  335. //
  336. // Call this function to reset (clear) the undo flag of an edit control. The
  337. // edit control will now be unable to undo the last operation. The undo flag
  338. // is set whenever an operation within the edit control can be undone.
  339. //
  340. // The undo flag is automatically cleared whenever the SetHandle or the
  341. // CWindow::SetWindowText member functions are called.
  342. //
  343. // See Also: TCEditWindow::CanUndo, TCEditWindow::SetHandle,
  344. // TCEditWindow::Undo, CWindow::SetWindowText, EM_EMPTYUNDOBUFFER
  345. inline void TCEditWindow::EmptyUndoBuffer()
  346. {
  347. assert(::IsWindow(m_hWnd));
  348. ::SendMessage(m_hWnd, EM_EMPTYUNDOBUFFER, 0, 0);
  349. }
  350. /////////////////////////////////////////////////////////////////////////////
  351. // Description: Sets the inclusion of soft line-break characters on or off
  352. // within a multiple-line edit control.
  353. //
  354. // Call this function to set the inclusion of soft line-break characters on
  355. // or off within a multiple-line edit control. A soft line break consists of
  356. // two carriage returns and a linefeed inserted at the end of a line that is
  357. // broken because of word wrapping. A hard line break consists of one
  358. // carriage return and a linefeed. Lines that end with a hard line break are
  359. // not affected by FmtLines.
  360. //
  361. // Windows will only respond if the TCEditWindow object is a multiple-line
  362. // edit control.
  363. //
  364. // FmtLines only affects the buffer returned by GetHandle and the text
  365. // returned by *WM_GETTEXT*. It has no impact on the display of the text
  366. // within the edit control.
  367. //
  368. // Parameters:
  369. // bAddEOL - Specifies whether soft line-break characters are to be
  370. // inserted. A value of *TRUE* inserts the characters; a value of
  371. // *FALSE* removes them.
  372. //
  373. // Return Value: Nonzero if any formatting occurs; otherwise 0.
  374. //
  375. // See Also: TCEditWindow::GetHandle, CWindow::GetWindowText, EM_FMTLINES
  376. inline BOOL TCEditWindow::FmtLines(BOOL bAddEOL)
  377. {
  378. assert(::IsWindow(m_hWnd));
  379. return (BOOL)::SendMessage(m_hWnd, EM_FMTLINES, bAddEOL, 0);
  380. }
  381. /////////////////////////////////////////////////////////////////////////////
  382. // Description: Limits the length of the text that the user may enter into an
  383. // edit control.
  384. //
  385. // Call this function to limit the length of the text that the user may enter
  386. // into an edit control.
  387. //
  388. // Changing the text limit restricts only the text the user can enter. It has
  389. // no effect on any text already in the edit control, nor does it affect the
  390. // length of the text copied to the edit control by the
  391. // CWindow::SetWindowText member function. If an application uses the
  392. // SetWindowText function to place more text into an edit control than is
  393. // specified in the call to LimitText, the user can delete any of the text
  394. // within the edit control. However, the text limit will prevent the user
  395. // from replacing the existing text with new text, unless deleting the
  396. // current selection causes the text to fall below the text limit.
  397. //
  398. // Note: In Win32 (Windows NT and Windows 95), SetLimitText replaces this
  399. // function.
  400. //
  401. // Parameters:
  402. // nChars - Specifies the maximum number of characters the user can enter.
  403. // If this parameter is zero, the text length is set to 0x7FFFFFFE characters
  404. // for single-line edit controls or 0xFFFFFFFF for multiline edit controls.
  405. //
  406. // See Also: TCEditWindow::GetLimitText, TCEditWindow::SetLimitText,
  407. // CWindow::SetWindowText, EM_LIMITTEXT
  408. inline void TCEditWindow::LimitText(int nChars)
  409. {
  410. assert(::IsWindow(m_hWnd));
  411. ::SendMessage(m_hWnd, EM_LIMITTEXT, nChars, 0);
  412. }
  413. /////////////////////////////////////////////////////////////////////////////
  414. // Description: Retrieves the line number of the line that contains the
  415. // specified character index.
  416. //
  417. // Call this function to retrieve the line number of the line that contains
  418. // the specified character index. A character index is the number of
  419. // characters from the beginning of the edit control.
  420. //
  421. // This member function is only used by multiple-line edit controls.
  422. //
  423. // Parameters:
  424. // nIndex - Contains the zero-based index value for the desired character
  425. // in the text of the edit control, or contains –1. If nIndex is –1, it
  426. // specifies the current line, that is, the line that contains the caret.
  427. //
  428. // Return Value: The zero-based line number of the line containing the
  429. // character index specified by nIndex. If nIndex is –1, the number of the
  430. // line that contains the first character of the selection is returned.
  431. // If there is no selection, the current line number is returned.
  432. //
  433. // See Also: TCEditWindow::LineIndex, EM_LINEFROTCHAR
  434. inline int TCEditWindow::LineFromChar(int nIndex) const
  435. {
  436. assert(::IsWindow(m_hWnd));
  437. return (int)::SendMessage(m_hWnd, EM_LINEFROTCHAR, nIndex, 0);
  438. }
  439. /////////////////////////////////////////////////////////////////////////////
  440. // Description: Retrieves the character index of a line within a
  441. // multiple-line edit control.
  442. //
  443. // Call this function to retrieve the character index of a line within a
  444. // multiple-line edit control. The character index is the number of
  445. // characters from the beginning of the edit control to the specified line.
  446. //
  447. // This member function is only processed by multiple-line edit controls.
  448. //
  449. // Parameters:
  450. // nLine - Contains the index value for the desired line in the text of the
  451. // edit control, or contains –1. If nLine is –1, it specifies the current
  452. // line, that is, the line that contains the caret.
  453. //
  454. // Return Value: The character index of the line specified in nLine or –1 if
  455. // the specified line number is greater then the number of lines in the edit
  456. // control.
  457. //
  458. // See Also: TCEditWindow::LineFromChar, EM_LINEINDEX
  459. inline int TCEditWindow::LineIndex(int nLine) const
  460. {
  461. assert(::IsWindow(m_hWnd));
  462. return (int)::SendMessage(m_hWnd, EM_LINEINDEX, nLine, 0);
  463. }
  464. /////////////////////////////////////////////////////////////////////////////
  465. // Description: Retrieves the length of a line in an edit control.
  466. //
  467. // Call this function to retrieve the length of a line in an edit control.
  468. //
  469. // Use the LineIndex member function to retrieve a character index for a
  470. // given line number within a multiple-line edit control.
  471. //
  472. // Parameters:
  473. // nLine - Specifies the character index of a character in the line whose
  474. // length is to be retrieved. If this parameter is –1, the length of the
  475. // current line (the line that contains the caret) is returned, not including
  476. // the length of any selected text within the line. When LineLength is called
  477. // for a single-line edit control, this parameter is ignored.
  478. //
  479. // Return Value: When LineLength is called for a multiple-line edit control,
  480. // the return value is the length (in characters) of the line specified by
  481. // /nLine/. When LineLength is called for a single-line edit control, the
  482. // return value is the length (in characters) of the text in the edit
  483. // control.
  484. //
  485. // See Also: TCEditWindow::LineIndex, EM_LINELENGTH
  486. inline int TCEditWindow::LineLength(int nLine) const
  487. {
  488. assert(::IsWindow(m_hWnd));
  489. return (int)::SendMessage(m_hWnd, EM_LINELENGTH, nLine, 0);
  490. }
  491. /////////////////////////////////////////////////////////////////////////////
  492. // Description: Scrolls the text of a multiple-line edit control.
  493. //
  494. // Call this function to scroll the text of a multiple-line edit control.
  495. //
  496. // This member function is processed only by multiple-line edit controls.
  497. //
  498. // The edit control does not scroll vertically past the last line of text in
  499. // the edit control. If the current line plus the number of lines specified
  500. // by /nLines/ exceeds the total number of lines in the edit control, the
  501. // value is adjusted so that the last line of the edit control is scrolled to
  502. // the top of the edit-control window.
  503. //
  504. // LineScroll can be used to scroll horizontally past the last character of
  505. // any line.
  506. //
  507. // Parameters:
  508. // nLines - Specifies the number of lines to scroll vertically.
  509. // nChars - Specifies the number of character positions to scroll
  510. // horizontally. This value is ignored if the edit control has either the
  511. // *ES_RIGHT* or *ES_CENTER* style.
  512. //
  513. // See Also: TCEditWindow::LineIndex, EM_LINESCROLL
  514. inline void TCEditWindow::LineScroll(int nLines, int nChars)
  515. {
  516. assert(::IsWindow(m_hWnd));
  517. ::SendMessage(m_hWnd, EM_LINESCROLL, nChars, nLines);
  518. }
  519. /////////////////////////////////////////////////////////////////////////////
  520. // Description: Replaces the current selection in an edit control with the
  521. // specified text.
  522. //
  523. // Call this function to replace the current selection in an edit control
  524. // with the text specified by /pszNewText/.
  525. //
  526. // Replaces only a portion of the text in an edit control. If you want to
  527. // replace all of the text, use the CWindow::SetWindowText member function.
  528. //
  529. // If there is no current selection, the replacement text is inserted at the
  530. // current cursor location.
  531. //
  532. // Parameters:
  533. // pszNewText - Points to a null-terminated string containing the
  534. // replacement text.
  535. // bCanUndo - To specify that this function can be undone, set the value of
  536. // this parameter to *TRUE* . The default value is *FALSE*.
  537. //
  538. // See Also: CWindow::SetWindowText, EM_REPLACESEL
  539. inline void TCEditWindow::ReplaceSel(LPCTSTR pszNewText, BOOL bCanUndo)
  540. {
  541. assert(::IsWindow(m_hWnd));
  542. ::SendMessage(m_hWnd, EM_REPLACESEL, bCanUndo, (LPARAM)pszNewText);
  543. }
  544. /////////////////////////////////////////////////////////////////////////////
  545. // Description: Sets or removes a password character displayed in an edit
  546. // control when the user enters text.
  547. //
  548. // Call this function to set or remove a password character displayed in an
  549. // edit control when the user types text. When a password character is set,
  550. // that character is displayed for each character the user types.
  551. //
  552. // This member function has no effect on a multiple-line edit control.
  553. //
  554. // When the SetPasswordChar member function is called, TCEditWindow will
  555. // redraw all visible characters using the character specified by /ch/.
  556. //
  557. // If the edit control is created with the *ES_PASSWORD* style, the default
  558. // password character is set to an asterisk (*). This style is removed if
  559. // SetPasswordChar is called with /ch/ set to 0.
  560. //
  561. // Parameters:
  562. // ch - Specifies the character to be displayed in place of the character
  563. // typed by the user. If /ch/ is 0, the actual characters typed by the user
  564. // are displayed.
  565. //
  566. // See Also: TCEditWindow::GetPasswordChar, EM_SETPASSWORDCHAR
  567. inline void TCEditWindow::SetPasswordChar(TCHAR ch)
  568. {
  569. assert(::IsWindow(m_hWnd));
  570. ::SendMessage(m_hWnd, EM_SETPASSWORDCHAR, ch, 0);
  571. }
  572. /////////////////////////////////////////////////////////////////////////////
  573. // Description: Sets the formatting rectangle of a multiple-line edit control
  574. // and updates the control.
  575. //
  576. // Call this function to set the dimensions of a rectangle using the
  577. // specified coordinates. This member is processed only by multiple-line edit
  578. // controls.
  579. //
  580. // Use SetRect to set the formatting rectangle of a multiple-line edit
  581. // control. The formatting rectangle is the limiting rectangle of the text,
  582. // which is independent of the size of the edit-control window. When the edit
  583. // control is first created, the formatting rectangle is the same as the
  584. // client area of the edit-control window. By using the SetRect member
  585. // function, an application can make the formatting rectangle larger or
  586. // smaller than the edit-control window.
  587. //
  588. // If the edit control has no scroll bar, text will be clipped, not wrapped,
  589. // if the formatting rectangle is made larger than the window. If the edit
  590. // control contains a border, the formatting rectangle is reduced by the size
  591. // of the border. If you adjust the rectangle returned by the GetRect member
  592. // function, you must remove the size of the border before you pass the
  593. // rectangle to SetRect.
  594. //
  595. // When SetRect is called, the edit control's text is also reformatted and
  596. // redisplayed.
  597. //
  598. // Parameters:
  599. // lpRect - Points to the *RECT* structure that specifies the new
  600. // dimensions of the formatting rectangle.
  601. //
  602. // See Also: TCEditWindow::GetRect, TCEditWindow::SetRectNP, EM_SETRECT
  603. inline void TCEditWindow::SetRect(LPCRECT lpRect)
  604. {
  605. assert(::IsWindow(m_hWnd));
  606. ::SendMessage(m_hWnd, EM_SETRECT, 0, (LPARAM)lpRect);
  607. }
  608. /////////////////////////////////////////////////////////////////////////////
  609. // Description: Sets the formatting rectangle of a multiple-line edit control
  610. // without redrawing the control window.
  611. //
  612. // Call this function to set the formatting rectangle of a multiple-line
  613. // edit control. The formatting rectangle is the limiting rectangle of the
  614. // text, which is independent of the size of the edit-control window.
  615. //
  616. // SetRectNP is identical to the SetRect member function except that the
  617. // edit-control window is not redrawn.
  618. //
  619. // When the edit control is first created, the formatting rectangle is the
  620. // same as the client area of the edit-control window. By calling the
  621. // SetRectNP member function, an application can make the formatting
  622. // rectangle larger or smaller than the edit-control window.
  623. //
  624. // If the edit control has no scroll bar, text will be clipped, not wrapped,
  625. // if the formatting rectangle is made larger than the window.
  626. //
  627. // This member is processed only by multiple-line edit controls.
  628. //
  629. // Parameters:
  630. // lpRect - Points to the *RECT* structure that specifies the new
  631. // dimensions of the formatting rectangle.
  632. //
  633. // See Also: TCEditWindow::GetRect, TCEditWindow::SetRect, EM_SETRECTNP
  634. inline void TCEditWindow::SetRectNP(LPCRECT lpRect)
  635. {
  636. assert(::IsWindow(m_hWnd));
  637. ::SendMessage(m_hWnd, EM_SETRECTNP, 0, (LPARAM)lpRect);
  638. }
  639. /////////////////////////////////////////////////////////////////////////////
  640. // Description: Selects a range of characters in an edit control.
  641. //
  642. // Call this function to select a range of characters in an edit control.
  643. //
  644. // Parameters:
  645. // dwSelection - Specifies the starting position in the low-order word and
  646. // the ending position in the high-order word. If the low-order word is 0
  647. // and the high-order word is –1, all the text in the edit control is
  648. // selected. If the low-order word is –1, any current selection is removed.
  649. // bNoScroll - Indicates whether the caret should be scrolled into view. If
  650. // *FALSE*, the caret is scrolled into view. If *TRUE*, the caret is not
  651. // scrolled into view.
  652. //
  653. // See Also: TCEditWindow::GetSel, TCEditWindow::ReplaceSel, EM_SETSEL
  654. inline void TCEditWindow::SetSel(DWORD dwSelection, BOOL bNoScroll)
  655. {
  656. assert(::IsWindow(m_hWnd));
  657. ::SendMessage(m_hWnd, EM_SETSEL, LOWORD(dwSelection), HIWORD(dwSelection));
  658. if (!bNoScroll)
  659. ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0);
  660. }
  661. /////////////////////////////////////////////////////////////////////////////
  662. // Parameters:
  663. // nStartChar - Specifies the starting position. If /nStartChar/ is 0 and
  664. // /nEndChar/ is –1, all the text in the edit control is selected. If
  665. // /nStartChar/ is –1, any current selection is removed.
  666. // nEndChar - Specifies the ending position.
  667. inline void TCEditWindow::SetSel(int nStartChar, int nEndChar,
  668. BOOL bNoScroll)
  669. {
  670. assert(::IsWindow(m_hWnd));
  671. ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar);
  672. if (!bNoScroll)
  673. ::SendMessage(m_hWnd, EM_SCROLLCARET, 0, 0);
  674. }
  675. /////////////////////////////////////////////////////////////////////////////
  676. // Description: Sets the tab stops in a multiple-line edit control.
  677. //
  678. // Call this function to set the tab stops in a multiple-line edit control.
  679. // When text is copied to a multiple-line edit control, any tab character in
  680. // the text will cause space to be generated up to the next tab stop.
  681. //
  682. // To set tab stops to the default size of 32 dialog units, call the
  683. // parameterless version of this member function. To set tab stops to a size
  684. // other than 32, call the version with the /cxEachStop/ parameter. To set
  685. // tab stops to an array of sizes, use the version with two parameters.
  686. //
  687. // This member function is only processed by multiple-line edit controls.
  688. //
  689. // SetTabStops does not automatically redraw the edit window. If you change
  690. // the tab stops for text already in the edit control, call
  691. // CWindow::InvalidateRect to redraw the edit window.
  692. //
  693. // Parameters:
  694. // nTabStops - Specifies the number of tab stops contained in rgTabStops.
  695. // This number must be greater than 1.
  696. // rgTabStops - Points to an array of unsigned integers specifying the tab
  697. // stops in dialog units. A dialog unit is a horizontal or vertical distance.
  698. // One horizontal dialog unit is equal to one-fourth of the current dialog
  699. // base width unit, and 1 vertical dialog unit is equal to one-eighth of the
  700. // current dialog base height unit. The dialog base units are computed based
  701. // on the height and width of the current window font. The Win32
  702. // *MapDialogRect* function converts (maps) the specified dialog box units to
  703. // screen units (pixels).
  704. //
  705. // Return Value: Nonzero if the tabs were set; otherwise 0.
  706. //
  707. // See Also: CWindow::InvalidateRect, EM_SETTABSTOPS, ::MapDialogRect
  708. inline BOOL TCEditWindow::SetTabStops(int nTabStops, LPINT rgTabStops)
  709. {
  710. assert(::IsWindow(m_hWnd));
  711. return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, nTabStops,
  712. (LPARAM)rgTabStops);
  713. }
  714. /////////////////////////////////////////////////////////////////////////////
  715. inline void TCEditWindow::SetTabStops()
  716. {
  717. assert(::IsWindow(m_hWnd));
  718. LRESULT lResult = ::SendMessage(m_hWnd, EM_SETTABSTOPS, 0, 0);
  719. assert(lResult);
  720. }
  721. /////////////////////////////////////////////////////////////////////////////
  722. // Parameters:
  723. // cxEachStop - Specifies that tab stops are to be set at every
  724. // /cxEachStop/ dialog units.
  725. inline BOOL TCEditWindow::SetTabStops(const int& cxEachStop)
  726. {
  727. assert(::IsWindow(m_hWnd));
  728. return (BOOL)::SendMessage(m_hWnd, EM_SETTABSTOPS, 1,
  729. (LPARAM)(LPINT)&cxEachStop);
  730. }
  731. /////////////////////////////////////////////////////////////////////////////
  732. // Description: Reverses the last edit-control operation.
  733. //
  734. // Call this function to undo the last edit-control operation.
  735. //
  736. // An undo operation can also be undone. For example, you can restore deleted
  737. // text with the first call to Undo. As long as there is no intervening edit
  738. // operation, you can remove the text again with a second call to Undo.
  739. //
  740. // Return Value: For a single-line edit control, the return value is always
  741. // nonzero. For a multiple-line edit control, the return value is nonzero if
  742. // the undo operation is successful, or 0 if the undo operation fails.
  743. //
  744. // See Also: TCEditWindow::CanUndo, EM_UNDO
  745. inline BOOL TCEditWindow::Undo()
  746. {
  747. assert(::IsWindow(m_hWnd));
  748. return (BOOL)::SendMessage(m_hWnd, EM_UNDO, 0, 0);
  749. }
  750. /////////////////////////////////////////////////////////////////////////////
  751. // Description: Deletes (clears) the current selection (if any) in the edit
  752. // control.
  753. //
  754. // Call this function to delete (clear) the current selection (if any) in the
  755. // edit control.
  756. //
  757. // The deletion performed by Clear can be undone by calling the Undo member
  758. // function.
  759. //
  760. // To delete the current selection and place the deleted contents into the
  761. // Clipboard, call the Cut member function.
  762. //
  763. // See Also: TCEditWindow::Undo, TCEditWindow::Copy, TCEditWindow::Cut,
  764. // TCEditWindow::Paste, WM_CLEAR
  765. inline void TCEditWindow::Clear()
  766. {
  767. assert(::IsWindow(m_hWnd));
  768. ::SendMessage(m_hWnd, WM_CLEAR, 0, 0);
  769. }
  770. /////////////////////////////////////////////////////////////////////////////
  771. // Description: Copies the current selection (if any) in the edit control to
  772. // the Clipboard in *CF_TEXT* format.
  773. //
  774. // Call this function to coy the current selection (if any) in the edit
  775. // control to the Clipboard in *CF_TEXT* format.
  776. //
  777. // See Also: TCEditWindow::Clear, TCEditWindow::Cut, TCEditWindow::Paste,
  778. // WM_COPY
  779. inline void TCEditWindow::Copy()
  780. {
  781. assert(::IsWindow(m_hWnd));
  782. ::SendMessage(m_hWnd, WM_COPY, 0, 0);
  783. }
  784. /////////////////////////////////////////////////////////////////////////////
  785. // Description: Deletes (cuts) the current selection (if any) in the edit
  786. // control and copies the deleted text to the Clipboard in *CF_TEXT* format.
  787. //
  788. // Call this function to delete (cut) the current selection (if any) in the
  789. // edit control and copy the deleted text to the Clipboard in
  790. // *CF_TEXT* format.
  791. //
  792. // The deletion performed by Cut can be undone by calling the Undo member
  793. // function.
  794. //
  795. // To delete the current selection without placing the deleted text into the
  796. // Clipboard, call the Clear member function.
  797. //
  798. // See Also: TCEditWindow::Undo, TCEditWindow::Clear, TCEditWindow::Copy,
  799. // TCEditWindow::Paste, WM_CUT
  800. inline void TCEditWindow::Cut()
  801. {
  802. assert(::IsWindow(m_hWnd));
  803. ::SendMessage(m_hWnd, WM_CUT, 0, 0);
  804. }
  805. /////////////////////////////////////////////////////////////////////////////
  806. // Description: Inserts the data from the Clipboard into the edit control at
  807. // the current cursor position. Data is inserted only if the Clipboard
  808. // contains data in *CF_TEXT* format.
  809. //
  810. // Call this function to insert the data from the Clipboard into the
  811. // TCEditWindow at the insertion point. Data is inserted only if the
  812. // Clipboard contains data in *CF_TEXT* format.
  813. //
  814. // See Also: TCEditWindow::Clear, TCEditWindow::Copy, TCEditWindow::Cut,
  815. // WM_PASTE
  816. inline void TCEditWindow::Paste()
  817. {
  818. assert(::IsWindow(m_hWnd));
  819. ::SendMessage(m_hWnd, WM_PASTE, 0, 0);
  820. }
  821. /////////////////////////////////////////////////////////////////////////////
  822. // Description: Sets or clears the read-only state of an edit control.
  823. //
  824. // Calls this function to set the read-only state of an edit control.
  825. //
  826. // The current setting can be found by testing the *ES_READONLY* flag in the
  827. // return value of CWindow::GetStyle.
  828. //
  829. // Parameters:
  830. // bReadOnly - Specifies whether to set or remove the read-only state of
  831. // the edit control. A value of *TRUE* sets the state to read-only; a value
  832. // of *FALSE* sets the state to read/write.
  833. //
  834. // Return Value: Nonzero if the operation is successful, or 0 if an error
  835. // occurs.
  836. //
  837. // See Also: CWindow::GetStyle, EM_SETREADONLY
  838. inline BOOL TCEditWindow::SetReadOnly(BOOL bReadOnly )
  839. {
  840. assert(::IsWindow(m_hWnd));
  841. return (BOOL)::SendMessage(m_hWnd, EM_SETREADONLY, bReadOnly, 0L);
  842. }
  843. /////////////////////////////////////////////////////////////////////////////
  844. // Description: Determines the topmost visible line in an edit control.
  845. //
  846. // Call this function to determine the topmost visible line in an edit
  847. // control.
  848. //
  849. // Return Value: The zero-based index of the topmost visible line. For
  850. // single-line edit controls, the return value is 0.
  851. //
  852. // See Also: TCEditWindow::GetLine, EM_GETFIRSTVISIBLELINE
  853. inline int TCEditWindow::GetFirstVisibleLine() const
  854. {
  855. assert(::IsWindow(m_hWnd));
  856. return (int)::SendMessage(m_hWnd, EM_GETFIRSTVISIBLELINE, 0, 0L);
  857. }
  858. /////////////////////////////////////////////////////////////////////////////
  859. // Description: Retrieves the password character displayed in an edit control
  860. // when the user enters text.
  861. //
  862. // Call this function to retrieve the password character displayed in an edit
  863. // control when the user enters text.
  864. //
  865. // If the edit control is created with the *ES_PASSWORD* style, the default
  866. // password character is set to an asterisk (*).
  867. //
  868. // Return Value: Specifies the character to be displayed in place of the
  869. // character typed by the user. The return value is *NULL* if no password
  870. // character exists.
  871. //
  872. // See Also: TCEditWindow::SetPasswordChar, EM_GETPASSWORDCHAR
  873. inline TCHAR TCEditWindow::GetPasswordChar() const
  874. {
  875. assert(::IsWindow(m_hWnd));
  876. return (TCHAR)::SendMessage(m_hWnd, EM_GETPASSWORDCHAR, 0, 0L);
  877. }
  878. /////////////////////////////////////////////////////////////////////////////
  879. // Description: Sets the left and right margins for this TCEditWindow.
  880. //
  881. // Call this member function to set the left and right margins of this edit
  882. // control.
  883. //
  884. // Parameters:
  885. // nLeft - The width of the new left margin, in pixels.
  886. // nRight - The width of the new right margin, in pixels.
  887. //
  888. // See Also: TCEditWindow::GetMargins, EM_SETMARGINS
  889. inline void TCEditWindow::SetMargins(UINT nLeft, UINT nRight)
  890. {
  891. assert(::IsWindow(m_hWnd));
  892. ::SendMessage(m_hWnd, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN,
  893. MAKELONG(nLeft, nRight));
  894. }
  895. /////////////////////////////////////////////////////////////////////////////
  896. // Description: Gets the left and right margins for this TCEditWindow.
  897. //
  898. // Call this member function to retrieve the left and right margins of this
  899. // edit control. Margins are measured in pixels.
  900. //
  901. // Return Value: The width of the left margin in the low-order *WORD* and
  902. // the width of the right margin in the high-order *WORD*.
  903. //
  904. // See Also: TCEditWindow::SetMargins, EM_GETMARGINS
  905. inline DWORD TCEditWindow::GetMargins() const
  906. {
  907. assert(::IsWindow(m_hWnd));
  908. return (DWORD)::SendMessage(m_hWnd, EM_GETMARGINS, 0, 0);
  909. }
  910. /////////////////////////////////////////////////////////////////////////////
  911. // Description: Sets the maximum amount of text this TCEditWindow can
  912. // contain.
  913. //
  914. // Call this member function to set the text limit for this TCEditWindow
  915. // object. The text limit is the maximum amount of text, in characters, that
  916. // the edit control can accept.
  917. //
  918. // Changing the text limit restricts only the text the user can enter. It has
  919. // no effect on any text already in the edit control, nor does it affect the
  920. // length of the text copied to the edit control by the
  921. // CWindow::SetWindowText member function. If an application uses the
  922. // CWindow::SetWindowText function to place more text into an edit control
  923. // than is specified in the call to LimitText, the user can delete any of the
  924. // text within the edit control. However, the text limit will prevent the
  925. // user from replacing the existing text with new text, unless deleting the
  926. // current selection causes the text to fall below the text limit.
  927. //
  928. // This function replaces LimitText in Win32.
  929. //
  930. // Parameters:
  931. // nMax - The new text limit, in characters.
  932. //
  933. // See Also: TCEditWindow::GetLimitText, TCEditWindow::LimitText
  934. // EM_SETLIMITTEXT
  935. inline void TCEditWindow::SetLimitText(UINT nMax)
  936. {
  937. assert(::IsWindow(m_hWnd));
  938. ::SendMessage(m_hWnd, EM_SETLIMITTEXT, nMax, 0);
  939. }
  940. /////////////////////////////////////////////////////////////////////////////
  941. // Description: Gets the maximum amount of text this TCEditWindow can
  942. // contain.
  943. //
  944. // Call this member function to get the text limit for this TCEditWindow
  945. // object. The text limit is the maximum amount of text, in characters, that
  946. // the edit control can accept.
  947. //
  948. // Return Value: The current text limit, in characters, for this TCEditWindow
  949. // object.
  950. //
  951. // See Also: TCEditWindow::SetLimitText, TCEditWindow::LimitText,
  952. // EM_GETLIMITTEXT
  953. inline UINT TCEditWindow::GetLimitText() const
  954. {
  955. assert(::IsWindow(m_hWnd));
  956. return (UINT)::SendMessage(m_hWnd, EM_GETLIMITTEXT, 0, 0);
  957. }
  958. /////////////////////////////////////////////////////////////////////////////
  959. // Description: Retrieves the coordinates of the upper-left corner of a
  960. // specified character index.
  961. //
  962. // Call this function to get the position (top-left corner) of a given
  963. // character within this TCEditWindow object. The character is specified by
  964. // giving its zero-based index value. If /nChar/ is greater than the index of
  965. // the last character in this TCEditWindow object, the return value specifies
  966. // the coordinates of the character position just past the last character in
  967. // this TCEditWindow object.
  968. //
  969. // Parameters:
  970. // nChar - The zero-based index of the character for which the position is
  971. // to be returned.
  972. //
  973. // Return Value: The coordinates of the top-left corner of the character
  974. // specified by /nChar/.
  975. //
  976. // See Also: TCEditWindow::CharFromPos, EM_POSFROTCHAR
  977. inline POINT TCEditWindow::PosFromChar(UINT nChar) const
  978. {
  979. assert(::IsWindow(m_hWnd));
  980. POINT pt;
  981. ::SendMessage(m_hWnd, EM_POSFROTCHAR, WPARAM(&pt), nChar);
  982. return pt;
  983. }
  984. /////////////////////////////////////////////////////////////////////////////
  985. // Description: Retrieves the line and character indices for the character
  986. // closest to a specified position.
  987. //
  988. // Call this function to retrieve the zero-based line and character indices
  989. // of the character nearest the specified point in this TCEditWindow control.
  990. //
  991. // Parameters:
  992. // pt - The coordinates of a point in the client area of this TCEditWindow
  993. // object.
  994. //
  995. // Return Value: The character index in the low-order *WORD*, and the line
  996. // index in the high-order *WORD*.
  997. //
  998. // See Also: TCEditWindow::PosFromChar, EM_CHARFROMPOS
  999. inline int TCEditWindow::CharFromPos(POINT pt) const
  1000. {
  1001. assert(::IsWindow(m_hWnd));
  1002. return (int)::SendMessage(m_hWnd, EM_CHARFROMPOS, 0,
  1003. MAKELPARAM(pt.x, pt.y));
  1004. }
  1005. /////////////////////////////////////////////////////////////////////////////
  1006. // Group=Operators
  1007. /////////////////////////////////////////////////////////////////////////////
  1008. // Subclasses the specified window.
  1009. //
  1010. // Parameters:
  1011. // hwnd - the handle of the window to be subclassed by this object.
  1012. //
  1013. // See Also: CWindowImpl::SubclassWindow
  1014. inline const TCEditWindow& TCEditWindow::operator=(HWND hwnd)
  1015. {
  1016. SubclassWindow(hwnd);
  1017. return *this;
  1018. }
  1019. /////////////////////////////////////////////////////////////////////////////
  1020. #endif // !__EditWindow_h__