使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 0408576e9da10015ffa9da0079b8c985113ce4b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/**
 * Copyright (C) 2014-2050 SOUIÍŶÓ
 * All rights reserved.
 * 
 * @file       SDateTimeEdit.h
 * @brief      Í¨Óÿؼþ
 * @version    v1.0      
 * @author     soui      
 * @date       2014-06-27
 * 
 * Describe    Ê±¼ä¿Ø¼þ
 */
 
#pragma once
 
#include <control/SRichEdit.h>
#include <helper/STime.h>
 
namespace SOUI{
 
//===========================================================================
// Summary:
//     SMaskEdit is a CXTPEdit derived class. It allows text masking to be
//     applied to the control to format it for special editing restrictions.
//===========================================================================
/**
 * @class      SMaskEdit
 * @brief      ÒþÂëÊäÈë¿ò
 * 
 * Describe    ÒþÂëÊäÈë¿ò  Ö÷ÒªÓÃÓڹ̶¨ÊäÈë¸ñʽ
 */
class SMaskEdit : public SEdit
{
    SOUI_CLASS_NAME(SMaskEdit, L"maskedit")
 
public:
    /**
     * SMaskEdit::SMaskEdit
     * @brief    ¹¹Ô캯Êý
     *
     * Describe  ¹¹Ô캯Êý
     */
    SMaskEdit();
    /**
     * SMaskEdit::CanUseMask
     * @brief    ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     * @return   ·µ»ØBOOL
     * 
     * Describe  ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     */
    BOOL CanUseMask() const;
    /**
     * SMaskEdit::SetUseMask
     * @brief    ÉèÖÃmask¹¦ÄÜ
     * @param    BOOL bUseMask  -- TRUE FALSE
     * 
     * Describe  ÉèÖÃmask¹¦ÄÜ
     */
    void SetUseMask(BOOL bUseMask);
    /**
     * SMaskEdit::CanOverType
     * @brief    ÊÇ·ñÆôÓøÄд¹¦ÄÜ
     * @param    ·µ»ØBOOL
     * 
     * Describe  ÊÇ·ñÆôÓøÄд¹¦ÄÜ
     */
    BOOL CanOverType() const;
 
    /**
     * SMaskEdit::SetOverType
     * @brief    ÉèÖøÄд¹¦ÄÜ
     * @param    BOOL bOverType  -- TRUE FALSE     
     * 
     * Describe  ÉèÖøÄд¹¦ÄÜ
     */    
    void SetOverType(BOOL bOverType);
 
    /**
     * SMaskEdit::PosInRange
     * @brief    ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     * @param    ·µ»ØBOOL
     * 
     * Describe  ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     */
    BOOL PosInRange(int nPos) const;
 
    /**
     * SMaskEdit::CanUseMask
     * @brief    ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     * @param    ·µ»ØBOOL
     * 
     * Describe  ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     */
    TCHAR GetPromptChar() const;
    /**
     * SMaskEdit::CanUseMask
     * @brief    ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     * @param    ·µ»ØBOOL
     * 
     * Describe  ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     */    
    SStringT GetPromptString(int nLength) const;
    /**
     * SMaskEdit::CanUseMask
     * @brief    ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     * @param    ·µ»ØBOOL
     * 
     * Describe  ÊÇ·ñÆôÓÃmask¹¦ÄÜ
     */  
    void  SetPromptChar(TCHAR ch, BOOL bAutoReplace = TRUE);
 
 
    BOOL            MaskCut();
    BOOL            MaskCopy();
    void            MaskReplaceSel(LPCTSTR lpszNewText);
    BOOL            MaskPaste();
    void            MaskDeleteSel();
    BOOL            MaskClear();
    void            MaskSelectAll();
    BOOL            IsModified() const;
    void            SetMaskedText(LPCTSTR lpszMaskedText, int nPos = 0, BOOL bUpdateWindow = TRUE);
    virtual BOOL    SetEditMask(LPCTSTR lpszMask, LPCTSTR lpszLiteral, LPCTSTR lpszDefault=NULL);
    TCHAR           ConvertUnicodeAlpha(TCHAR nChar, BOOL bUpperCase) const;
    virtual BOOL    CheckChar(TCHAR& nChar, int nPos);
    virtual BOOL    ProcessMask(TCHAR& nChar, int nEndPos);
 
    void            DeleteCharAt(int nPos);
    void            InsertCharAt(int nPos, TCHAR nChar);
 
