xj qian
2024-06-27 e4b4c508c599943ddb22b7d4868ccd40ac05a043
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
#pragma once
 
#include "xview.hpp"
#include "kobject/kcontrol.hpp"
#include "kobject/kwin.hpp"
#include "win32/win.hpp"
#include "wobject/xstring.hpp"
using kwin=Hxsoft::XFrame::IXFWin;
using kcontrol = Hxsoft::XFrame::IXFControl;
 
class xcontrol: public xview
{
public:
    xcontrol(void * impl):xview(impl){}
public:
    int Redraw()
    {
        return ((kcontrol*)this->getNativePointer())->Redraw();
    }
    HWND GetHWND()
    {
        return ((kcontrol*)this->getNativePointer())->GetHWND();
    }
 
    int SetReadOnlyEx(const bool )
    {
        int EM_SETREADONLY = 0x00CF;
        return SendMessage(GetHWND(),EM_SETREADONLY,0,0);
    }
 
    int EnableWindow(bool abled)
    {
        return ::EnableWindow(GetHWND(),abled);
    }
    
    int GetTextLength()
    {
        int WM_GETTEXTLENGTH = 0x000E;
        int nLen = ::GetWindowTextLengthW(GetHWND());
        return nLen;
    }
 
    xstring GetText()
    {
        int WM_GETTEXT = 0x000D;
        int nLen = GetTextLength();
        
        xstring xs;
        GetWindowTextW(GetHWND(),xs.sure(nLen+1),nLen + 1);
        return xs;
    }
    
    int SetText(string value)
    {
        int WM_SETTEXT = 0x000C;
        ::SetWindowTextW(GetHWND(),value);
        return 1;
    }
 
    KXMLDOMElement GetElement()
    {
        return ((kcontrol*)this->getNativePointer())->GetElement();
    }
};