From 85ba63a61f314bbe19c678fd4ccd32ef0e253875 Mon Sep 17 00:00:00 2001
From: LiFan <2308045698@qq.com>
Date: 星期二, 02 七月 2024 10:43:40 +0800
Subject: [PATCH] update

---
 jrj/project/vindexform.cpp |  454 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 443 insertions(+), 11 deletions(-)

diff --git a/jrj/project/vindexform.cpp b/jrj/project/vindexform.cpp
index 7707025..a229ce7 100644
--- a/jrj/project/vindexform.cpp
+++ b/jrj/project/vindexform.cpp
@@ -10,6 +10,7 @@
 #include "xcontrol/xcombobox.hpp"
 #include "xcontrol/xlayersheet.hpp"
 
+using xml = KXMLDOMDocument;
 class __declspec(dllexport) vindexform: public xwin
 {
 public:
@@ -21,6 +22,20 @@
 	xcombobox cbx_panelNo;
 	xcombobox cbx_tab;
 
+	
+	xcombobox memuId; //椤电鏁扮粍
+	xcombobox tabNo; //椤电椤哄簭鏁扮粍
+	xcombobox panelNo; //椤电鏁扮粍
+	xcombobox panelName; //椤电椤哄簭鏁扮粍
+
+	int m_npHwnd; //鑿滃崟鏍戠獥鍙e彞鏌�
+	int m_nHwnd; //鑿滃崟鏍戠獥鍙e彞鏌�
+	int m_cursheet; //褰撳墠椤电
+	int menuShow;
+
+	int m_npHwnd2; //openwindow
+	int m_startwin;
+
 public:
 	vindexform(void* implPtr,HWND hWnd):xwin(implPtr,hWnd){}
 public:
@@ -29,6 +44,54 @@
 		return  new vindexform(implPtr,(HWND)hWnd);
 	}
 public:
+
+
+	xstring getHomeConfig(xstring att)
+	{
+		xml x ;
+		x.load(L"cache\\config.xml");
+		//alert(x.GetXml());
+		if (x.xml() == L"") return L"";
+		KXMLDOMElement e = x.documentElement();
+		if (e.selectSingleNode(L"home"))
+		{
+			KXMLDOMElement e1 = e.selectSingleNode(L"home");
+			if (e1.selectSingleNode(L"@" + att))
+				return e1.selectSingleNode(L"@" + att).text();
+		}
+		return L"";
+	}
+
+	int setHomeConfig(xstring att, xstring value)
+	{
+		xml x ;
+		x.load(L"cache\\config.xml");
+		if (x.xml() == L"")
+		{
+			//alert(L"<config><home "+att+L"=L"+value+L"/></config>");
+			x.loadXML(L"<config><home " + att + L"='" + value + L"'/></config>");
+		}
+		else
+		{
+			KXMLDOMElement e = x.documentElement();
+			if (e.selectSingleNode(L"home"))
+			{
+				KXMLDOMElement e1 = e.selectSingleNode(L"home");
+				e1.setAttribute(att, value);
+			}
+			else
+			{
+				KXMLDOMElement e2 = x.createElement(L"home");
+				e2.setAttribute(att, value);
+				e.appendChild(e2);
+			}
+			//alert(e.xml);
+		}
+		//alert(x.GetXml());
+		xutil::SaveToFile(L"cache\\config.xml", x.xml(), L"", L"", (LPTSTR)L"");
+		return 1;
+	}
+
 	int OnDWClick(TEvent* evt, int p)
 	{
 		alert(L"clicked");
@@ -83,28 +146,329 @@
 		
 		return 1;
 	}