    SStringT         GetMaskedText(int nStartPos = 0, int nEndPos = -1) const;
 
    void            GetMaskState(BOOL bCorrectSelection = TRUE);
    void            SetMaskState();
 
    void            MaskGetSel();
 
    BOOL            CopyToClipboard(const SStringT& strText);
 
    BOOL            IsPromptPos(int nPos) const;
    BOOL            IsPromptPos(const SStringT& strLiteral, int nPos) const;
 
    BOOL            CorrectPosition(int& nPos, BOOL bForward = TRUE);
 
    void            CorrectWindowText();
 
    virtual BOOL    IsPrintChar(TCHAR nChar);
    virtual BOOL    IsAlphaChar(TCHAR nChar);
    virtual void    NotifyPosNotInRange();
    virtual void    NotifyInvalidCharacter(TCHAR /*nChar*/, TCHAR /*chMask*/);
    void            ProcessChar(TCHAR nChar);
 
protected:
  
    /**
     * SMaskEdit::OnCreate
     * @brief    ´´½¨ÏûÏ¢ÏìÓ¦º¯Êý
     * @param    LPVOID
     * @return   ·µ»ØÖµint
     *
     * Describe  ´Ëº¯ÊýÊÇÏûÏ¢ÏìÓ¦º¯Êý
     */
    int  OnCreate(LPVOID);
  
    /**
     * SMaskEdit::OnChar
     * @brief    ×Ö·ûÏûÏ¢
     * @param    UINT nChar -- °´¼ü¶ÔÓ¦µÄÂëÖµ 
     * @param    UINT nRepCnt -- Öظ´´ÎÊý
     * @param    UINT nFlags -- ±êÖ¾
     * 
     * Describe  ´Ëº¯ÊýÊÇÏûÏ¢ÏìÓ¦º¯Êý
     */ 
    void  OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  
    /**
     * SMaskEdit::OnKeyDown
     * @brief    ¼üÅ̰´ÏÂʼþ
     * @param    UINT nChar -- °´¼ü¶ÔÓ¦µÄÂëÖµ 
     * @param    UINT nRepCnt -- Öظ´´ÎÊý
     * @param    UINT nFlags -- ±êÖ¾
     * 
     * Describe  ´Ëº¯ÊýÊÇÏûÏ¢ÏìÓ¦º¯Êý
     */ 
    void  OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  
    /**
     * SMaskEdit::OnSetFocus
     * @brief    ÉèÖý¹µã
     * 
     * Describe  ´Ëº¯ÊýÊÇÏûÏ¢ÏìÓ¦º¯Êý
     */
    void  OnSetFocus(SWND wndOld);
protected:
    int             m_nStartChar;       // Current position of the first character in the current selection.
    int             m_nEndChar;         // Current position of the first non-selected character past the end of the current selection.
    BOOL            m_bUseMask;         // TRUE to use the edit mask.
    BOOL            m_bOverType;        // TRUE to over type the text, set with VK_INSERT key press.
    BOOL            m_bModified;        // TRUE if mask edit has been modified.
    TCHAR           m_chPrompt;         // Prompt character used to identify the text entry.
    SStringT         m_strMask;          // Buffer that holds the actual edit mask value.
    SStringT         m_strDefault;       // Contains the edit controls default display text.
    SStringT         m_strWindowText;    // Buffer that holds the actual edit text.
    SStringT         m_strLiteral;       // Literal format that restricts where the user can enter text.
 
protected:
   SOUI_MSG_MAP_BEGIN()
        MSG_WM_CREATE(OnCreate)
        MSG_WM_CHAR(OnChar)
        MSG_WM_KEYDOWN(OnKeyDown)
        MSG_WM_SETFOCUS_EX(OnSetFocus)
   SOUI_MSG_MAP_END()
};
 
/**
 * @class      SDateEdit
 * @brief      ÈÕÆÚ±à¼­¿ò
 * 
 * Describe    ÈÕÆÚ±à¼­¿ò
 */
class  SDateEdit : public SMaskEdit
{
    SOUI_CLASS_NAME(SDateEdit, L"dateedit")
 
public:
      
