void CLoginWnd::InitWindow() { COptionUI* pLeft = static_cast<COptionUI*>(m_PaintManager.FindControl(_T("remember"))); COptionUI* pRight = static_cast<COptionUI*>(m_PaintManager.FindControl(_T("autolog"))); CEditUI* pName = static_cast<CEditUI*>(m_PaintManager.FindControl(_T("account"))); CEditUI* pPassWord = static_cast<CEditUI*>(m_PaintManager.FindControl(_T("password"))); HANDLE hFile = CreateFile(L"..\\logstate.dat",GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL); if (hFile == INVALID_HANDLE_VALUE) { return; } char account[128]; memset(account,0,sizeof(account)); char password[128]; memset(password,0,sizeof(password)); char left[32]; memset(left,0,sizeof(left)); char right[32]; memset(right,0,sizeof(right)); DWORD num = 0; ReadFile(hFile,account,sizeof(account),&num,NULL); SetFilePointer(hFile,150,NULL,FILE_BEGIN); ReadFile(hFile,password,sizeof(password),&num,NULL); SetFilePointer(hFile,300,NULL,FILE_BEGIN); ReadFile(hFile,left,sizeof(left),&num,NULL); SetFilePointer(hFile,350,NULL,FILE_BEGIN); ReadFile(hFile,right,sizeof(right),&num,NULL); CloseHandle(hFile); if (strcmp(left,"yes")==0) { pLeft->Selected(true); WCHAR wAccount[256]; memset(wAccount,0,sizeof(wAccount)); WCHAR wPassword[256]; memset(wPassword,0,sizeof(wPassword)); CCommonConvert::Char2WChar(account,sizeof(account),wAccount); CCommonConvert::Char2WChar(password,sizeof(password),wPassword); pName->SetText(wAccount); pPassWord->SetText(wPassword); } if (strcmp(right,"yes")==0) { pRight->Selected(true); Login(); HMODULE hd = ::GetModuleHandle(NULL); LPTSTR lpFileName = NULL; ::GetModuleFileName(hd,lpFileName,MAX_PATH); ::WritePrivateProfileString(_T("Windows"),_T("load"),lpFileName,_T("c:windows\\win.ini")); } }
void CLoginWnd::Notify(TNotifyUI& msg) { if (msg.sType ==DUI_MSGTYPE_CLICK) { CDuiString str = msg.pSender->GetName(); if ( str == _T("configbtn")) { CConfigWnd* pConfig = new CConfigWnd; pConfig->Create(NULL,_T("服务器配置"),UI_WNDSTYLE_FRAME,WS_EX_WINDOWEDGE); pConfig->CenterWindow(); pConfig->ShowModal(); delete pConfig; } else if ( str == _T("login")) { Login(); } } if (msg.sType == DUI_MSGTYPE_SELECTCHANGED) { if (msg.pSender->GetName()==_T("autolog")) { COptionUI* pLeft = static_cast<COptionUI*>(m_PaintManager.FindControl(_T("remember"))); COptionUI* pRight = static_cast<COptionUI*>(m_PaintManager.FindControl(_T("autolog"))); if (!pLeft->IsSelected()) { pLeft->Selected(true); } } } return WindowImplBase::Notify(msg); }
void COptionUI::Selected(bool bSelected, bool bTriggerEvent) { if( m_bSelected == bSelected ) return; m_bSelected = bSelected; if( m_bSelected ) m_uButtonState |= UISTATE_SELECTED; else m_uButtonState &= ~UISTATE_SELECTED; if( m_pManager != NULL ) { if( !m_sGroupName.IsEmpty() ) { if( m_bSelected ) { CStdPtrArray* aOptionGroup = m_pManager->GetOptionGroup(m_sGroupName); for( int i = 0; i < aOptionGroup->GetSize(); i++ ) { COptionUI* pControl = static_cast<COptionUI*>(aOptionGroup->GetAt(i)); if( pControl != this ) { pControl->Selected(false, bTriggerEvent); } } if (bTriggerEvent) m_pManager->SendNotify(this, DUI_MSGTYPE_SELECTCHANGED); } } else { if (bTriggerEvent) m_pManager->SendNotify(this, DUI_MSGTYPE_SELECTCHANGED); } } Invalidate(); }
void CVisitor::SelectAll(bool flag) { int num = m_pList->GetCount(); for (int i=0;i<num;++i) { CListContainerElementUI* pContainer = static_cast<CListContainerElementUI*>(m_pList->GetItemAt(i)); COptionUI* pOpt = static_cast<COptionUI*>(m_pManager->FindSubControlByName(pContainer,_T("selectall"))); pOpt->Selected(flag); } }
void CMainWnd::InitWindow() { // 初始化数据管理器 m_Data.Init(m_hWnd); // 创建分类按钮 CHorizontalLayoutUI* pTabBar = (CHorizontalLayoutUI*)m_PaintManager.FindControl(_T("tabbar")); if(pTabBar) { TABBTN aTypes[] = { {_T("8009|1003|1004|1007|1002|1005|1006|1001|1008"), _T("精选")}, {_T("1003"), _T("风景")}, {_T("1004"), _T("美女")}, {_T("1007"), _T("小清新")}, {_T("1002"), _T("动漫")}, {_T("1005"), _T("萌宠")}, {_T("1006"), _T("明星")}, {_T("1001"), _T("创意")}, {_T("1008"), _T("汽车")}, {_T("8009"), _T("颜色")}, }; COptionUI* pFirst = NULL; for(int i = 0; i < sizeof(aTypes) / sizeof(TABBTN); ++i) { TABBTN Tab = aTypes[i]; COptionUI* pOption = new COptionUI(); pOption->SetName(_T("wp_tabbtn")); pOption->SetText(Tab.sText); pOption->SetUserData(Tab.sType); pOption->SetGroup(_T("tabbar")); pOption->SetFixedHeight(25); pOption->SetFixedWidth(65); pOption->SetHotImage(_T("file='main/224.bmp' corner='4,4,4,4'")); pOption->SetSelectedImage(_T("file='main/224.bmp' corner='4,4,4,4'")); pOption->OnNotify += MakeDelegate(this, &CMainWnd::OnNotify1); pOption->OnNotify += MakeDelegate(this, &CMainWnd::OnNotify2); pTabBar->Add(pOption); if(pFirst == NULL) pFirst = pOption; } if(pFirst != NULL) pFirst->Selected(true); } m_Data.LoadBizhi(_T("8009|1003|1004|1007|1002|1005|1006|1001|1008"), 1, 10); }
NSDUILIB_API void TBCIASendMessage(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { HWND hwnd = (HWND)popint(); TCHAR msgID[MAX_PATH]; TCHAR wParam[MAX_PATH]; TCHAR lParam[MAX_PATH]; EXDLL_INIT(); ZeroMemory(msgID, MAX_PATH*sizeof(TCHAR)); ZeroMemory(wParam, MAX_PATH*sizeof(TCHAR)); ZeroMemory(lParam, MAX_PATH*sizeof(TCHAR)); DEBUG_INFO("to send message stringsize %d MAX_PATH %d\n",g_stringsize,MAX_PATH); popstring( msgID,sizeof(msgID) ); popstring( wParam,sizeof(wParam) ); popstring( lParam ,sizeof(lParam)); if( _tcsicmp( msgID, _T("WM_TBCIAMIN")) == 0 ) ::SendMessage( hwnd, WM_TBCIAMIN, (WPARAM)wParam, (LPARAM)lParam ); else if( _tcsicmp( msgID, _T("WM_TBCIACLOSE")) == 0 ) ::SendMessage( hwnd, WM_TBCIACLOSE, (WPARAM)wParam, (LPARAM)lParam ); else if( _tcsicmp( msgID, _T("WM_TBCIABACK")) == 0 ) ::SendMessage( hwnd, WM_TBCIABACK, (WPARAM)g_installPageTabName.GetData(), (LPARAM)lParam ); else if( _tcsicmp( msgID, _T("WM_TBCIANEXT")) == 0 ) ::SendMessage( hwnd, WM_TBCIANEXT, (WPARAM)g_installPageTabName.GetData(), (LPARAM)lParam ); else if( _tcsicmp( msgID, _T("WM_TBCIACANCEL")) == 0 ) { LPCTSTR lpTitle = (LPCTSTR)wParam; LPCTSTR lpText = (LPCTSTR)lParam; DEBUG_BUFFER_FMT(lpTitle,_tcslen(lpTitle) + sizeof(TCHAR),"lpTitle :"); DEBUG_BUFFER_FMT(lpText,_tcslen(lpText) + sizeof(TCHAR),"lpText :"); if( IDYES == MessageBox( hwnd, lpText, lpTitle, MB_YESNO)/*TBCIAMessageBox( hwnd, lpTitle, lpText )*/) { pushint( 0 ); ::SendMessage( hwnd, WM_TBCIACLOSE, (WPARAM)wParam, (LPARAM)lParam ); } else pushint( -1 ); } else if (_tcsicmp( msgID, _T("WM_QAUERYCANCEL")) == 0) { LPCTSTR lpTitle = (LPCTSTR)wParam; LPCTSTR lpText = (LPCTSTR)lParam; if( IDYES == MessageBox( hwnd, lpText, lpTitle, MB_YESNO)/*TBCIAMessageBox( hwnd, lpTitle, lpText )*/) { pushint( 0 ); } else pushint( -1 ); } else if( _tcsicmp( msgID, _T("WM_TBCIASTARTINSTALL")) == 0 ) { ::SendMessage( hwnd, WM_TBCIASTARTINSTALL, (WPARAM)g_installPageTabName.GetData(), (LPARAM)lParam ); } else if( _tcsicmp( msgID, _T("WM_TBCIASTARTUNINSTALL")) == 0 ) ::SendMessage( hwnd, WM_TBCIASTARTUNINSTALL, (WPARAM)g_installPageTabName.GetData(), (LPARAM)lParam ); else if( _tcsicmp( msgID, _T("WM_TBCIAFINISHEDINSTALL")) == 0 ) ::SendMessage( hwnd, WM_TBCIAFINISHEDINSTALL, (WPARAM)wParam, (LPARAM)lParam ); else if( _tcsicmp( msgID, _T("WM_TBCIAOPTIONSTATE")) == 0 ) // 返回option的状态 { COptionUI* pOption = static_cast<COptionUI*>(g_pFrame->GetPaintManager().FindControl( wParam )); if( pOption == NULL ) return; DEBUG_INFO("selected %s\n",pOption->IsSelected() ? "yes" : "no"); pushint( pOption->IsSelected() ); } else if (_tcsicmp( msgID, _T("WM_TBCIASETSTATE")) == 0) { COptionUI* pOption = static_cast<COptionUI*>(g_pFrame->GetPaintManager().FindControl( wParam )); if( pOption == NULL ) return; if (_tcsicmp(lParam,_T("1"))== 0) { pOption->Selected(true); } else { pOption->Selected(false); } DEBUG_INFO("selected %s\n",pOption->IsSelected() ? "yes" : "no"); pOption->PaintStatusImage(g_pFrame->GetPaintManager().GetPaintDC()); pushint( pOption->IsSelected() ); } else if (_tcsicmp(msgID,_T("WM_TBCIAEXIT"))==0) { ::SendMessage(hwnd,WM_CLOSE,0,0); } else if( _tcsicmp( msgID, _T("WM_TBCIAOPENURL")) == 0 ) { CDuiString url = (CDuiString)wParam; if( url.Find( _T("https://") ) == -1 && url.Find(_T("http://")) == -1) { pushstring( _T("url error") ); return; } CDuiString lpCmdLine = _T("explorer \""); lpCmdLine += url; lpCmdLine += _T("\""); USES_CONVERSION; char strCmdLine[MAX_PATH]; #ifdef _UNICODE wcstombs(strCmdLine,lpCmdLine.GetData(),MAX_PATH); #else strncpy(strCmdLine,lpCmdLine.GetData(),MAX_PATH); #endif WinExec( strCmdLine, SW_SHOWNORMAL); } }
void MainFrame::Notify(TNotifyUI& msg) { if (_tcsicmp(msg.sType, kWindowInit) == 0) { OnPrepare(msg); } else if (_tcsicmp(msg.sType, kClick) == 0) { if (_tcsicmp(msg.pSender->GetName(), kCloseButtonControlName) == 0 || _tcsicmp(msg.pSender->GetName(), kCancelButtonControlName) == 0) { OnExit(msg); } else if (_tcsicmp(msg.pSender->GetName(), kMinButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_MINIMIZE); #else SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kMaxButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_MAXIMIZE); CControlUI* pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(false); pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(true); #else SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), kRestoreButtonControlName) == 0) { #if defined(UNDER_CE) ::ShowWindow(m_hWnd, SW_RESTORE); CControlUI* pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kMaxButtonControlName)); if( pControl ) pControl->SetVisible(true); pControl = static_cast<CControlUI*>(paint_manager_.FindControl(kRestoreButtonControlName)); if( pControl ) pControl->SetVisible(false); #else SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); #endif } else if (_tcsicmp(msg.pSender->GetName(), _T("select_all_btn")) == 0) { CContainerUI* pDriverList = static_cast<CContainerUI*>(paint_manager_.FindControl(_T("driver_list"))); for (int i = 0; (pDriverList != NULL) && (i < pDriverList->GetCount()); ++i) { COptionUI* pDriver = static_cast<COptionUI*>(pDriverList->GetItemAt(i)->GetInterface(_T("Option"))); if (pDriver != NULL) pDriver->Selected(true); } } else if (_tcsicmp(msg.pSender->GetName(), _T("uninstall_btn")) == 0) { vector<tString> deleted_printer_driver; DWORD dwError = 0; TCHAR szBuf[MAX_PATH] = {0}; CContainerUI* pDriverList = static_cast<CContainerUI*>(paint_manager_.FindControl(_T("driver_list"))); for (int i = 0; (pDriverList != NULL) && (i < pDriverList->GetCount()); ++i) { COptionUI* pDriver = static_cast<COptionUI*>(pDriverList->GetItemAt(i)->GetInterface(_T("Option"))); if ((pDriver != NULL) && pDriver->IsSelected()) { // 涉及到的API: DeletePrinter DeletePrinterDriver HANDLE hPrinter = NULL; _stprintf_s(szBuf, MAX_PATH - 1, pDriver->GetText().GetData()); PRINTER_DEFAULTS PrtDefault = {NULL, NULL, PRINTER_ALL_ACCESS}; OpenPrinter(szBuf, &hPrinter, &PrtDefault); if (hPrinter != NULL) { DWORD dwNeeded = 0; GetPrinter(hPrinter, 2, NULL, 0, &dwNeeded); LPBYTE lpBuffer = (LPBYTE)malloc(dwNeeded); if (lpBuffer != NULL) { GetPrinter(hPrinter, 2, lpBuffer, dwNeeded, &dwNeeded); DeletePrinter(hPrinter); dwError = GetLastError(); vector<tString>::const_iterator citer = find(deleted_printer_driver.begin(), deleted_printer_driver.end(), ((PRINTER_INFO_2*)lpBuffer)->pDriverName); if (citer == deleted_printer_driver.end()) { deleted_printer_driver.push_back(((PRINTER_INFO_2*)lpBuffer)->pDriverName); } ClosePrinter(hPrinter); free(lpBuffer); } } } } for (vector<tString>::const_iterator citer = deleted_printer_driver.begin(); citer != deleted_printer_driver.end(); ++citer) { _stprintf_s(szBuf, MAX_PATH - 1, citer->c_str()); DeletePrinterDriver(NULL, NULL, szBuf); dwError = GetLastError(); } RestartSpoolsv(); EnumInstalledDriver(); if (IDYES == DUIMessageBox(m_hWnd, _T("注意:您需要重新启动计算机使设置生效,现在需要重启计算机吗?点击“是”立即重启计算机,点击“否”稍后您自己手动重启计算机。"), _T("重新启动计算机"), MB_YESNO)) SystemReboot(); } } else if (_tcsicmp(msg.sType, kTimer) == 0) { return OnTimer(msg); } }