//----------------------------------------------------------------------------- // Purpose: Recalculate the internal scoreboard data //----------------------------------------------------------------------------- void ScorePanel::Update() { // Set the title if (gViewPort->m_szServerName) { char sz[MAX_SERVERNAME_LENGTH + 16]; sprintf(sz, "%s", gViewPort->m_szServerName ); m_TitleLabel.setText(sz); } m_iRows = 0; gViewPort->GetAllPlayersInfo(); //Hide or show the QUEUE and WINS labels. if ( g_iArenaMode == TRUE ) { m_HeaderLabels[2].setVisible ( true ); m_HeaderLabels[3].setVisible ( true ); } else { m_HeaderLabels[2].setVisible ( false ); m_HeaderLabels[3].setVisible ( false ); } // Clear out sorts for (int i = 0; i < NUM_ROWS; i++) { m_iSortedRows[i] = 0; m_iIsATeam[i] = TEAM_NO; } for (int i = 0; i < MAX_PLAYERS; i++) { m_bHasBeenSorted[i] = false; } SortTeams(); // If it's not teamplay, sort all the players. Otherwise, sort the teams. // if ( !gHUD.m_Teamplay ) SortPlayers( 0, NULL ); // else // set scrollbar range m_PlayerList.SetScrollRange(m_iRows); FillGrid(); }
//----------------------------------------------------------------------------- // Purpose: Recalculate the internal scoreboard data //----------------------------------------------------------------------------- void ScorePanel::Update() { // Set the title if (gViewPort->m_szServerName) { char sz[MAX_SERVERNAME_LENGTH + 16]; sprintf(sz, "%s", gViewPort->m_szServerName ); m_TitleLabel.setText(sz); } m_iRows = 0; gViewPort->GetAllPlayersInfo(); // Clear out sorts // modified by jason for (int i = 0; i < MAX_PLAYERS; i++) { m_iSortedRows[i] = 0; m_iIsATeam[i] = TEAM_NO; m_bHasBeenSorted[i] = false; } // If it's not teamplay, sort all the players. Otherwise, sort the teams. if ( !gHUD.m_Teamplay ) SortPlayers( 0, NULL ); else SortTeams(); // set scrollbar range m_PlayerList.SetScrollRange(m_iRows); FillGrid(); if ( gViewPort->m_pSpectatorPanel->m_menuVisible ) { m_pCloseButton->setVisible ( true ); } else { m_pCloseButton->setVisible ( false ); } }
BOOL Member::OnInitDialog() { CDialog::OnInitDialog(); CString strPath = QueryExePath(); strPath += _T("Food.sqlite"); char *path; path=strPath.GetBuffer(strPath.GetLength()); strPath.ReleaseBuffer(); // 打开数据库, 创建连接 if (SQLITE_OK != sqlite3_open(path, &conn)) { GetDlgItem(IDC_BUTTON1)->SetWindowText(_T("DBerror")); } m_Grid.EnableDragAndDrop(TRUE); m_Grid.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(0xFF, 0xFF, 0xE0)); m_Grid.SetFixedColumnSelection(TRUE); m_Grid.SetFixedRowSelection(TRUE); m_Grid.EnableColumnHide(); //m_Grid.EnableScrollBars(SB_VERT,1); m_Grid.SetColumnCount(3); m_Grid.SetRowCount(5); m_Grid.SetFixedRowCount(1); int a = m_Grid.IsVisibleVScroll(); CString str; str = "ID"; m_Grid.SetItemText(0,0,str); str = "Name"; m_Grid.SetItemText(0,1,str); str = "Money"; m_Grid.SetItemText(0,2,str); //m_Grid.ExpandColumnsToFit(TRUE); FillGrid(); return TRUE; }
int CBCGPMSMoneyDemoView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; m_Image.LoadBitmap (IDB_BCGPMSM_VIEW_BKGND); BITMAP bitmap; m_Image.GetBitmap (&bitmap); m_sizeImage = CSize (bitmap.bmWidth, bitmap.bmHeight); CRect rectGrid (CPoint (m_ptOffset.x, m_ptOffset.y + m_sizeImage.cy), CSize (m_sizeImage.cx, 200)); m_wndGrid.Create (WS_CHILD | WS_VISIBLE, rectGrid, this, 1); m_wndGrid.SetColorTheme (theme); FillGrid (); return 0; }
//----------------------------------------------------------------------------- // Purpose: Recalculate the internal scoreboard data //----------------------------------------------------------------------------- void ScorePanel::Update() { // Set the title string theTitleName; if (gViewPort->m_szServerName) { int iServerNameLength = max((int)strlen(gViewPort->m_szServerName),MAX_SERVERNAME_LENGTH); theTitleName += string(gViewPort->m_szServerName,iServerNameLength); } string theMapName = gHUD.GetMapName(); if(theMapName != "") { if(theTitleName != "") { theTitleName += " "; } theTitleName += "("; theTitleName += theMapName; theTitleName += ")"; } m_TitleLabel.setText(theTitleName.c_str()); int theColorIndex = 0; // Set gamma-correct title color Color gammaAdjustedTeamColor = BuildColor(kTeamColors[theColorIndex][0], kTeamColors[theColorIndex][1], kTeamColors[theColorIndex][2], gHUD.GetGammaSlope()); int theR, theG, theB, theA; gammaAdjustedTeamColor.getColor(theR, theG, theB, theA); m_TitleLabel.setFgColor(theR, theG, theB, theA); m_iRows = 0; gViewPort->GetAllPlayersInfo(); // Clear out sorts int i = 0; for (i = 0; i < NUM_ROWS; i++) { m_iSortedRows[i] = 0; m_iIsATeam[i] = TEAM_IND; } // Fix for memory overrun bug for (i = 0; i < MAX_PLAYERS; i++) { m_bHasBeenSorted[i] = false; } SortTeams(); // set scrollbar range m_PlayerList.SetScrollRange(m_iRows); FillGrid(); if ( gViewPort->m_pSpectatorPanel->m_menuVisible ) { m_pCloseButton->setVisible ( true ); } else { m_pCloseButton->setVisible ( false ); } }
void Member::OnBnClickedButton4() { CString strName,strMoney; GetDlgItem(IDC_EDIT1)->GetWindowText(strName); if (strName.IsEmpty()) { CString ss = _T("Name is Empty"); MessageBox(ss); return; } ////////////////////////////////////////// sqlite3_stmt* ppStmt = NULL; CString strSql; strSql.Format("select id, money from member where name = '%s'",strName); int ret = sqlite3_prepare(conn, strSql, -1, &ppStmt, /*&tail*/0); ret = sqlite3_step(ppStmt); int id = -1; if(ret!=SQLITE_DONE) { id = sqlite3_column_double(ppStmt,0); double dMoney = sqlite3_column_double(ppStmt,1); sqlite3_finalize(ppStmt); if (dMoney<0) { CString ss = _T("该用户目前欠费,不能消除!"); MessageBox(ss); return; } strSql.Format("Delete from member WHERE name='%s'",strName); ret = sqlite3_prepare(conn, strSql, -1, &ppStmt, /*&tail*/0); ret = sqlite3_step(ppStmt); FillGrid(); sqlite3_finalize(ppStmt); } //////////////////////////////////////////// //delete pSql; CString strResult; CTime time = CTime::GetCurrentTime(); CString date = time.Format("%Y-%m-%d %H:%M:%S %W-%A"); strResult.Format("delete the %d:%s at %s",id,strName,date); strSql.Format("INSERT INTO change ([des]) VALUES('%s')",strResult); char* pSql=strSql.GetBuffer(); char* err_msg; // Create a prepared statement. sqlite3_exec(conn, pSql, 0, 0, &err_msg); }
void Member::OnBnClickedButton1() { CString strName,strMoney; GetDlgItem(IDC_EDIT1)->GetWindowText(strName); if (strName.IsEmpty()) { CString ss = _T("Name is Empty"); MessageBox(ss); return; } GetDlgItem(IDC_EDIT2)->GetWindowText(strMoney); if (strMoney.IsEmpty()) { CString ss = _T("Money is Empty"); MessageBox(ss); return; } float fMoney = atof(strMoney); ////////////////////////////////////////// sqlite3_stmt* ppStmt = NULL; CString strSql; strSql.Format("select id, money from member where name = '%s'",strName); int ret = sqlite3_prepare(conn, strSql, -1, &ppStmt, /*&tail*/0); ret = sqlite3_step(ppStmt); int id = -1; if(ret!=SQLITE_DONE) { id = sqlite3_column_double(ppStmt,0); double dMoney = sqlite3_column_double(ppStmt,1); dMoney += fMoney; sqlite3_finalize(ppStmt); strSql.Format("UPDATE member SET money = %f WHERE name='%s'",dMoney,strName); ret = sqlite3_prepare(conn, strSql, -1, &ppStmt, /*&tail*/0); ret = sqlite3_step(ppStmt); for(int i=1;i<m_Grid.GetRowCount();i++) { CString str = m_Grid.GetItemText(i,0); int n = atoi(str); if(n == id) { CString strNum; strNum.Format("%f",dMoney); m_Grid.SetItemText(i,2,strNum); m_Grid.SetItemBkColour(i,2,0X00F0F0); break;; } } m_Grid.UpdateData(); m_Grid.Invalidate(); if(ret != SQLITE_DONE) MessageBox("充值成功,请查看高亮处是否准确"); sqlite3_finalize(ppStmt); } else { strSql.Format("INSERT INTO member ([name],[money]) VALUES('%s',%f)",strName,fMoney); char *pSql; pSql=strSql.GetBuffer(); char *err_msg = NULL; sqlite3_stmt *stmt; // Create a prepared statement. if (SQLITE_OK != sqlite3_exec(conn, pSql, 0, 0, &err_msg)) { CString strContent(err_msg); MessageBox(strContent); } else { GetDlgItem(IDC_EDIT1)->SetWindowText(_T("")); GetDlgItem(IDC_EDIT2)->SetWindowText(_T("")); } FillGrid(); } //////////////////////////////////////////// //delete pSql; CString strResult; CTime time = CTime::GetCurrentTime(); CString date = time.Format("%Y-%m-%d %H:%M:%S %W-%A"); strResult.Format("%d:%s add money %s at %s",id,strName,strMoney,date); strSql.Format("INSERT INTO change ([des]) VALUES('%s')",strResult); char* pSql=strSql.GetBuffer(); char* err_msg; // Create a prepared statement. sqlite3_exec(conn, pSql, 0, 0, &err_msg); }
BOOL CBookmarkDlg::Create(CWnd *pParentWnd) { if (!CDialog::Create(MAKEINTRESOURCE(IDD), pParentWnd)) // IDD_BOOKMARKS { TRACE0("Failed to create bookmarks dialog\n"); return FALSE; // failed to create } // Default to retaining network/removeable drive files when validating ASSERT(GetDlgItem(IDC_NET_RETAIN) != NULL); ((CButton *)GetDlgItem(IDC_NET_RETAIN))->SetCheck(BST_CHECKED); ASSERT(GetDlgItem(IDC_GRID_BL) != NULL); if (!grid_.SubclassWindow(GetDlgItem(IDC_GRID_BL)->m_hWnd)) { TRACE0("Failed to subclass grid control\n"); return FALSE; } // Set up the grid control grid_.SetDoubleBuffering(); grid_.SetAutoFit(); grid_.SetCompareFunction(&bl_compare); grid_.SetGridLines(GVL_BOTH); // GVL_HORZ | GVL_VERT grid_.SetTrackFocusCell(FALSE); grid_.SetFrameFocusCell(FALSE); grid_.SetListMode(TRUE); grid_.SetSingleRowSelection(FALSE); grid_.SetHeaderSort(TRUE); grid_.SetFixedRowCount(1); InitColumnHeadings(); grid_.SetColumnResize(); grid_.EnableRowHide(FALSE); grid_.EnableColumnHide(FALSE); grid_.EnableHiddenRowUnhide(FALSE); grid_.EnableHiddenColUnhide(FALSE); FillGrid(); grid_.ExpandColsNice(FALSE); // Set up resizer control // We must set the 4th parameter true else we get a resize border // added to the dialog and this really stuffs things up inside a pane. m_resizer.Create(GetSafeHwnd(), TRUE, 100, TRUE); // It needs an initial size for it's calcs CRect rct; GetWindowRect(&rct); m_resizer.SetInitialSize(rct.Size()); m_resizer.SetMinimumTrackingSize(rct.Size()); // This can cause problems if done too early (OnCreate or OnInitDialog) m_resizer.Add(IDOK, 100, 0, 0, 0); m_resizer.Add(IDC_BOOKMARK_NAME, 0, 0, 100, 0); m_resizer.Add(IDC_BOOKMARK_ADD, 100, 0, 0, 0); m_resizer.Add(IDC_GRID_BL, 0, 0, 100, 100); m_resizer.Add(IDC_BOOKMARK_GOTO, 100, 0, 0, 0); m_resizer.Add(IDC_BOOKMARK_REMOVE, 100, 0, 0, 0); m_resizer.Add(IDC_BOOKMARKS_VALIDATE, 100, 0, 0, 0); m_resizer.Add(IDC_NET_RETAIN, 100, 0, 0, 0); m_resizer.Add(IDC_BOOKMARKS_HELP, 100, 0, 0, 0); return TRUE; }
LRESULT CCompareListDlg::OnKickIdle(WPARAM, LPARAM lCount) { if (m_first) { m_first = false; InitColumnHeadings(); grid_.ExpandColsNice(FALSE); } // Display context help for ctrl set up in OnHelpInfo if (help_hwnd_ != (HWND)0) { theApp.HtmlHelpWmHelp(help_hwnd_, id_pairs); help_hwnd_ = (HWND)0; } CHexEditView * pview = GetView(); // active file's view (or NULL if none) CHexEditDoc * pdoc = NULL; // active file's doc int diffs = -1; // number of diffs, or -2 if bg compare in progress clock_t curr_change = -1; // time that current compare finished int curr_progress = 0; // progress value if background compare in progress if (pview != NULL) { pdoc = pview->GetDocument(); ASSERT(pdoc != NULL); diffs = pdoc->CompareDifferences(); curr_change = pdoc->LastCompareFinishTime(); } // First work out if we have to redraw the list bool redraw = false; if (pview != phev_) { redraw = true; // we have to redraw after switching files phev_ = pview; // track which view we last used } // Check if we have to redraw because the current file status has changed if (!redraw && pview != NULL) { if (diffs == -2) { // Currently comparing (background) - check if we need to update progress static int last_progress; curr_progress = (pdoc->CompareProgress()/5) * 5; // nearest 5% if (curr_progress != last_progress) { last_progress = curr_progress; redraw = true; // need to update progress } } else if (diffs >= 0 && curr_change != 0 && curr_change != last_change_) { redraw = true; // need to redraw the whole list } } if (redraw) { TRACE("]]]] %p %p %d %d %d\n", pview, pdoc, diffs, (int)last_change_, (int)curr_change); if (pview == NULL) { grid_.SetRowCount(grid_.GetFixedRowCount()); // No view so display empty list } else if (diffs >= 0) { last_change_ = curr_change; // Grid needs updating (switched to diff view or compare just finished) grid_.SetRowCount(grid_.GetFixedRowCount()); // Clear grid before refilling FillGrid(pdoc); // fill grid with results } else if (diffs == -2) { grid_.SetRowCount(grid_.GetFixedRowCount()); // Clear grid before adding message RowAdder rowAdder(grid_, pview); CString mess; mess.Format("%d%% ...", curr_progress); rowAdder.AddMessage(mess, IDS_COMPARE_INPROGRESS); } else { grid_.SetRowCount(grid_.GetFixedRowCount()); // clear list if no compare done } } return FALSE; }