    /**
     * SDateEdit::SDateEdit
     * @brief    ¹¹Ô캯Êý
     *
     * Describe  ¹¹Ô캯Êý
     */
    SDateEdit();
    /**
     * SDateEdit::SetDateTime
     * @brief    ÉèÖÃÈÕÆÚ
     * @param    LPCTSTR strDate -- ÈÕÆÚ×Ö·û´®
     *
     * Describe  ÉèÖÃÈÕÆÚ
     */
    virtual void SetDateTime(LPCTSTR strDate);
    /**
     * SDateEdit::SetDateTime
     * @brief    ÉèÖÃÈÕÆÚ
     * @param    CTime tm -- ÈÕÆÚÀà¶ÔÏó
     *
     * Describe  ÉèÖÃÈÕÆÚ
     */
    virtual void SetDateTime(CTime tm);
    
    /**
     * SDateEdit::GetWindowDateTime
     * @brief    »ñȡϵͳʱ¼ä
     * @return   SStringT ·µ»Ø×Ö·û´®    
     *
     * Describe  »ñȡϵͳʱ¼ä
     */
    virtual SStringT GetWindowDateTime();
       
    virtual BOOL    ProcessMask(TCHAR& nChar, int nEndPos);
protected:
    /**
     * SDateEdit::OnCreate
     * @brief    ÏûÏ¢ÏìÓ¦º¯Êý
     * @return   int    
     *
     * Describe  ÏûÏ¢ÏìÓ¦º¯Êý
     */
    int OnCreate(LPVOID);
 
protected:
   SOUI_MSG_MAP_BEGIN()
        MSG_WM_CREATE(OnCreate)
   SOUI_MSG_MAP_END()
};
 
//===========================================================================
//  CDxTimeEdit
/**
 * @class      STimeEdit
 * @brief      Ê±¼ä±à¼­¿ò
 * 
 * Describe    Ê±¼ä±à¼­¿ò
 */
class  STimeEdit : public SDateEdit
{
    SOUI_CLASS_NAME(STimeEdit, L"timeedit")
 
public:
    /**
     * STimeEdit::STimeEdit
     * @brief    ¹¹Ô캯Êý
     *
     * Describe  ¹¹Ô캯Êý
     */
    STimeEdit();
 
public:
    
    /**
     * SDateEdit::SetHours
     * @brief    ÉèÖÃСʱ
     *
     * Describe  ÉèÖÃСʱ
     */
    virtual void    SetHours(int nHours);
    /**
     * SDateEdit::SetMins
     * @brief    ÉèÖ÷ÖÖÓ
     *
     * Describe  ÉèÖ÷ÖÖÓ
     */
    virtual void    SetMins(int nMins);
    /**
     * SDateEdit::SetTime
     * @brief    ÉèÖÃʱ¼ä
     * @param    int nHours -- Ð¡Ê±
     * @param    int nMins  -- ·ÖÖÓ
     *
     * Describe  ÉèÖÃʱ¼ä
     */
    virtual void    SetTime(int nHours, int nMins);
    /**
     * SDateEdit::GetHours
     * @brief    »ñȡСʱ
     * @return   ·µ»Øint
     *
     * Describe  »ñȡСʱ
     */
 
    int             GetHours() const;
    /**
     * SDateEdit::GetMins
     * @brief    »ñÈ¡·ÖÖÓ
     * @return   ·µ»Øint
     *
     * Describe  ÉèÖ÷ÖÖÓ
     */
 
    int             GetMins() const;
 
    virtual BOOL    ProcessMask(TCHAR& nChar, int nEndPos);
    void            SetMilitary(BOOL bMilitary = TRUE);
 
protected:
    int             m_nHours;  /**< Ð¡Ê± */
    int             m_nMins;   /**< ·ÖÖÓ */
    BOOL            m_bMilitary; /**<  */
 
protected:
    /**
     * STimeEdit::OnCreate
     * @brief    ÏûÏ¢ÏìÓ¦º¯Êý
     * @return   int    
     *
     * Describe  ÏûÏ¢ÏìÓ¦º¯Êý
     */
    int             OnCreate(LPVOID);
 
protected:
   SOUI_MSG_MAP_BEGIN()
        MSG_WM_CREATE(OnCreate)
   SOUI_MSG_MAP_END()
};
 
//////////////////////////////////////////////////////////////////////
inline int STimeEdit::GetHours() const
{
    return m_nHours;
}
 
inline int STimeEdit::GetMins() const
{
    return m_nMins;
}
 
inline void STimeEdit::SetMilitary(BOOL bMilitary)
{
    m_bMilitary = bMilitary;
 
}
 
 
}//end of namespace