]> git.saurik.com Git - wxWidgets.git/blame - src/os2/textctrl.cpp
Fix for when Set is called with wxSameAs to behave just like calling SameAs()
[wxWidgets.git] / src / os2 / textctrl.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: textctrl.cpp
3// Purpose: wxTextCtrl
d90895ac 4// Author: David Webster
0e320a79 5// Modified by:
d90895ac 6// Created: 10/17/99
0e320a79 7// RCS-ID: $Id$
d90895ac
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
d90895ac
DW
12// ----------------------------------------------------------------------------
13// headers
14// ----------------------------------------------------------------------------
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifndef WX_PRECOMP
20 #include "wx/textctrl.h"
19193a2c 21 #include "wx/scrolwin.h"
d90895ac
DW
22 #include "wx/settings.h"
23 #include "wx/brush.h"
24 #include "wx/utils.h"
25 #include "wx/log.h"
0e320a79
DW
26#endif
27
d90895ac
DW
28#if wxUSE_CLIPBOARD
29 #include "wx/app.h"
30 #include "wx/clipbrd.h"
31#endif
0e320a79 32
d90895ac
DW
33#include "wx/textfile.h"
34
35#include "wx/os2/private.h"
36
37#include <string.h>
38#include <stdlib.h>
39#include <sys/types.h>
0e320a79 40
d90895ac
DW
41#if wxUSE_IOSTREAMH
42# include <fstream.h>
0e320a79 43#else
d90895ac 44# include <fstream>
0e320a79
DW
45#endif
46
19193a2c 47#if !defined(MLE_INDEX)
a92d9721
SN
48#define MLE_INDEX 0
49#define MLE_RGB 1
50#endif
51
d90895ac
DW
52
53// ----------------------------------------------------------------------------
54// event tables and other macros
55// ----------------------------------------------------------------------------
56
0e320a79
DW
57IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
58
59BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
d90895ac
DW
60 EVT_CHAR(wxTextCtrl::OnChar)
61 EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
62
0e320a79
DW
63 EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
64 EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
65 EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
66 EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
67 EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
68
69 EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
70 EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
71 EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
72 EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
73 EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
74END_EVENT_TABLE()
0e320a79 75
d90895ac
DW
76
77// ============================================================================
78// implementation
79// ============================================================================
80
81// ----------------------------------------------------------------------------
82// creation
83// ----------------------------------------------------------------------------
84
0e320a79 85wxTextCtrl::wxTextCtrl()
0e320a79 86{
0e320a79
DW
87}
88
3bd418ca
DW
89bool wxTextCtrl::Create(
90 wxWindow* pParent
91, wxWindowID vId
92, const wxString& rsValue
93, const wxPoint& rPos
94, const wxSize& rSize
95, long lStyle
5d4b632b 96#if wxUSE_VALIDATORS
3bd418ca 97, const wxValidator& rValidator
5d4b632b 98#endif
3bd418ca
DW
99, const wxString& rsName
100)
101{
39c26ef2
DW
102 HWND hParent;
103 int nTempy;
3bd418ca
DW
104 //
105 // Base initialization
106 //
107 if ( !CreateBase( pParent
108 ,vId
109 ,rPos
110 ,rSize
111 ,lStyle
112#if wxUSE_VALIDATORS
113 ,rValidator
114#endif
115 ,rsName
116 ))
d90895ac 117 return FALSE;
0e320a79 118
45bfc84b 119 wxPoint vPos = rPos; // The OS/2 position
5d44b24e 120 SWP vSwp;
45bfc84b 121
3bd418ca 122 if (pParent )
45bfc84b 123 {
3bd418ca 124 pParent->AddChild(this);
45bfc84b 125 }
0e320a79 126
3bd418ca 127 m_windowStyle = lStyle;
d90895ac 128
3bd418ca
DW
129 long lSstyle = WS_VISIBLE | WS_TABSTOP;
130
131 //
132 // Single and multiline edit fields are two different controls in PM
133 //
d90895ac
DW
134 if ( m_windowStyle & wxTE_MULTILINE )
135 {
9c88ff79 136 lSstyle |= MLS_BORDER | MLS_WORDWRAP;
3bd418ca 137 m_bIsMLE = TRUE;
d90895ac 138
d90895ac 139 if ((m_windowStyle & wxTE_NO_VSCROLL) == 0)
3bd418ca
DW
140 lSstyle |= MLS_VSCROLL;
141 if (m_windowStyle & wxHSCROLL)
142 lSstyle |= MLS_HSCROLL;
143 if (m_windowStyle & wxTE_READONLY)
144 lSstyle |= MLS_READONLY;
d90895ac 145 }
0e320a79 146 else
3bd418ca 147 {
987da0d4 148 lSstyle |= ES_LEFT | ES_AUTOSCROLL | ES_MARGIN;
3bd418ca
DW
149
150 if (m_windowStyle & wxHSCROLL)
151 lSstyle |= ES_AUTOSCROLL;
152 if (m_windowStyle & wxTE_READONLY)
153 lSstyle |= ES_READONLY;
154 if (m_windowStyle & wxTE_PASSWORD) // hidden input
155 lSstyle |= ES_UNREADABLE;
156 }
5d44b24e
DW
157 //
158 // If the parent is a scrolled window the controls must
159 // have this style or they will overlap the scrollbars
160 //
161 if (pParent)
162 if (pParent->IsKindOf(CLASSINFO(wxScrolledWindow)) ||
163 pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)))
164 lSstyle |= WS_CLIPSIBLINGS;
165
3bd418ca
DW
166 if (m_bIsMLE)
167 {
168 m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
169 ,WC_MLE // Window class
170 ,(PSZ)rsValue.c_str() // Initial Text
171 ,(ULONG)lSstyle // Style flags
716ed225
DW
172 ,(LONG)0 // X pos of origin
173 ,(LONG)0 // Y pos of origin
174 ,(LONG)0 // field width
175 ,(LONG)0 // field height
3bd418ca
DW
176 ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent
177 ,HWND_TOP // initial z position
178 ,(ULONG)vId // Window identifier
179 ,NULL // no control data
180 ,NULL // no Presentation parameters
181 );
182 }
183 else
184 {
185 m_hWnd = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
186 ,WC_ENTRYFIELD // Window class
187 ,(PSZ)rsValue.c_str() // Initial Text
188 ,(ULONG)lSstyle // Style flags
716ed225
DW
189 ,(LONG)0 // X pos of origin
190 ,(LONG)0 // Y pos of origin
191 ,(LONG)0 // field width
192 ,(LONG)0 // field height
3bd418ca
DW
193 ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent
194 ,HWND_TOP // initial z position
195 ,(ULONG)vId // Window identifier
196 ,NULL // no control data
197 ,NULL // no Presentation parameters
198 );
199 }
200
201 if (m_hWnd == 0)
202 {
203 return FALSE;
204 }
205
d90895ac
DW
206 SubclassWin(GetHWND());
207
3bd418ca
DW
208 //
209 // Set font, position, size and initial value
210 //
211 wxFont& vFontParent = pParent->GetFont();
212
213 if (vFontParent.Ok())
d90895ac 214 {
3bd418ca 215 SetFont(vFontParent);
d90895ac
DW
216 }
217 else
218 {
a756f210 219 SetFont(wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT));
d90895ac 220 }
3bd418ca
DW
221 if (!rsValue.IsEmpty())
222 {
223 SetValue(rsValue);
224 }
225 SetupColours();
5d44b24e
DW
226 //
227 // If X and/or Y are not zero the difference is the compensation value
228 // for margins for OS/2 controls.
229 //
230 ::WinQueryWindowPos(m_hWnd, &vSwp);
231 SetXComp(vSwp.x);
232 SetYComp(vSwp.y);
39c26ef2
DW
233 SetSize( vPos.x
234 ,vPos.y
3bd418ca
DW
235 ,rSize.x
236 ,rSize.y
237 );
0e320a79 238 return TRUE;
3bd418ca 239} // end of wxTextCtrl::Create
0e320a79 240
3bd418ca 241//
d90895ac 242// Make sure the window style (etc.) reflects the HWND style (roughly)
3bd418ca 243//
d90895ac
DW
244void wxTextCtrl::AdoptAttributesFromHWND()
245{
3bd418ca
DW
246 HWND hWnd = GetHwnd();
247 LONG lStyle = ::WinQueryWindowULong(hWnd, QWL_STYLE);
d90895ac 248
3bd418ca 249 wxWindow::AdoptAttributesFromHWND();
d90895ac 250
3bd418ca
DW
251 if (m_bIsMLE)
252 {
253 m_windowStyle |= wxTE_MULTILINE;
254 if (lStyle & MLS_READONLY)
255 m_windowStyle |= wxTE_READONLY;
256 }
257 else
258 {
259 if (lStyle & ES_UNREADABLE)
260 m_windowStyle |= wxTE_PASSWORD;
261 if (lStyle & ES_READONLY)
262 m_windowStyle |= wxTE_READONLY;
263 }
c4955899 264} // end of wxTextCtrl::AdoptAttributesFromHWND
d90895ac
DW
265
266void wxTextCtrl::SetupColours()
267{
c4955899
DW
268 wxColour vBkgndColour;
269
a756f210 270 vBkgndColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
c4955899 271 SetBackgroundColour(vBkgndColour);
d90895ac 272 SetForegroundColour(GetParent()->GetForegroundColour());
9c88ff79
DW
273 if (m_bIsMLE)
274 {
275 ::WinSendMsg( GetHwnd()
276 ,MLM_SETTEXTCOLOR
277 ,(MPARAM)GetParent()->GetForegroundColour().GetPixel()
278 ,(MPARAM)MLE_RGB
279 );
280 }
c4955899 281} // end of wxTextCtrl::SetupColours
d90895ac
DW
282
283// ----------------------------------------------------------------------------
284// set/get the controls text
285// ----------------------------------------------------------------------------
286
0e320a79
DW
287wxString wxTextCtrl::GetValue() const
288{
c4955899
DW
289 wxString sStr = wxGetWindowText(GetHWND());
290 char* zStr = (char*)sStr.c_str();
d90895ac 291
c4955899
DW
292 for ( ; *zStr; zStr++ )
293 {
294 //
295 // this will replace \r\n with just \n
296 //
297 if (*zStr == '\n')
298 *zStr = '\0';
299 if (*zStr == '\r')
300 *zStr = '\n';
301 }
302 sStr = zStr;
303 return sStr;
304} // end of wxTextCtrl::GetValue
0e320a79 305
c4955899
DW
306void wxTextCtrl::SetValue(
307 const wxString& rsValue
308)
0e320a79 309{
c4955899
DW
310 //
311 // If the text is long enough, it's faster to just set it instead of first
312 // comparing it with the old one (chances are that it will be different
313 // anyhow, this comparison is there to avoid flicker for small single-line
314 // edit controls mostly)
315 //
316 if ((rsValue.length() > 0x400) || (rsValue != GetValue()))
317 {
318 ::WinSetWindowText(GetHwnd(), rsValue.c_str());
319 AdjustSpaceLimit();
320 }
321} // end of wxTextCtrl::SetValue
d90895ac 322
c4955899
DW
323void wxTextCtrl::WriteText(
324 const wxString& rsValue
325)
326{
327 ::WinSetWindowText(GetHwnd(), rsValue.c_str());
d90895ac 328 AdjustSpaceLimit();
c4955899 329} // end of wxTextCtrl::WriteText
0e320a79 330
c4955899
DW
331void wxTextCtrl::AppendText(
332 const wxString& rsText
333)
d90895ac 334{
d90895ac 335 SetInsertionPointEnd();
c4955899
DW
336 WriteText(rsText);
337} // end of wxTextCtrl::AppendText
d90895ac
DW
338
339void wxTextCtrl::Clear()
340{
c4955899
DW
341 ::WinSetWindowText(GetHwnd(), "");
342} // end of wxTextCtrl::Clear
d90895ac
DW
343
344// ----------------------------------------------------------------------------
0e320a79 345// Clipboard operations
d90895ac
DW
346// ----------------------------------------------------------------------------
347
0e320a79
DW
348void wxTextCtrl::Copy()
349{
d90895ac
DW
350 if (CanCopy())
351 {
352 HWND hWnd = GetHwnd();
3bd418ca
DW
353 if (m_bIsMLE)
354 ::WinSendMsg(hWnd, MLM_COPY, 0, 0);
355 else
356 ::WinSendMsg(hWnd, EM_COPY, 0, 0);
d90895ac 357 }
3bd418ca 358} // end of wxTextCtrl::Copy
0e320a79
DW
359
360void wxTextCtrl::Cut()
361{
d90895ac
DW
362 if (CanCut())
363 {
364 HWND hWnd = GetHwnd();
3bd418ca
DW
365
366 if (m_bIsMLE)
367 ::WinSendMsg(hWnd, MLM_CUT, 0, 0);
368 else
369 ::WinSendMsg(hWnd, EM_CUT, 0, 0);
d90895ac 370 }
c4955899 371} // end of wxTextCtrl::Cut
0e320a79
DW
372
373void wxTextCtrl::Paste()
374{
d90895ac
DW
375 if (CanPaste())
376 {
c4955899
DW
377 HWND hWnd = GetHwnd();
378
379 ::WinSendMsg(hWnd, EM_PASTE, 0, 0);
d90895ac 380 }
c4955899 381} // end of wxTextCtrl::Paste
d90895ac
DW
382
383bool wxTextCtrl::CanCopy() const
384{
c4955899 385 //
d90895ac 386 // Can copy if there's a selection
c4955899
DW
387 //
388 long lFrom = 0L;
389 long lTo = 0L;
390
391 GetSelection(&lFrom, &lTo);
392 return (lFrom != lTo);
393} // end of wxTextCtrl::CanCopy
d90895ac
DW
394
395bool wxTextCtrl::CanCut() const
396{
c4955899 397 //
d90895ac 398 // Can cut if there's a selection
c4955899
DW
399 //
400 long lFrom = 0L;
401 long lTo = 0L;
402
403 GetSelection(&lFrom, &lTo);
404 return (lFrom != lTo);
405} // end of wxTextCtrl::CanCut
d90895ac
DW
406
407bool wxTextCtrl::CanPaste() const
408{
3bd418ca
DW
409 bool bIsTextAvailable = FALSE;
410
d90895ac
DW
411 if (!IsEditable())
412 return FALSE;
413
3bd418ca
DW
414 //
415 // Check for straight text on clipboard
416 //
417 if (::WinOpenClipbrd(vHabmain))
d90895ac 418 {
3bd418ca
DW
419 bIsTextAvailable = (::WinQueryClipbrdData(vHabmain, CF_TEXT) != 0);
420 ::WinCloseClipbrd(vHabmain);
d90895ac 421 }
3bd418ca
DW
422 return bIsTextAvailable;
423} // end of wxTextCtrl::CanPaste
0e320a79 424
d90895ac
DW
425// ----------------------------------------------------------------------------
426// Accessors
427// ----------------------------------------------------------------------------
428
c4955899
DW
429void wxTextCtrl::SetEditable(
430 bool bEditable
431)
0e320a79 432{
c4955899
DW
433 HWND hWnd = GetHwnd();
434
435 if (m_bIsMLE)
436 ::WinSendMsg(hWnd, MLM_SETREADONLY, MPFROMLONG(!bEditable), (MPARAM)0);
437 else
438 ::WinSendMsg(hWnd, EM_SETREADONLY, MPFROMLONG(!bEditable), (MPARAM)0);
439} // end of wxTextCtrl::SetEditable
0e320a79 440
c4955899
DW
441void wxTextCtrl::SetInsertionPoint(
442 long lPos
443)
0e320a79 444{
c4955899
DW
445 HWND hWnd = GetHwnd();
446
447 if (m_bIsMLE)
448 ::WinSendMsg(hWnd, MLM_SETSEL, (MPARAM)lPos, (MPARAM)lPos);
449 else
450 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lPos, (USHORT)lPos), (MPARAM)0);
451} // end of wxTextCtrl::SetInsertionPoint
0e320a79
DW
452
453void wxTextCtrl::SetInsertionPointEnd()
454{
c4955899
DW
455 long lPos = GetLastPosition();
456
457 SetInsertionPoint(lPos);
458} // end of wxTextCtrl::SetInsertionPointEnd
0e320a79
DW
459
460long wxTextCtrl::GetInsertionPoint() const
461{
3bd418ca
DW
462 WXDWORD dwPos = 0L;
463
464 if (m_bIsMLE)
465 dwPos = (WXDWORD)::WinSendMsg(GetHwnd(), MLM_QUERYSEL, (MPARAM)MLFQS_MINSEL, 0);
466 else
467 {
468 dwPos = (WXDWORD)::WinSendMsg(GetHwnd(), EM_QUERYSEL, 0, 0);
469 dwPos = SHORT1FROMMP((MPARAM)dwPos); // the first 16 bit value is the min pos
470 }
471 return (dwPos & 0xFFFF);
472} // end of wxTextCtrl::GetInsertionPoint
0e320a79
DW
473
474long wxTextCtrl::GetLastPosition() const
475{
3bd418ca
DW
476 HWND hWnd = GetHwnd();
477 long lCharIndex;
478 long lLineLength;
0e320a79 479
3bd418ca
DW
480 if (m_bIsMLE)
481 {
482 lCharIndex = 0;
d90895ac 483
3bd418ca
DW
484 //
485 // This just gets the total text length. The last will be this value
486 //
487 lLineLength = (long)::WinSendMsg(hWnd, MLM_QUERYTEXTLENGTH, 0, 0);
488 }
489 else
490 {
491 WNDPARAMS vParams;
492
493 lCharIndex = 0;
494 vParams.fsStatus = WPM_CCHTEXT;
495 if (::WinSendMsg( GetHwnd()
496 ,WM_QUERYWINDOWPARAMS
497 ,&vParams
498 ,0
499 ))
500 {
501 lLineLength = (long)vParams.cchText;
502 }
503 else
504 lLineLength = 0;
505 }
506 return(lCharIndex + lLineLength);
507} // end of wxTextCtrl::GetLastPosition
0e320a79 508
d90895ac
DW
509// If the return values from and to are the same, there is no
510// selection.
c4955899
DW
511void wxTextCtrl::GetSelection(
512 long* plFrom
513, long* plTo
514) const
0e320a79 515{
c4955899 516 WXDWORD dwPos;
0e320a79 517
c4955899
DW
518 if (m_bIsMLE)
519 dwPos = (WXDWORD)::WinSendMsg(GetHwnd(), MLM_QUERYSEL, (MPARAM)MLFQS_MINSEL, 0);
520 else
521 {
522 dwPos = (WXDWORD)::WinSendMsg(GetHwnd(), EM_QUERYSEL, 0, 0);
523 }
524 *plFrom = SHORT1FROMMP((MPARAM)dwPos); // the first 16 bit value is the min pos
525 *plTo = SHORT2FROMMP((MPARAM)dwPos); // the first 16 bit value is the min pos
526} // end of wxTextCtrl::GetSelection
0e320a79 527
d90895ac
DW
528bool wxTextCtrl::IsEditable() const
529{
c4955899
DW
530 if (m_bIsMLE)
531 return((bool)LONGFROMMR(::WinSendMsg(GetHwnd(), MLM_QUERYREADONLY, 0, 0)));
532 else
533 return((bool)LONGFROMMR(::WinSendMsg(GetHwnd(), EM_QUERYREADONLY, 0, 0)));
534} // end of wxTextCtrl::IsEditable
0e320a79 535
d90895ac
DW
536// ----------------------------------------------------------------------------
537// Editing
538// ----------------------------------------------------------------------------
539
c4955899
DW
540void wxTextCtrl::Replace(
541 long lFrom
542, long lTo
543, const wxString& rsValue
544)
0e320a79 545{
d90895ac 546#if wxUSE_CLIPBOARD
c4955899
DW
547 HWND hWnd = GetHwnd();
548 long lFromChar = lFrom;
549 long lToChar = lTo;
0e320a79 550
c4955899 551 //
d90895ac 552 // Set selection and remove it
c4955899
DW
553 //
554 if (m_bIsMLE)
555 {
556 ::WinSendMsg(hWnd, MLM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
557 ::WinSendMsg(hWnd, MLM_CUT, 0, 0);
558 }
559 else
560 {
561 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
562 ::WinSendMsg(hWnd, EM_CUT, 0, 0);
563 }
0e320a79 564
c4955899 565 //
d90895ac 566 // Now replace with 'value', by pasting.
c4955899
DW
567 //
568 wxSetClipboardData(wxDF_TEXT, (wxObject *) (const wxChar *)rsValue, 0, 0);
0e320a79 569
d90895ac 570 // Paste into edit control
c4955899
DW
571 if (m_bIsMLE)
572 ::WinSendMsg(hWnd, MLM_PASTE, (MPARAM)0, (MPARAM)0);
573 else
574 ::WinSendMsg(hWnd, EM_PASTE, (MPARAM)0, (MPARAM)0);
d90895ac
DW
575#else
576 wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0.");
577#endif
c4955899 578} // end of wxTextCtrl::Replace
0e320a79 579
c4955899
DW
580void wxTextCtrl::Remove(
581 long lFrom
582, long lTo
583)
0e320a79 584{
c4955899
DW
585 HWND hWnd = GetHwnd();
586 long lFromChar = lFrom;
587 long lToChar = lTo;
d90895ac 588
c4955899
DW
589 if (m_bIsMLE)
590 {
591 ::WinSendMsg(hWnd, MLM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
592 ::WinSendMsg(hWnd, MLM_CUT, 0, 0);
593 }
594 else
595 {
596 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
597 ::WinSendMsg(hWnd, EM_CUT, 0, 0);
598 }
599} // end of wxTextCtrl::Remove
0e320a79 600
c4955899
DW
601void wxTextCtrl::SetSelection(
602 long lFrom
603, long lTo
604)
0e320a79 605{
c4955899
DW
606 HWND hWnd = GetHwnd();
607 long lFromChar = lFrom;
608 long lToChar = lTo;
d90895ac 609
c4955899
DW
610 //
611 // If from and to are both -1, it means (in wxWindows) that all text should
d90895ac 612 // be selected. Translate into Windows convention
c4955899
DW
613 //
614 if ((lFrom == -1L) && (lTo == -1L))
d90895ac 615 {
c4955899
DW
616 lFromChar = 0L;
617 lToChar = -1L;
d90895ac 618 }
c4955899
DW
619 if (m_bIsMLE)
620 ::WinSendMsg(hWnd, MLM_SETSEL, (MPARAM)lFromChar, (MPARAM)lToChar);
621 else
622 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFromChar, (USHORT)lToChar), (MPARAM)0);
623} // end of wxTextCtrl::SetSelection
d90895ac 624
c4955899
DW
625bool wxTextCtrl::LoadFile(
626 const wxString& rsFile
627)
0e320a79 628{
c4955899 629 if ( wxTextCtrlBase::LoadFile(rsFile) )
d90895ac 630 {
c4955899
DW
631 //
632 // Update the size limit if needed
633 //
d90895ac 634 AdjustSpaceLimit();
d90895ac
DW
635 return TRUE;
636 }
d90895ac 637 return FALSE;
c4955899 638} // end of wxTextCtrl::LoadFile
0e320a79
DW
639
640bool wxTextCtrl::IsModified() const
641{
c4955899
DW
642 bool bRc;
643
644 if (m_bIsMLE)
645 bRc = (bool)LONGFROMMR(::WinSendMsg(GetHwnd(), MLM_QUERYCHANGED, 0, 0));
646 else
647 bRc = (bool)LONGFROMMR(::WinSendMsg(GetHwnd(), EM_QUERYCHANGED, 0, 0));
648 return bRc;
649} // end of wxTextCtrl::IsModified
0e320a79 650
3bd418ca 651//
0e320a79 652// Makes 'unmodified'
3bd418ca 653//
0e320a79
DW
654void wxTextCtrl::DiscardEdits()
655{
3bd418ca
DW
656 if (m_bIsMLE)
657 ::WinSendMsg(GetHwnd(), MLM_SETCHANGED, MPFROMLONG(FALSE), 0);
658 else
659 //
660 // EM controls do not have a SETCHANGED but issuing a query should reset it
661 //
662 ::WinSendMsg(GetHwnd(), EM_QUERYCHANGED, 0, 0);
663} // end of wxTextCtrl::DiscardEdits
0e320a79
DW
664
665int wxTextCtrl::GetNumberOfLines() const
666{
c4955899 667 int nNumLines;
0e320a79 668
c4955899
DW
669 if (m_bIsMLE)
670 nNumLines = (int)::WinSendMsg(GetHwnd(), MLM_QUERYLINECOUNT, 0, 0);
671 else
672 nNumLines = 1;
673 return nNumLines;
674} // end of wxTextCtrl::GetNumberOfLines
d90895ac 675
c4955899
DW
676long wxTextCtrl::XYToPosition(
677 long lX
678, long lY
679) const
680{
681 HWND hWnd = GetHwnd();
682 long lCharIndex = 0L;
683 long lLen;
0e320a79 684
c4955899
DW
685 if (m_bIsMLE)
686 {
687 lLen = (long)::WinSendMsg(GetHwnd(), MLM_QUERYLINELENGTH, 0, 0);
688 lCharIndex = ((lLen * lY) + lX);
689 }
690 else
691 lCharIndex = lX;
692 return lCharIndex;
693} // end of wxTextCtrl::XYToPosition
694
695bool wxTextCtrl::PositionToXY(
696 long lPos
697, long* plX
698, long* plY
699) const
0e320a79 700{
c4955899
DW
701 HWND hWnd = GetHwnd();
702 long nLineNo = -1;
703 long lCharIndex = 0;
d90895ac 704
c4955899
DW
705 if (m_bIsMLE)
706 nLineNo = (long)::WinSendMsg(hWnd, MLM_LINEFROMCHAR, (MPARAM)lPos, 0);
707 else
708 nLineNo = 0;
d90895ac 709
c4955899 710 if (nLineNo == -1)
d90895ac
DW
711 {
712 // no such line
713 return FALSE;
714 }
715
c4955899 716 //
d90895ac 717 // This gets the char index for the _beginning_ of this line
c4955899
DW
718 //
719 long lLineWidth;
720
721 if (m_bIsMLE)
722 {
723 lLineWidth = (long)::WinSendMsg(hWnd, MLM_QUERYLINELENGTH, (MPARAM)0, (MPARAM)0);
724 lCharIndex = (nLineNo + 1) * lLineWidth;
725 }
726 else
727 {
728 WNDPARAMS vParams;
729
730 vParams.fsStatus = WPM_CCHTEXT;
731 if (::WinSendMsg( hWnd
732 ,WM_QUERYWINDOWPARAMS
733 ,&vParams
734 ,0
735 ))
736 {
737 lCharIndex = vParams.cchText;
738 }
739 else
740 lCharIndex = 32;
741 }
742
743 if (lCharIndex == -1)
d90895ac
DW
744 {
745 return FALSE;
746 }
747
c4955899
DW
748 //
749 // The X position must therefore be the difference between pos and charIndex
750 //
751 if (plX)
752 *plX = lPos - lCharIndex;
753 if (plY)
754 *plY = nLineNo;
d90895ac
DW
755
756 return TRUE;
c4955899 757} // end of wxTextCtrl::PositionToXY
0e320a79 758
c4955899
DW
759void wxTextCtrl::ShowPosition(
760 long lPos
761)
0e320a79 762{
c4955899
DW
763 HWND hWnd = GetHwnd();
764 long lCurrentLineLineNo = 0L;
d90895ac
DW
765
766 // To scroll to a position, we pass the number of lines and characters
767 // to scroll *by*. This means that we need to:
768 // (1) Find the line position of the current line.
769 // (2) Find the line position of pos.
770 // (3) Scroll by (pos - current).
771 // For now, ignore the horizontal scrolling.
772
c4955899 773 //
d90895ac
DW
774 // Is this where scrolling is relative to - the line containing the caret?
775 // Or is the first visible line??? Try first visible line.
c4955899
DW
776 //
777 if (m_bIsMLE)
778 {
779 //
780 // In PM this is the actual char position
781 //
782 lCurrentLineLineNo = (long)::WinSendMsg(hWnd, MLM_QUERYFIRSTCHAR, (MPARAM)0, (MPARAM)0);
d90895ac 783
c4955899
DW
784 //
785 // This will cause a scroll to the selected position
786 //
787 ::WinSendMsg(hWnd, MLM_SETSEL, (MPARAM)lCurrentLineLineNo, (MPARAM)lCurrentLineLineNo);
788 }
789} // end of wxTextCtrl::ShowPosition
0e320a79 790
3bd418ca
DW
791int wxTextCtrl::GetLineLength(
792 long lLineNo
793) const
0e320a79 794{
3bd418ca 795 long lLen = 0L;
d90895ac 796
3bd418ca
DW
797 if (m_bIsMLE)
798 lLen = (long)::WinSendMsg(GetHwnd(), MLM_QUERYLINELENGTH, 0, 0);
799 else
800 {
801 WNDPARAMS vParams;
802
803 vParams.fsStatus = WPM_CCHTEXT;
804 if (::WinSendMsg( GetHwnd()
805 ,WM_QUERYWINDOWPARAMS
806 ,&vParams
807 ,0
808 ))
809 {
810 lLen = vParams.cchText;
811 }
812 else
813 lLen = 32;
814 }
815 return lLen;
c4955899 816} // end ofwxTextCtrl::GetLineLength
0e320a79 817
c4955899
DW
818wxString wxTextCtrl::GetLineText(
819 long lLineNo
820) const
0e320a79 821{
c4955899
DW
822 long lLen = (long)GetLineLength((long)lLineNo) + 1;
823 wxString sStr;
824 char* zBuf;
0e320a79 825
c4955899
DW
826 //
827 // There must be at least enough place for the length WORD in the
828 // buffer
829 //
830 lLen += sizeof(WORD);
831 zBuf = new char[lLen];
832 if (m_bIsMLE)
833 {
834 long lIndex;
835 long lBuflen;
836 long lCopied;
0e320a79 837
c4955899
DW
838 lLen = (long)::WinSendMsg(GetHwnd(), MLM_QUERYLINELENGTH, 0, 0);
839 lIndex = lLen * lLineNo;
0e320a79 840
c4955899
DW
841 ::WinSendMsg(GetHwnd(), MLM_SETSEL, (MPARAM)lIndex, (MPARAM)lIndex);
842 ::WinSendMsg(GetHwnd(), MLM_SETIMPORTEXPORT, MPFROMP(zBuf), MPFROMSHORT((USHORT)sizeof(zBuf)));
843 lBuflen = (long)::WinSendMsg(GetHwnd(), MLM_QUERYFORMATTEXTLENGTH, MPFROMLONG(lIndex), MPFROMLONG(-1));
844 lCopied = (long)::WinSendMsg(GetHwnd(), MLM_EXPORT, MPFROMP(&lIndex), MPFROMP(&lBuflen));
845 zBuf[lCopied] = '\0';
846 }
847 else
848 {
849 WNDPARAMS vParams;
850
851 vParams.fsStatus = WPM_CCHTEXT;
852 if (::WinSendMsg( GetHwnd()
853 ,WM_QUERYWINDOWPARAMS
854 ,&vParams
855 ,0
856 ))
857 memcpy(zBuf, vParams.pszText, vParams.cchText);
858 zBuf[vParams.cchText] = '\0';
859 }
860 sStr = zBuf;
861 delete [] zBuf;
862 return sStr;
863} // end of wxTextCtrl::GetLineText
0e320a79 864
d90895ac 865// ----------------------------------------------------------------------------
0e320a79 866// Undo/redo
d90895ac
DW
867// ----------------------------------------------------------------------------
868
0e320a79
DW
869void wxTextCtrl::Undo()
870{
d90895ac
DW
871 if (CanUndo())
872 {
c4955899
DW
873 if (m_bIsMLE)
874 ::WinSendMsg(GetHwnd(), MLM_UNDO, 0, 0);
875 // Simple entryfields cannot be undone
d90895ac 876 }
c4955899 877} // end of wxTextCtrl::Undo
0e320a79
DW
878
879void wxTextCtrl::Redo()
880{
d90895ac
DW
881 if (CanRedo())
882 {
c4955899
DW
883 if (m_bIsMLE)
884 ::WinSendMsg(GetHwnd(), MLM_UNDO, 0, 0);
885 // Simple entryfields cannot be undone
d90895ac 886 }
c4955899 887} // end of wxTextCtrl::Redo
0e320a79
DW
888
889bool wxTextCtrl::CanUndo() const
890{
3bd418ca
DW
891 bool bOk;
892
893 if (m_bIsMLE)
894 bOk = (::WinSendMsg(GetHwnd(), MLM_QUERYUNDO, 0, 0) != 0);
895 else
896 bOk = FALSE; // can't undo regular edit fields in PM
897 return bOk;
898} // end of wxTextCtrl::CanUndo
0e320a79
DW
899
900bool wxTextCtrl::CanRedo() const
901{
3bd418ca
DW
902 bool bOk;
903
904 if (m_bIsMLE)
905 bOk = (::WinSendMsg(GetHwnd(), MLM_QUERYUNDO, 0, 0) != 0);
906 else
907 bOk = FALSE; // can't undo regular edit fields in PM
908 return bOk;
909} // end of wxTextCtrl::CanRedo
0e320a79 910
d90895ac
DW
911// ----------------------------------------------------------------------------
912// implemenation details
913// ----------------------------------------------------------------------------
0e320a79 914
c4955899
DW
915void wxTextCtrl::Command(
916 wxCommandEvent& rEvent
917)
0e320a79 918{
c4955899
DW
919 SetValue(rEvent.GetString());
920 ProcessCommand (rEvent);
921} // end of wxTextCtrl::Command
0e320a79 922
c4955899
DW
923void wxTextCtrl::OnDropFiles(
924 wxDropFilesEvent& rEvent
925)
0e320a79
DW
926{
927 // By default, load the first file into the text window.
c4955899 928 if (rEvent.GetNumberOfFiles() > 0)
0e320a79 929 {
c4955899 930 LoadFile(rEvent.GetFiles()[0]);
0e320a79 931 }
c4955899
DW
932} // end of wxTextCtrl::OnDropFiles
933
934WXHBRUSH wxTextCtrl::OnCtlColor(
935 WXHDC hWxDC
936, WXHWND hWnd
937, WXUINT uCtlColor
938, WXUINT uMessage
939, WXWPARAM wParam
940, WXLPARAM lParam
941)
d90895ac 942{
c4955899
DW
943 HPS hPS = (HPS)hWxDC;
944 wxBrush* pBrush = NULL;
945 wxColour vColBack = GetBackgroundColour();
946 wxColour vColFore = GetForegroundColour();
947 wxBrush* pBackgroundBrush = wxTheBrushList->FindOrCreateBrush( GetBackgroundColour()
948 ,wxSOLID
949 );
950
951 if (m_bUseCtl3D)
952 {
953 HBRUSH hBrush = NULLHANDLE;
0e320a79 954
c4955899
DW
955 return hBrush;
956 }
957 if (GetParent()->GetTransparentBackground())
958 ::GpiSetBackMix(hPS, BM_LEAVEALONE);
959 else
960 ::GpiSetBackMix(hPS, BM_OVERPAINT);
961 if (!IsEnabled() && (GetWindowStyle() & wxTE_MULTILINE) == 0)
a756f210 962 vColBack = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
c4955899
DW
963 ::GpiSetBackColor(hPS, vColBack.GetPixel());
964 ::GpiSetColor(hPS, vColFore.GetPixel());
965 return (WXHBRUSH)pBackgroundBrush->GetResourceHandle();
966} // end of wxTextCtrl::OnCtlColor
967
968void wxTextCtrl::OnChar(
969 wxKeyEvent& rEvent
970)
0e320a79 971{
c4955899 972 switch (rEvent.KeyCode())
d90895ac 973 {
d90895ac
DW
974 case WXK_RETURN:
975 if ( !(m_windowStyle & wxTE_MULTILINE) )
976 {
c4955899
DW
977 wxCommandEvent vEvent(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
978
979 vEvent.SetEventObject(this);
980 if ( GetEventHandler()->ProcessEvent(vEvent))
d90895ac
DW
981 return;
982 }
983 //else: multiline controls need Enter for themselves
984
985 break;
986
987 case WXK_TAB:
988 // always produce navigation event - even if we process TAB
989 // ourselves the fact that we got here means that the user code
990 // decided to skip processing of this TAB - probably to let it
991 // do its default job.
992 //
993 // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
994 // handled by Windows
995 {
c4955899 996 wxNavigationKeyEvent vEventNav;
d90895ac 997
c4955899
DW
998 vEventNav.SetDirection(!rEvent.ShiftDown());
999 vEventNav.SetWindowChange(FALSE);
1000 vEventNav.SetEventObject(this);
1001
1002 if ( GetEventHandler()->ProcessEvent(vEventNav) )
d90895ac
DW
1003 return;
1004 }
1005 break;
d90895ac 1006 }
c4955899
DW
1007 rEvent.Skip();
1008} // end of wxTextCtrl::OnChar
0e320a79 1009
c4955899
DW
1010bool wxTextCtrl::OS2Command(
1011 WXUINT uParam
1012, WXWORD WXUNUSED(vId)
1013)
0e320a79 1014{
c4955899 1015 switch (uParam)
d90895ac 1016 {
d90895ac
DW
1017 case EN_SETFOCUS:
1018 case EN_KILLFOCUS:
1019 {
c4955899
DW
1020 wxFocusEvent vEvent( uParam == EN_KILLFOCUS ? wxEVT_KILL_FOCUS
1021 : wxEVT_SET_FOCUS
1022 ,m_windowId
1023 );
1024
1025 vEvent.SetEventObject(this);
1026 GetEventHandler()->ProcessEvent(vEvent);
d90895ac
DW
1027 }
1028 break;
1029
1030 case EN_CHANGE:
1031 {
c4955899
DW
1032 wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_UPDATED
1033 ,m_windowId
1034 );
1035
1036 InitCommandEvent(vEvent);
1037 vEvent.SetString((char*)GetValue().c_str());
1038 ProcessCommand(vEvent);
d90895ac
DW
1039 }
1040 break;
1041
c4955899
DW
1042 case EN_OVERFLOW:
1043 //
1044 // The text size limit has been hit - increase it
1045 //
d90895ac
DW
1046 AdjustSpaceLimit();
1047 break;
1048
c4955899
DW
1049 case EN_SCROLL:
1050 case EN_INSERTMODETOGGLE:
1051 case EN_MEMERROR:
1052 return FALSE;
d90895ac
DW
1053 default:
1054 return FALSE;
1055 }
1056
c4955899
DW
1057 //
1058 // Processed
1059 //
d90895ac 1060 return TRUE;
c4955899 1061} // end of wxTextCtrl::OS2Command
0e320a79 1062
d90895ac 1063void wxTextCtrl::AdjustSpaceLimit()
0e320a79 1064{
3bd418ca
DW
1065 unsigned int uLen = 0;
1066 unsigned int uLimit = 0;
d90895ac 1067
3bd418ca
DW
1068 uLen = ::WinQueryWindowTextLength(GetHwnd());
1069 if (m_bIsMLE)
1070 {
1071 uLimit = (unsigned int)::WinSendMsg( GetHwnd()
1072 ,MLM_QUERYTEXTLIMIT
1073 ,0
1074 ,0
1075 );
1076 }
1077 else
1078 {
1079 ENTRYFDATA* pEfd;
1080 WNDPARAMS vParams;
1081
1082 vParams.fsStatus = WPM_CBCTLDATA;
1083 vParams.cbCtlData = sizeof(ENTRYFDATA);
1084
1085 if (::WinSendMsg( GetHwnd()
1086 ,WM_QUERYWINDOWPARAMS
1087 ,&vParams
1088 ,0
1089 ))
1090 {
1091 pEfd = (ENTRYFDATA*)vParams.pCtlData;
1092 uLimit = (unsigned int)pEfd->cchEditLimit;
1093 }
d90895ac 1094 else
3bd418ca 1095 uLimit = 32; //PM's default
d90895ac 1096 }
3bd418ca
DW
1097 if (uLen >= uLimit)
1098 {
1099 uLimit = uLen + 0x8000; // 32Kb
1100 if (uLimit > 0xffff)
1101 {
1102 uLimit = 0L;
1103 }
1104 if (m_bIsMLE)
1105 ::WinSendMsg(GetHwnd(), MLM_SETTEXTLIMIT, MPFROMLONG(uLimit), 0);
1106 else
1107 ::WinSendMsg(GetHwnd(), EM_SETTEXTLIMIT, MPFROMLONG(uLimit), 0);
1108 }
1109} // end of wxTextCtrl::AdjustSpaceLimit
0e320a79 1110
d90895ac 1111bool wxTextCtrl::AcceptsFocus() const
0e320a79 1112{
c4955899
DW
1113 //
1114 // We don't want focus if we can't be edited
1115 //
d90895ac 1116 return IsEditable() && wxControl::AcceptsFocus();
c4955899 1117} // end of wxTextCtrl::Command
0e320a79 1118
e78c4d50 1119wxSize wxTextCtrl::DoGetBestSize() const
0e320a79 1120{
c4955899
DW
1121 int nCx;
1122 int nCy;
0e320a79 1123
c4955899 1124 wxGetCharSize(GetHWND(), &nCx, &nCy, (wxFont*)&GetFont());
d90895ac 1125
c4955899 1126 int wText = DEFAULT_ITEM_WIDTH;
987da0d4 1127 int hText = (EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * .8);
c4955899
DW
1128
1129 if (m_windowStyle & wxTE_MULTILINE)
d90895ac
DW
1130 {
1131 hText *= wxMin(GetNumberOfLines(), 5);
1132 }
1133 //else: for single line control everything is ok
d90895ac 1134 return wxSize(wText, hText);
c4955899 1135} // end of wxTextCtrl::DoGetBestSize
0e320a79 1136
d90895ac
DW
1137// ----------------------------------------------------------------------------
1138// standard handlers for standard edit menu events
1139// ----------------------------------------------------------------------------
1140
c4955899
DW
1141void wxTextCtrl::OnCut(
1142 wxCommandEvent& rEvent
1143)
0e320a79
DW
1144{
1145 Cut();
c4955899 1146} // end of wxTextCtrl::OnCut
0e320a79 1147
c4955899
DW
1148void wxTextCtrl::OnCopy(
1149 wxCommandEvent& rEvent
1150)
0e320a79
DW
1151{
1152 Copy();
c4955899 1153} // end of wxTextCtrl::OnCopy
0e320a79 1154
c4955899
DW
1155void wxTextCtrl::OnPaste(
1156 wxCommandEvent& rEvent
1157)
0e320a79
DW
1158{
1159 Paste();
c4955899 1160} // end of wxTextCtrl::OnPaste
0e320a79 1161
c4955899
DW
1162void wxTextCtrl::OnUndo(
1163 wxCommandEvent& rEvent
1164)
0e320a79
DW
1165{
1166 Undo();
c4955899 1167} // end of wxTextCtrl::OnUndo
0e320a79 1168
c4955899
DW
1169void wxTextCtrl::OnRedo(
1170 wxCommandEvent& rEvent
1171)
0e320a79
DW
1172{
1173 Redo();
c4955899 1174} // end of wxTextCtrl::OnRedo
0e320a79 1175
c4955899
DW
1176void wxTextCtrl::OnUpdateCut(
1177 wxUpdateUIEvent& rEvent
1178)
0e320a79 1179{
c4955899
DW
1180 rEvent.Enable(CanCut());
1181} // end of wxTextCtrl::OnUpdateCut
0e320a79 1182
c4955899
DW
1183void wxTextCtrl::OnUpdateCopy(
1184 wxUpdateUIEvent& rEvent
1185)
0e320a79 1186{
c4955899
DW
1187 rEvent.Enable(CanCopy());
1188} // end of wxTextCtrl::OnUpdateCopy
0e320a79 1189
c4955899
DW
1190void wxTextCtrl::OnUpdatePaste(
1191 wxUpdateUIEvent& rEvent
1192)
0e320a79 1193{
c4955899
DW
1194 rEvent.Enable(CanPaste());
1195} // end of wxTextCtrl::OnUpdatePaste
0e320a79 1196
c4955899
DW
1197void wxTextCtrl::OnUpdateUndo(
1198 wxUpdateUIEvent& rEvent
1199)
0e320a79 1200{
c4955899
DW
1201 rEvent.Enable(CanUndo());
1202} // end of wxTextCtrl::OnUpdateUndo
1203
1204void wxTextCtrl::OnUpdateRedo(
1205 wxUpdateUIEvent& rEvent
1206)
1207{
1208 rEvent.Enable(CanRedo());
1209} // end of wxTextCtrl::OnUpdateRedo
0e320a79 1210
c4955899
DW
1211bool wxTextCtrl::SetBackgroundColour(
1212 const wxColour& rColour
1213)
0e320a79 1214{
c4955899
DW
1215 if (m_bIsMLE)
1216 ::WinSendMsg(GetHwnd(), MLM_SETBACKCOLOR, (MPARAM)rColour.GetPixel(), MLE_INDEX);
1217 return TRUE;
1218} // end of wxTextCtrl::SetBackgroundColour
1219
1220bool wxTextCtrl::SetForegroundColour(
1221 const wxColour& rColour
1222)
1223{
1224 if (m_bIsMLE)
1225 ::WinSendMsg(GetHwnd(), MLM_SETTEXTCOLOR, (MPARAM)rColour.GetPixel(), MLE_INDEX);
1226 return TRUE;
1227} // end of wxTextCtrl::SetForegroundColour
d90895ac 1228
39c26ef2
DW
1229bool wxTextCtrl::SetStyle(
1230 long lStart
1231, long lEnd
1232, const wxTextAttr& rStyle
1233)
1234{
1235 HWND hWnd = GetHwnd();
1236
1237 if (lStart > lEnd)
1238 {
1239 long lTmp = lStart;
1240
1241 lStart = lEnd;
1242 lEnd = lTmp;
1243 }
1244
1245 //
1246 // We can only change the format of the selection, so select the range we
1247 // want and restore the old selection later
1248 //
1249 long lStartOld;
1250 long lEndOld;
1251
1252 GetSelection( &lStartOld
1253 ,&lEndOld
1254 );
1255
1256 //
1257 // But do we really have to change the selection?
1258 //
1259 bool bChangeSel = lStart != lStartOld ||
1260 lEnd != lEndOld;
1261
1262 if (bChangeSel)
1263 {
1264 if (m_bIsMLE)
1265 ::WinSendMsg(hWnd, MLM_SETSEL, MPFROM2SHORT((USHORT)lStart, (USHORT)lEnd), 0);
1266 else
1267 ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lStart, (USHORT)lEnd), 0);
1268 }
1269
1270 //
1271 // TODO:: finish this part
1272 //
1273 return TRUE;
1274} // end of wxTextCtrl::SetStyle
1275