LiFan
2025-04-29 6c8c9ddaeb2bc6245a374c9354296bcfc2d96c06
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
 
#pragma once
 
#include "xcontrol/xdwtable.hpp"
#include "xcontrol/xdwgrid.hpp"
#include "wobject/xwin.hpp"
#include "wobject/xstring.hpp"
#include "wobject/xaserverarg.hpp"
#include "wobject/xaserver.hpp"
#include "xcontrol/xcombobox.hpp"
#include "xcontrol/xlayersheet.hpp"
 
class __declspec(dllexport) vindexformex: public xwin
{
public:
    string m_Assignment;
    HWND m_hMenu;
    xlayersheet mainsheet;
    xcombobox cbx_menu;
    xcombobox cbx_panelName;
    xcombobox cbx_panelNo;
    xcombobox cbx_tab;
 
public:
    vindexformex(void* implPtr,HWND hWnd):xwin(implPtr,hWnd){}
public:
    static vindexformex * CreateInstance(void* implPtr,void* hWnd)
    {
        return  new vindexformex(implPtr,(HWND)hWnd);
    }
public:
    int OnDWClick(TEvent* evt, int p)
    {
        alert(L"clicked");
        return 1;
    }
    int OnMenu(HWND hMenu)
    {
        if (!hMenu)
        {
            HWND hw = m_hMenu;
            bool f = IsWindow(hw);
 
            if (hw == 0 && f <= 0)
            {
                xaserverarg* arg = new xaserverarg();
                HWND hWnd = GetHWND();
                arg->SetParam(L"hwnd", (LPARAM)hWnd);
                arg->SetParam(L"memuId", (LPARAM)cbx_menu.getNativePointer());
                arg->SetParam(L"tabNo", (LPARAM)cbx_tab.getNativePointer());
                arg->SetParam(L"panelNo", (LPARAM)cbx_panelNo.getNativePointer());
                arg->SetParam(L"panelName", (LPARAM)cbx_panelName.getNativePointer());
                xwin* pwin=OpenWindow(L"dev:xpage[vindexmenu.vx]", (LPARAM)arg);
                m_hMenu = pwin->GetHWND();
                hw = m_hMenu;
                //return 1;
            }
            HWND HWND_TOPMOST = (HWND) - 1;
            HWND HWND_NOTOPMOST =(HWND)-2;
            int SWP_NOSIZE = 0x0001;
            int SWP_NOMOVE = 0x0002;
            int SWP_SHOWWINDOW = 0x0040;
            SetWindowPos(hw, HWND_TOPMOST, -1000, -1000, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
        }
        else
        {
            m_hMenu = hMenu;
        }
 
        xrect xr;
        xcontrol xc = GetControl(L"xmMenu");
        GetWindowRect(xc.GetHWND(), xr);
        int l = xr.left;
        int b = xr.bottom;
 
        xrect r;
        xc = GetControl(L"split");
        GetWindowRect(xc.GetHWND(), r);
        int t2 = r.top;
        int b2 = r.bottom;
 
        MoveWindow(m_hMenu, l - 7, b, 220, b2 - t2, true);
        
        return 1;
    }
 
    int OnCmdDispatch(xstring comdid)
    {
        if (comdid == L"xmMenu") OnMenu(0);
        //else if (comdid.find(L"menuid:", 0) >= 0)
        //    return OnMenu((HWND)comdid.mid(comdid.find(L":", 0) + 1, comdid.length()).toInt());
#if 0
        if (comdid ==L "xmAssignment") OnChangeLogin();
        else if (comdid == L"xmAllCaption") OnAllCaption();
        else if (comdid == L"xmMenu") OnMenu(L"");
        else if (comdid == L"xmHelp") return OnHelp();
        else if (comdid.find("menuid:", 0) >= 0) OnMenu(comdid.mid(comdid.find(":", 0) + 1, comdid.length()));
        else if (comdid.find("menuAgent:", 0) >= 0) OnMenuAgent(comdid.mid(comdid.find(":", 0) + 1, comdid.length()));
        else if (comdid.find("changesheet:", 0) >= 0) OnChangeSheet(comdid.mid(comdid.find(":", 0) + 1, comdid.length()));
        else if (comdid.find("openforoldid:", 0) >= 0) OnOpenForOld(comdid.mid(comdid.find(":", 0) + 1, comdid.length()));
        else if (comdid.find("open:", 0) >= 0) OnOpen(comdid.mid(comdid.find(":", 0) + 1, comdid.length()));
        else if (comdid == "xmRefreshTask")
        {
            SendMessage(m_startwin, 0x401, comdid, 0);
            return 1;
        }
#endif
        return 0;
    }
    
    int OnXCommand(TEvent* evt,int p)
    {
        return OnCmdDispatch(evt->xcommand.pStrID);
    }    
 
    int OnAttachListon()
    {
        AttachEvent(L"WM_XCOMMAND",(FEvent)&vindexformex::OnXCommand,this);
        //AttachEvent("mdilayer", "LYSN_SELECTEDSHEET",OnSheetChanged);    
        ////AttachEvent("mdilayer", "LYSN_CLOSESHEET",OnCloseSheet);    
        return 1;
    }
    
    int SetUserID()
    {
        Hxsoft::XFrame::KXMLDOMDocument x;
        xaserverarg arg;
        arg.AddArg(L"Assignment", m_Assignment);
        if(xaserver::ExecXQuery(GetServerUrl(),L"[GetSysInfo.xq]",arg.GetString(),x)!=1)
        {
            trace(x.xml());
            return -1;    
        }
        if((xstring)x.xml() == L"") return -1; 
 
        Hxsoft::XFrame::KXMLDOMElement e = x.documentElement();
        if((xstring)m_Assignment == L"" && e.selectSingleNode(L"AssignmentID"))
        {
            string sInfoEx = e.selectSingleNode(L"AssignmentID").text();
            m_Assignment = sInfoEx;
        }
        
        if((xstring)m_Assignment == L"")
            alert(L"获取用户数据失败,请重新登录!");
        else
            xaserver::SetUID((LPWSTR)m_Assignment);
        return 1;
    }
 
    int Initial()
    {
        SetUserID();
        return 1;
    }
    int onload()
    {
        m_hMenu = 0;
        m_Assignment = L"";
 
        mainsheet = GetControl(L"mdilayer");
        cbx_menu = GetControl(L"memuId");
        cbx_tab = GetControl(L"tabNo");
        cbx_panelNo = GetControl(L"panelNo");
        cbx_panelName = GetControl(L"panelName");
 
        Initial();
 
        OnAttachListon();
        OpenWindow(L"dev:xpage[start.vframe.vbusiness.vx]");
    
        return 1;
    }
    
 
 
};