// BOOL ViCbAddCtrl(HANDLE hCtrl, HANDLE hParent) SQInteger ViCbAddCtrl(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger hCtrl = 0; SQInteger hParent = 0; CContainerUI* pParentCtrl = NULL; CScriptMgr* pMgr = NULL; CPaintManagerUI* pPM = NULL; CControlUI* pCtrl = NULL; SQBool bRet = FALSE; if (!v || 2 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 3)) {goto _Exit_;} sq_getinteger(v, 2, &hCtrl); sq_getinteger(v, 3, &hParent); pCtrl = QiHwHandleToCtrl(hCtrl); pParentCtrl = (CContainerUI*)QiHwHandleToCtrl(hParent); if (!pCtrl) {goto _Exit_;} if (NULL == pParentCtrl) { pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} pParentCtrl = (CContainerUI*)pPM->GetRoot(); } if (!pParentCtrl || !pParentCtrl->IsContainer()) {goto _Exit_;} bRet = (SQBool)pParentCtrl->Add(pCtrl); _Exit_: sq_pushbool(v, bRet); return 1; }
// void VwUpdateLayout(HWND hWnd) SQInteger VwUpdateLayout(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger nWnd = 0; HWND hWnd = NULL; CPaintManagerUI* pPM = NULL; if (!v || 1 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} sq_getinteger(v, 2, &nWnd); if (-1 == nWnd) { CScriptMgr* pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} } else { pPM = QiHwHandleToWin(nWnd)->pWinObj->GetPM(); if (!pPM) {goto _Exit_;} } pPM->UpdateLayout(); _Exit_: return 1; }
// int VwGetPosHight(VApiHandle hWnd) SQInteger VwGetPosHight(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger nWnd = 0; WinMgrItem* pWin = NULL; HWND hWnd = NULL; SQInteger nRet = 0; RECT rc = {0}; if (!v || 1 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} sq_getinteger(v, 2, &nWnd); if (-1 == nWnd) { CScriptMgr* pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} CPaintManagerUI* pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} hWnd = pPM->GetPaintWindow(); } else { hWnd = QiHwHandleToWin(nWnd)->pWinObj->GetHWND(); } ::GetWindowRect(hWnd, &rc); nRet = rc.bottom - rc.top; _Exit_: sq_pushinteger(v, nRet); return 1; }
void CNotice::TypeInit(TNotifyUI& msg) { CPaintManagerUI* pPaintMgrUI = GetPaintMgr(); ASSERT(pPaintMgrUI); CTextUI* pLabel = static_cast<CTextUI*>(pPaintMgrUI->FindControl(noticeView::kUser)); if(pLabel){ pLabel->SetText(m_strText); } int iWidth = GetSystemMetrics(SM_CXSCREEN); int iHeight = GetSystemMetrics(SM_CYSCREEN);//计算的屏幕客户工作区域 MONITORINFO oMonitor = {}; oMonitor.cbSize = sizeof(oMonitor); ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor); CDuiRect rcWork = oMonitor.rcWork; RECT rcWnd; SIZE szInit = GetPaintMgr()->GetInitSize(); rcWnd.right = rcWork.right-1; rcWnd.left = rcWnd.right-szInit.cx; rcWnd.bottom = rcWork.bottom -1; rcWnd.top = rcWnd.bottom-szInit.cy; // MoveWindow(&rcWnd); HWND hWnd = GetForegroundWindow(); SetWindowPos(HWND_TOPMOST,&rcWnd,SWP_NOACTIVATE); SetForegroundWindow(hWnd); /* 设置初始皮肤 */ }
void CALLBACK CUICommandHistory::UIAdd(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strParentName = pElement->Attribute("parentname"); pElement->RemoveAttribute("parentname"); if(strParentName.IsEmpty()) return; CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); CPaintManagerUI* pManager = pUIView->GetPaintManager(); CControlUI* pParentControl = pManager->FindControl(StringConvertor::Utf8ToWide(strParentName)); if(pParentControl == NULL) return; TiXmlDocument xmlDoc; TiXmlDeclaration Declaration("1.0","utf-8","yes"); xmlDoc.InsertEndChild(Declaration); TiXmlElement* pRootElem = new TiXmlElement("UIAdd"); pRootElem->InsertEndChild(*pElement); xmlDoc.InsertEndChild(*pRootElem); TiXmlPrinter printer; xmlDoc.Accept(&printer); delete pRootElem; CDialogBuilder builder; CControlUI* pRoot=builder.Create(StringConvertor::Utf8ToWide(printer.CStr()), (UINT)0, NULL, pManager); if(pRoot) pUIView->RedoUI(pRoot, pParentControl); }
void CALLBACK CUICommandHistory::UIModify(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strName = pElement->Attribute("myname"); pElement->RemoveAttribute("myname"); if(strName.IsEmpty()) return; CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager(); CControlUI* pControl = pManager->FindControl(StringConvertor::Utf8ToWide(strName)); TiXmlAttribute* pAttrib = pElement->FirstAttribute(); if(pControl == NULL) return; while(pAttrib) { if(strcmp(pAttrib->Name(), "name") == 0) { pManager->ReapObjects(pControl); g_pClassView->RenameUITreeItem(pControl, StringConvertor::Utf8ToWide(pAttrib->Value())); pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name()) , StringConvertor::Utf8ToWide(pAttrib->Value())); pManager->InitControls(pControl); } else pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name()) , StringConvertor::Utf8ToWide(pAttrib->Value())); pAttrib = pAttrib->Next(); } CControlUI* pParent = pControl->GetParent(); if(pParent == NULL) pParent = pControl; pParent->SetPos(pParent->GetPos()); }
// 脚本调用原型: // VApiHandle VApiHwFindControl(HANDLE hWnd, string CtrlName); SQInteger ViHwFindControl(HSQUIRRELVM v) { VApiHandle hRet = 0; const SQChar* szCtrlName = NULL; SQInteger nargs = sq_gettop(v); SQInteger nWnd = 0; HANDLE hWnd = NULL; CScriptMgr* pMgr = NULL; CPaintManagerUI* pPM = NULL; if (!v || 2 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} if (OT_STRING != sq_gettype(v, 3)) {goto _Exit_;} sq_getinteger(v, 2, &nWnd); sq_getstring(v, 3, &szCtrlName); if (-1 == nWnd) { pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} pPM = pMgr->GetManager(); } else { pPM = QiHwHandleToWin(nWnd)->pWinObj->GetPM(); } if (!pPM) {goto _Exit_;} // fixbug - 未验证pm合法性 hRet = QiHwCtrlToHandle(pPM->FindControl(szCtrlName)); _Exit_: sq_pushinteger(v, hRet); return 1; }
// void VwSetWindowPos(HWND hWnd, HWND hWndlnsertAfter,int X, int Y, int cx, int cy, UNIT Flags) SQInteger VwSetWindowPos(HSQUIRRELVM v) { SQInteger uIDEvent = 0; SQInteger nargs = sq_gettop(v); SQInteger nWnd = 0; SQInteger nWndlnsertAfter = NULL; HWND hWnd = NULL; HWND hWndlnsertAfter = NULL; int X = 0; int Y = 0; int cx = 0; int cy = 0; UINT uFlags = 0; if (!v || 7 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 3)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 4) && OT_FLOAT != sq_gettype(v, 4)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 5) && OT_FLOAT != sq_gettype(v, 5)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 6) && OT_FLOAT != sq_gettype(v, 6)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 7) && OT_FLOAT != sq_gettype(v, 7)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 8)) {goto _Exit_;} sq_getinteger(v, 2, &nWnd); sq_getinteger(v, 3, &nWndlnsertAfter); sq_getinteger(v, 4, &X); sq_getinteger(v, 5, &Y); sq_getinteger(v, 6, &cx); sq_getinteger(v, 7, &cy); sq_getinteger(v, 8, (SQInteger*)&uFlags); if (-1 == nWnd) { CScriptMgr* pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} CPaintManagerUI* pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} hWnd = pPM->GetPaintWindow(); } else { hWnd = QiHwHandleToWin(nWnd)->pWinObj->GetHWND(); } if (HWND_TOP == (HWND)nWndlnsertAfter || HWND_BOTTOM == (HWND)nWndlnsertAfter || HWND_TOPMOST == (HWND)nWndlnsertAfter || HWND_TOPMOST == (HWND)nWndlnsertAfter) { hWndlnsertAfter = (HWND)nWndlnsertAfter; } else { hWndlnsertAfter = QiHwHandleToWin(nWndlnsertAfter)->pWinObj->GetHWND(); } ::SetWindowPos(hWnd, hWndlnsertAfter, X, Y, cx, cy, uFlags); //::MoveWindow( hWnd, X, Y, cx, cy, TRUE); _Exit_: return 0; }
void CSDKLoginWithSSOUIGroup::InitWindow(CPaintManagerUI& ui_mgr, CSDKLoginUIMgr* main_frame_) { m_loginWithSSOPage = static_cast<CVerticalLayoutUI* >(ui_mgr.FindControl(_T("panel_Login_With_SSO"))); m_editSSOtoken = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_sso_token"))); m_login_bottom = static_cast<CVerticalLayoutUI* >(ui_mgr.FindControl(_T("panel_Login_Buttom"))); m_btnLogin = static_cast<CButtonUI* >(ui_mgr.FindControl(_T("btn_login"))); m_chkRemember = static_cast<CCheckBoxUI* >(ui_mgr.FindControl(_T("chk_remember_me"))); m_parentFrame = main_frame_; }
LRESULT CDropDownWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { if( uMsg == WM_CREATE ) { m_pm.Init(m_hWnd); // The trick is to add the items to the new container. Their owner gets // reassigned by this operation - which is why it is important to reassign // the items back to the righfull owner/manager when the window closes. CControlCanvasUI* pWindow = new CControlCanvasUI; CVerticalLayoutUI* pLayout = new CVerticalLayoutUI; for( int i = 0; i < m_pOwner->GetCount(); i++ ) pLayout->Add(static_cast<CControlUI*>(m_pOwner->GetItem(i))); pLayout->SetAutoDestroy(false); pLayout->EnableScrollBar(); pWindow->Add(pLayout); m_pm.AttachDialog(pWindow); return 0; } else if( uMsg == WM_CLOSE ) { m_pOwner->SetManager(m_pOwner->GetManager(), m_pOwner->GetParent()); m_pOwner->SetPos(m_pOwner->GetPos()); m_pOwner->SetFocus(); } else if( uMsg == WM_LBUTTONUP ) { PostMessage(WM_KILLFOCUS); } else if( uMsg == WM_KEYDOWN ) { switch( wParam ) { case VK_ESCAPE: m_pOwner->SelectItem(m_iOldSel); // FALL THROUGH... case VK_RETURN: PostMessage(WM_KILLFOCUS); break; default: TEventUI event; event.Type = UIEVENT_KEYDOWN; event.chKey = wParam; m_pOwner->Event(event); return 0; } } else if( uMsg == WM_KILLFOCUS ) { if( m_hWnd != (HWND) wParam ) PostMessage(WM_CLOSE); } LRESULT lRes = 0; if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes; return CWindowWnd::HandleMessage(uMsg, wParam, lParam); }
void CALLBACK CUICommandHistory::UIDelete(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strName = pElement->Attribute("myname"); if(strName.IsEmpty()) return; CUIDesignerView* pUIView = g_pMainFrame->GetActiveUIView(); CPaintManagerUI* pManager = pUIView->GetPaintManager(); CControlUI* pControl = pManager->FindControl(StringConvertor::Utf8ToWide(strName)); if(pControl == NULL) return; CControlUI* pParent=pControl->GetParent(); HTREEITEM hDelete=(HTREEITEM)(((ExtendedAttributes*)pControl->GetTag())->hItem); g_pClassView->RemoveUITreeItem(hDelete); pUIView->DeleteUI(pControl); if(pParent) pParent->NeedUpdate(); }
// HANDLE VwSnapShot(VApiHandle hWnd) SQInteger VwSnapShot(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger nWnd = 0; HWND hWnd = NULL; CUIImage* pImg = NULL; CScriptMgr* pMgr = NULL; CPaintManagerUI* pPM = NULL; BOOL bIsAlphaWin = NULL; VApiHandle hRet = NULL; CUIRect rt; if (!v || 1 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} sq_getinteger(v, 2, &nWnd); if (-1 == nWnd) { pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} hWnd = pPM->GetPaintWindow(); } else { hWnd = QiHwHandleToWin(nWnd)->pWinObj->GetHWND(); } ::GetWindowRect(hWnd, &rt); bIsAlphaWin = pPM->IsAlphaWin(); pImg = new CUIImage(); pImg->Create(pPM->GetPaintDC(), rt.GetWidth(), rt.GetHeight(), 0, TRUE); ::PrintWindow(hWnd, pImg->GetDC(), 0); ::SendMessage(hWnd, WM_PRINT, (WPARAM)pImg->GetDC(), PRF_NONCLIENT | PRF_CLIENT | PRF_ERASEBKGND | PRF_CHILDREN); hRet = QiHwObjToHandle(pImg); _Exit_: sq_pushinteger(v, hRet); return 1; }
//BOOL VwSetLayeredWindowAttributes(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags); SQInteger VwSetLayeredWindowAttributes(HSQUIRRELVM v) { SQInteger uIDEvent = 0; SQInteger nargs = sq_gettop(v); SQInteger nWnd = 0; HWND hWnd = NULL; COLORREF crKey = 0; int bAlpha = 0; DWORD dwFlags = 0; if (!v || 4 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 3)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 4)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 5)) {goto _Exit_;} sq_getinteger(v, 2, &nWnd); sq_getinteger(v, 3, (SQInteger*)&crKey); sq_getinteger(v, 4, (SQInteger*)&bAlpha); sq_getinteger(v, 5, (SQInteger*)&dwFlags); if (-1 == nWnd) { CScriptMgr* pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} CPaintManagerUI* pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} hWnd = pPM->GetPaintWindow(); } else { hWnd = QiHwHandleToWin(nWnd)->pWinObj->GetHWND(); } //::SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) ^ WS_EX_LAYERED); ::SetLayeredWindowAttributes(hWnd, crKey, (BYTE)bAlpha, dwFlags); ::RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); _Exit_: return 1; }
// BOOL VwKillTimer(SQInteger uIDEvent) SQInteger VwKillTimer(HSQUIRRELVM v) { SQUserPointer uIDEvent = 0; SQInteger nargs = sq_gettop(v); if (!v || 1 + 1 != nargs) {goto _Exit_;} if (OT_USERPOINTER != sq_gettype(v, 2)) {goto _Exit_;} sq_getuserpointer(v, 2, &uIDEvent); CScriptMgr* pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} CPaintManagerUI* pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} ::KillTimer(pPM->GetPaintWindow(), (UINT_PTR)uIDEvent); delete (SetTimerParam*)uIDEvent; _Exit_: sq_pushbool(v, TRUE); return 1; }
SQInteger _VwSetTimerInternal(HSQUIRRELVM v, TIMERPROC lpTimerFunc) { SQInteger nargs = sq_gettop(v); SQInteger Handle = 0; SQInteger uElapse = 0; LPCTSTR pstrFunc = NULL; SetTimerParam* pTimerParam = NULL; SQUserPointer nRet = NULL; if (!v || 3 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} if (OT_STRING != sq_gettype(v, 3)) {goto _Exit_;} if (OT_INSTANCE != sq_gettype(v, 4)) {goto _Exit_;} sq_getinteger(v, 2, &uElapse); sq_getstring(v, 3, &pstrFunc); pTimerParam = new SetTimerParam(); pTimerParam->v = v; pTimerParam->sFunc = pstrFunc; sq_getstackobj(v, 4, &pTimerParam->Obj); CScriptMgr* pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} CPaintManagerUI* pPM = pMgr->GetManager(); if (!pPM) {goto _Exit_;} if (NULL != ::SetTimer(pPM->GetPaintWindow(), (UINT_PTR)pTimerParam, uElapse, lpTimerFunc)) { nRet = (SQUserPointer)pTimerParam; } else { nRet = NULL; } _Exit_: sq_pushuserpointer(v, nRet); return 1; }
void CSDKLoginWithEmailUIGroup::InitWindow(CPaintManagerUI& ui_mgr, CSDKLoginUIMgr* main_frame_) { m_loginWithEmailPage = static_cast<CVerticalLayoutUI* >(ui_mgr.FindControl(_T("panel_Login_With_Email"))); m_editUserAccount = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_user_email"))); m_editUserPassword = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_user_password"))); m_login_bottom = static_cast<CVerticalLayoutUI* >(ui_mgr.FindControl(_T("panel_Login_Buttom"))); m_btnLogin = static_cast<CButtonUI* >(ui_mgr.FindControl(_T("btn_login"))); m_chkRemember = static_cast<CCheckBoxUI* >(ui_mgr.FindControl(_T("chk_remember_me"))); m_parentFrame = main_frame_; }
void CSDKWithoutLoginStartJoinMeetingUIGroup::InitWindow(CPaintManagerUI& ui_mgr, CSDKLoginUIMgr* main_frame_) { m_WithoutLoginStartJoinMeetingPage = static_cast<CVerticalLayoutUI* >(ui_mgr.FindControl(_T("panel_Join_Meeting_Only"))); m_editMeetingNumber = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_meeting_number"))); m_editScreenName = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_screen_name"))); m_editMeetingPassword = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_meeting_password"))); m_btnJoin = static_cast<CButtonUI* >(ui_mgr.FindControl(_T("btn_login"))); m_chkRemember = static_cast<CCheckBoxUI* >(ui_mgr.FindControl(_T("chk_remember_me"))); m_parentFrame = main_frame_; m_withoutLoginJoinMeetingWorkFlow.SetUIEvent(this); }
void CSDKRestAPIUserUIGroup::InitWindow(CPaintManagerUI& ui_mgr, CSDKLoginUIMgr* main_frame_) { m_WithoutLoginRestAPIPage = static_cast<CVerticalLayoutUI* >(ui_mgr.FindControl(_T("panel_RestAPI_Without_Login"))); m_editRestAPIKey = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_restapi_key"))); if(m_editRestAPIKey) m_editRestAPIKey->SetLimitText(KEY_SECRET_LIMIT_LENGTH_MAX); m_editRestAPISecret = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_restapi_secret"))); if(m_editRestAPISecret) m_editRestAPISecret->SetLimitText(KEY_SECRET_LIMIT_LENGTH_MAX); m_editScreenName = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_restapi_ScreenName"))); m_editEmail = static_cast<CRichEditUI* >(ui_mgr.FindControl(_T("edit_restapi_email"))); m_btnStartMeeting = static_cast<CButtonUI* >(ui_mgr.FindControl(_T("btn_login"))); m_chkRemember = static_cast<CCheckBoxUI* >(ui_mgr.FindControl(_T("chk_remember_me"))); m_parentFrame = main_frame_; m_RestAPIUserWorkFlow.SetUIEvent(this); }
// HANDLE VwCreateWin( // VApiHandle hWndParent, int X, int Y, int nWidth, int nHeight, // WCHAR* wszRegName, WCHAR* wszNewName, BOOL bIsAlpha) SQInteger VwCreateWin(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger nWndParent = 0; HWND hWndParent = NULL; CUIImage* pImg = NULL; CScriptMgr* pMgr = NULL; CPaintManagerUI* pPM = NULL; int X = 0; int Y = 0; int nWidth = 0; int nHeight = 0; const SQChar* pwszRegName = NULL; const SQChar* pwszNewName = NULL; WCHAR wszNewName[60] = {0}; SQBool bIsAlphaWin = NULL; WinMgrItem* pWinMgrIt = NULL; HWND hWnd = NULL; CWindowWnd* pWinObj = NULL; SQInteger nRet = 0; CMarkupNode* pRootXm = NULL; if (!v || 8 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 3)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 4)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 5)) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 6)) {goto _Exit_;} if (OT_STRING != sq_gettype(v, 7)) {goto _Exit_;} if (OT_STRING != sq_gettype(v, 8)) {goto _Exit_;} if (OT_BOOL != sq_gettype(v, 9)) {goto _Exit_;} sq_getinteger(v, 2, &nWndParent); sq_getinteger(v, 3, &X); sq_getinteger(v, 4, &Y); sq_getinteger(v, 5, &nWidth); sq_getinteger(v, 6, &nHeight); sq_getstring(v, 7, &pwszRegName); //sq_getinteger(v, 8, &wszNewName); sq_getbool(v, 9, &bIsAlphaWin); swprintf_s(wszNewName, 60, L"%x", ::GetTickCount()); if (nWndParent) { hWndParent = QiHwHandleToWin(nWndParent)->pWinObj->GetHWND(); } pMgr = (CScriptMgr*)sq_getforeignptr(v); if (!pMgr) {goto _Exit_;} pPM = pMgr->GetManager(); if (!pPM || !pPM->GetWinMgr()) {goto _Exit_;} pWinMgrIt = pPM->GetWinMgr()->FindWinByName(pwszRegName); if (!pWinMgrIt) {goto _Exit_;} // 新建立个模板,因为需要可重复用以前的名字 pRootXm = new CMarkupNode(*pWinMgrIt->pWinXML); pWinObj = new CWindowTemplate(pWinMgrIt->pWinObj); pWinObj->GetPM()->SetWinMgr(pPM->GetWinMgr()); pWinObj->SetDefaultResource(pRootXm); pWinMgrIt = pPM->GetWinMgr()->AddOneWin(pWinObj, wszNewName, pRootXm, X, Y, nWidth, nHeight, pWinMgrIt->dwStyle, pWinMgrIt->dwExStyle, &pWinMgrIt->ExInfo); if (!bIsAlphaWin) { hWnd = pWinObj->Create(hWndParent, pwszNewName, pWinMgrIt->dwStyle, pWinMgrIt->dwExStyle, X, Y, nWidth, nHeight, 0); } else { hWnd = pWinObj->CreateAlphaWin(hWndParent, pwszNewName, pWinMgrIt->dwStyle | WS_EX_LAYERED, pWinMgrIt->dwExStyle, X, Y, nWidth, nHeight); } if (!hWnd) {goto _Exit_;} nRet = QiHwObjToHandle(pWinMgrIt); _Exit_: sq_pushinteger(v, nRet); return 1; }
void CPropertiesWnd::SetUIValue(CMFCPropertyGridProperty* pProp,int nTag) { CControlUI* pControl = m_wndUIProperties.GetCurUI(); if(pControl == NULL) return; int nUpdate=UPDATE_REDRAW_CONTROL; CString strName=pProp->GetName(); strName.MakeLower(); CString strNewVal; CString strOldVal; strNewVal = pProp->FormatProperty(); strOldVal = m_wndUIProperties.FormatOrigProperty(pProp); if(nTag!=tagName && nTag!=tagText && strName.Find(_T("image"))==-1) { strNewVal.MakeLower(); strOldVal.MakeLower(); } switch(nTag) { case tagName: { CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager(); if(strNewVal.IsEmpty() || pManager->FindControl(strNewVal)) { if(!strNewVal.IsEmpty()) MessageBox(strNewVal + _T(" 名称已被其他控件使用!")); pProp->SetValue((_variant_t)pControl->GetName()); return; } else pManager->ReapObjects(pControl); g_pClassView->RenameUITreeItem(pControl, strNewVal); break; } case tagPos: case tagPadding: SetPropValue(pControl,tagSize); nUpdate=UPDATE_POS; break; case tagSize: case tagMinSize: case tagMaxSize: case tagMinMax: SetUIValue(pProp->GetSubItem(0),-1); SetUIValue(pProp->GetSubItem(1),-1); SetPropValue(pControl,tagPos); nUpdate=UPDATE_POS; break; case tagFloat: case tagColumns: nUpdate=UPDATE_POS; break; case tagVisible: nUpdate=UPDATE_REDRAW_PARENT; break; case tagListHeader: if (strNewVal.Compare(_T("false"))==0) { strNewVal = _T("hidden"); } break; case tagAlpha: { int alpha=_ttoi(strNewVal); if (alpha<0) { strNewVal=_T("0"); pProp->SetValue((_variant_t)(LONG)0); } else { strNewVal=_T("255"); pProp->SetValue((_variant_t)(LONG)255); } break; } } CUIDesignerView* pUIView=g_pMainFrame->GetActiveUIView(); ASSERT(pUIView); TNotifyUI Msg; UIAttribute oldAttrib = {strName, strOldVal}; Msg.pSender=pControl; Msg.sType=_T("PropertyBeginChanged"); Msg.wParam=0; Msg.lParam=(LPARAM)&oldAttrib; pUIView->Notify(Msg); pControl->SetAttribute(strName,strNewVal); pProp->SetOriginalValue(pProp->GetValue()); UIAttribute newAttrib = {strName, strNewVal}; Msg.sType = _T("PropertyEndChanged"); Msg.lParam = (LPARAM)&newAttrib; pUIView->Notify(Msg); if(nTag==tagWindowSize) { Msg.sType=_T("formsize"); Msg.lParam = NULL; pUIView->Notify(Msg); } else if(nTag == tagName) { CPaintManagerUI* pManager = pUIView->GetPaintManager(); pManager->InitControls(pControl); } CControlUI* pParent=pControl->GetParent(); if(pParent==NULL) pParent=pControl; switch(nUpdate) { case UPDATE_POS: pParent->SetPos(pParent->GetPos()); break; case UPDATE_REDRAW_CONTROL: pControl->NeedUpdate(); break; case UPDATE_REDRAW_PARENT: pParent->NeedUpdate(); } }