+	int OnMenuAgent(xstring f)
+	{
+		int LayerFlow_None = 0x00000001;
+		int LayerFlow_UnLayer = 0x00000100;
+		int LayerFlow_NS = 0x00000004;
+		int LayerFlow_Control = 0x00000010;
+		int GWL_STYLE = -16;
+		int WS_POPUP = 0x80000000;
+		int WS_CHILD = 0x40000000;
+		int WS_MAXIMIZE = 0x00010000;
+		int SW_MAXIMIZE = 3;
+		int HWND_TOPMOST = -1;
+		int HWND_NOTOPMOST = -2;
+		int SWP_NOSIZE = 0x0001;
+		int SWP_NOMOVE = 0x0002;
+		int SWP_SHOWWINDOW = 0x0040;
+		SetWindowPos(m_nHwnd, HWND_TOPMOST, -1000, -1000, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+		int style = GetWindowLong(m_nHwnd, GWL_STYLE);
+		xnode anode = GetAgentNode(L"menuAgent");
+		xnode bnode = GetAgentNode(L"xmMenu");
+		int isshow = menuShow;
+		if (isshow == -1)
+		{
+			anode.SetLayerFlow(LayerFlow_NS | LayerFlow_Control);
+			bnode.SetLayerFlow(LayerFlow_None | LayerFlow_UnLayer);
 
+			style = style - WS_POPUP;
+			style = style + WS_CHILD;
+			xwin::SetWindowLong(m_nHwnd, GWL_STYLE, style);
+
+			m_npHwnd = xwin::GetParent(m_nHwnd);
+			xcontrol xc = GetControl(L"menuAgent");
+			xwin::SetParent(m_nHwnd, xc.GetId());
+			xwin::ShowWindow(m_nHwnd, SW_MAXIMIZE);
+
+			///AttachEvent(L"WM_SIZE",OnMenuSizeChanged);	
+			//AttachEvent(L"WM_PAINT",OnMenuSizeChanged);	
+			//AttachEvent(L"WM_WINDOWPOSCHANGED",OnMenuSizeChanged);	
+		}
+		else
+		{
+			bnode.SetLayerFlow(LayerFlow_NS | LayerFlow_Control);
+			anode.SetLayerFlow(LayerFlow_None | LayerFlow_UnLayer);
+
+			style = style + WS_POPUP;
+			style = style - WS_CHILD;
+			xwin::SetWindowLong(m_nHwnd, GWL_STYLE, style);
+			xwin::SetParent(m_nHwnd, m_npHwnd);
+			OnMenu(L"");
+		}
+		menuShow = -1 - isshow;
+		xcombobox::SetCurSel(memuId.GetId(), menuShow);
+		if (f != L"")
+			setHomeConfig(L"menuposition", menuShow.toString());
+		return 1;
+	}
+
+	int ResetMenu()
+	{
+		//if(m_nHwnd) xwin::CloseWindow(m_nHwnd);
+		m_nHwnd = 0;
+
+		menuShow = -1;
+		xstring f = getHomeConfig(L"menuposition");
+		if (f == L"0")
+		{
+			OnMenu(L"");
+			OnMenuAgent(L"");
+		}
+
+		xaserverarg arg;
+	
+		int h = GetHWND();
+		arg.AddArg(L"hwnd", xstring(h));
+		
+		OpenWindow(L"dev:xpage[vindexforold.vx]", arg);
+
+		return 1;
+	}
+
+	int ReSetInfo()
+	{
+
+		xcombobox::ResetContent(memuId.GetId());
+		xcombobox::ResetContent(tabNo.GetId());
+		xcombobox::ResetContent(panelNo.GetId());
+		xcombobox::ResetContent(panelName.GetId());
+
+		int hItem = mainsheet.GetSheetCount();
+		while (hItem > 1)
+		{
+			//mainsheet.DeleteSheet(hItem - 1);
+			SendMessage(GetHWND(), 0x401, L"xmSheetClose", 0);
+			hItem = mainsheet.GetSheetCount();
+		}
+
+		xml x;
+		
+		xaserverarg arg;
+		
+		arg.AddArg(L"Assignment", m_Assignment);
+		//alert(arg.GetString());
+		if (xaserver::ExecXQuery(GetServerUrl(), L"[GetSysInfo.xq]", arg.GetString(), x) != 1)
+		{
+			//trace(x.GetXml());
+			return -1;
+		}
+		if (x.xml() == L"") return -1;
+		KXMLDOMElement e = x.documentElement();
+		if (/*m_Assignment == L"" &&*/ e.selectSingleNode(L"AssignmentID"))
+		{
+			xstring sInfoEx = e.selectSingleNode(L"AssignmentID").text();
+			m_Assignment = sInfoEx;
+		}
+
+		if (m_Assignment == L"")
+			alert(L"鑾峰彇鐢ㄦ埛鏁版嵁澶辫触锛岃閲嶆柊鐧诲綍!");
+		else
+			xaserver::SetUserId(m_Assignment);
+
+		xcombobox::AddItem(memuId.GetId(), L"寮�濮�");
+		xcombobox::AddItem(tabNo.GetId(), L"-1");
+		//OpenWindow(L"dev:xpage[vstart.vx]");
+		xcontrol xc = GetControl(L"statusbar0");
+		xc.SetText(L"姝e湪鍒濆鍖栫郴缁燂紝璇风◢鍊�....");
+		HCURSOR hCursor = xutil::SetCursorWait();
+		if (e.selectSingleNode(L"name"))
+		{
+			xstring sInfo = e.selectSingleNode(L"name").text();
+			xc.SetText(sInfo + L"  绯荤粺鐗堟湰:" + xaserver::GetVersion());
+		}
+
+		ResetMenu();
+		xutil::RestoreCursor(hCursor);
+		return 1;
+	}
+
+	int OnChangeLogin()
+	{
+		xml x;
+		
+		xaserverarg arg ;
+		
+		arg.AddArg(L"userno", xaserver::GetUserNo());
+		if (xaserver::ExecXQuery(GetServerUrl(), L"[GetSysAssignment.xq]", arg.GetString(), x) != 1)
+		{
+			trace(x.xml());
+			return -1;
+		}
+		if (x.xml() == L"") return -1;
+		KXMLDOMElement e = x.documentElement();
+		KXMLDOMNodeList li = e.selectNodes(L"item");
+		int i;
+		int s = li.length();
+		xstring sInfo = m_Assignment;
+		if (s > 0)
+		{
+			int m = xwin::CreatePopupMenu();
+			int MF_STRING = 0x00000000;
+			int MF_DISABLED = 0x00000002;
+			int TPM_RIGHTBUTTON = 0x0002;
+			int TPM_RETURNCMD = 0x0100;
+			int MF_CHECKED = 0x8;
+			for (i = 0; i < s; i++)
+			{
+				KXMLDOMElement xitem = li.item(i);
+				xstring id = xitem.selectSingleNode(L"AssignmentID").text();
+				xstring name = xitem.selectSingleNode(L"PositionName").text();
+				if (sInfo == id)
+					xwin::AppendMenu(m, MF_STRING | MF_CHECKED, i + 1, name);
+				else
+					xwin::AppendMenu(m, MF_STRING, i + 1, name);
+			}
+			xrect xr;
+			xpoint pt;
+			xwin::GetCursorPos(pt);
+			int res = xwin::TrackPopupMenu(m, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, GetHWND(), xr);
+			if (res == 0) return 0;
+			KXMLDOMElement ele = li.item(res - 1);
+			xstring sInfoEx = ele.selectSingleNode(L"AssignmentID").text();
+			if (m_Assignment == sInfoEx) return 0;
+			m_Assignment = sInfoEx;
+			ReSetInfo();
+			/*if(m_nHwnd)
+			{
+				win32::CloseWindow(m_nHwnd);
+			}*/
+		}
+		return 1;
+	}
+
+	int OnAllCaption()
+	{
+		int m = xwin::CreatePopupMenu();
+		int MF_STRING = 0x00000000;
+		int MF_DISABLED = 0x00000002;
+		int TPM_RIGHTBUTTON = 0x0002;
+		int TPM_RETURNCMD = 0x0100;
+		int MF_CHECKED = 0x8;
+
+		int k = mainsheet.GetSheetIndex();
+		//int cs = xcombobox::GetCount(memuId.GetId());
+		int cs = mainsheet.GetSheetCount();
+		int i;
+		for (i = 0; i < cs; i++) {
+			//string str = xcombobox::GetLBText(memuId.GetId(), i);
+			xstring str = mainsheet.GetSheetText(i);
+			if (i == k)
+				xwin::AppendMenu(m, MF_STRING | MF_CHECKED, i + 1, str);
+			else
+				xwin::AppendMenu(m, MF_STRING, i + 1, str);
+		}
+		xrect xr;
+		xpoint pt;
+		xwin::GetCursorPos(pt);
+		int res = xwin::TrackPopupMenu(m, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, this.GetHWND(), xr);
+		if (res == 0) return 0;
+		int nSheet = mainsheet.GetSheetIndex();
+		if (nSheet == (res - 1)) return 0;
+		mainsheet.SelectSheet(res - 1);
+		return 0;
+	}
+	int OnChangeSheet(xstring sheet)
+	{
+		if (sheet == L"") return 0;
+		int nIndex = sheet.toInt();
+		int curIndex = mainsheet.GetSheetIndex();
+		if (nIndex == curIndex)
+			return 0;
+		mainsheet.SelectSheet(nIndex);
+		return 1;
+	}
+	int OnMenuSizeChanged(TEvent* evt, int p)
+	{
+		/*xrect xr33;
+		xcontrol xc = GetControl(L"menuAgent");
+		xwin::GetWindowRect(xc.GetId(), xr33);
+		int l = xr33.left;
+		int b = xr33.right;
+		int xx = b - l;*/
+		//alert(xx.toString());
+		int isshow = menuShow;
+		if (isshow == 0)
+		{
+			int SW_MAXIMIZE = 3;
+			xcontrol xc = GetControl(L"menuAgent");
+			xwin::SetParent(m_nHwnd, xc.GetId());
+			xwin::ShowWindow(m_nHwnd, SW_MAXIMIZE);
+		}
+		return 1;
+	}
+	int OnOpen(xstring pa)
+	{
+		//xwin::SendMessage(m_npHwnd2, 0x401, pa, 0);
+		//return 1;
+		/*if(xaserver::GetUserNo() == L"admin")
+		{
+			OpenWindow(L"dev:xpage[vstart.vx]");
+			return 1;
+		}*/
+
+		int p = pa.toInt();
+		xaserverarg arg ;
+		
+		xstring isnew = arg.GetArgString(L"_isNewModule");
+		xstring vx = arg.GetArgString(L"_ModuelPage");
+		if (isnew == L"Y")
+		{
+			if (vx.find(L".vx", 0) > 0 || vx.find(L".xpage", 0) > 0)
+				OpenWindow(L"dev:xpage[" + vx + L"]", p);
+			else
+				openUrl(vx, p);
+			return 1;
+		}
+		OpenWindow(L"dev:xpage[vindexforold.vx]", p);
+		return 1;
+	}
+	int OnOpenForOld(xstring pa)
+	{
+		m_npHwnd2 = pa.toInt();
+
+		int GWL_STYLE = -16;
+		int WS_POPUP = 0x80000000;
+		int WS_CHILD = 0x40000000;
+		int SW_MAXIMIZE = 3;
+		int style = xwin::GetWindowLong(m_npHwnd2, GWL_STYLE);
+		style = style - WS_POPUP;
+		style = style + WS_CHILD;
+		xwin::SetWindowLong(m_npHwnd2, GWL_STYLE, style);
+
+		xcontrol xc = GetControl(L"openforold");
+		xwin::SetParent(m_npHwnd2, xc.GetId());
+
+		xwin::ShowWindow(m_npHwnd2, SW_MAXIMIZE);
+		return 1;
+	}
+
+	int OnHelp()
+	{
+		OpenWindow(L"dev:xpage[trade.help3.vx]");
+		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")
+		else if (comdid.find(L"menuid:", 0) >= 0) OnMenu(comdid.mid(comdid.find(L":", 0) + 1, comdid.length()));
+		else if (comdid.find(L"menuAgent:", 0) >= 0) OnMenuAgent(comdid.mid(comdid.find(L":", 0) + 1, comdid.length()));
+		else if (comdid.find(L"changesheet:", 0) >= 0) OnChangeSheet(comdid.mid(comdid.find(L":", 0) + 1, comdid.length()));
+		else if (comdid.find(L"openforoldid:", 0) >= 0) OnOpenForOld(comdid.mid(comdid.find(L":", 0) + 1, comdid.length()));
+		else if (comdid.find(L"open:", 0) >= 0) OnOpen(comdid.mid(comdid.find(L":", 0) + 1, comdid.length()));
+		else if (comdid == L"xmRefreshTask")
 		{
 			SendMessage(m_startwin, 0x401, comdid, 0);
 			return 1;
 		}
-#endif
+
 		return 0;
 	}
 	
@@ -116,11 +480,63 @@
 	int OnAttachListon()
 	{
 		AttachEvent(L"WM_XCOMMAND",(FEvent)&vindexform::OnXCommand,this);
-		//AttachEvent("mdilayer", "LYSN_SELECTEDSHEET",OnSheetChanged);	
-		////AttachEvent("mdilayer", "LYSN_CLOSESHEET",OnCloseSheet);	
+		//AttachEvent(L"mdilayer", L"LYSN_SELECTEDSHEET",OnSheetChanged);	
+		////AttachEvent(L"mdilayer", L"LYSN_CLOSESHEET",OnCloseSheet);	
 		return 1;
 	}
-	
+	int OnSheetChanged(TEvent* evt, int p)
+	{
+		ref LYSNMHDR nmtv = trust(evt.pnmh as ref LYSNMHDR);
+		int sheet = nmtv.nSheet;
+		int s = mainsheet.GetSheetCount();
+		//trace(s);
+		int cs = xcombobox::GetCount(memuId.GetId());
+		int cursheet = m_cursheet;
+
+		if (s > cs) {
+			xcombobox::AddItem(memuId.GetId(), L"鑷敱绐楀彛");
+			xcombobox::AddItem(tabNo.GetId(), cursheet.toString());
+		}
+		if (s < cs) {
+			xcombobox::DeleteItem(memuId.GetId(), cursheet);
+			int i = 0;
+			xstring value = xcombobox::GetLBText(tabNo.GetId(), cursheet);
+			for (i = 0; i < cs; i++)
+			{
+				xstring tabId = xcombobox::GetLBText(tabNo.GetId(), i);
+				if (tabId == cursheet.toString())
+				{
+					xcombobox::DeleteItem(tabNo.GetId(), i);
+					xcombobox::InsertString(tabNo.GetId(), i, value);
+				}
+			}
+			xcombobox::DeleteItem(tabNo.GetId(), cursheet);
+			if (sheet != value.toInt())
+				mainsheet.SelectSheet(value.toInt());
+		}
+
+		if (cursheet != mainsheet.GetSheetIndex())
+		{
+			int hPicture = xwin::FindWindowEx(0, 0, L"XFrameWndClass", L"__ProductPicture");
+			if (hPicture > 0)
+			{
+				int WM_CLOSE = 0x0010;
+				xwin::PostMessage(hPicture, WM_CLOSE, 0, 0);
+			}
+		}
+
+		m_cursheet = mainsheet.GetSheetIndex();
+		return 1;
+	}
+
+	int OnCloseSheet(TEvent* evt, int p)
+	{
+		ref LYSNMHDR nmtv = trust(evt.pnmh as ref LYSNMHDR);
+		int sheet = nmtv.nSheet;
+		//alert(L"xxxx");
+		return 1;
+	}
+
 	int SetUserID()
 	{
 		Hxsoft::XFrame::KXMLDOMDocument x;
@@ -147,6 +563,22 @@
 		return 1;
 	}
 
+	int OnInitial()
+	{
+		xstring userno = xaserver::GetUserNo();
+		if (userno == L"admin" /*|| userno==L"00206" || userno==L"00206" || userno==L"00201" ||userno==L"00101" */)
+		{
+			xnode anode = GetAgentNode(L"dev");
+			int LayerFlow_WE = 0x00000002;
+			int LayerFlow_Control = 0x00000010;
+			
+			anode.SetLayerFlow(LayerFlow_WE | LayerFlow_Control);
+		}
+		m_Assignment = L"";
+
+		return 1;
+	}
+
 	int Initial()
 	{
 		SetUserID();

--
Gitblit v1.9.3