BOOL CGameReviewDialog::OnInitDialog() { // first call base class CMyCustomDialog::OnInitDialog(); // init the tags list control const int tnColSpacer = 14; m_listTags.InsertColumn(0, "Tag", LVCFMT_LEFT, m_listTags.GetStringWidth("Tag ") + tnColSpacer, 0); m_listTags.InsertColumn(1, "Value", LVCFMT_LEFT, m_listTags.GetStringWidth("Value ") + tnColSpacer, 1); // subclass buttons for(int i=0;i<tnumButtons;i++) { m_flatButtons[i].SubclassDlgItem(tControlInfo[i].nControlID, this); if (tControlInfo[i].nIconID != 0) m_flatButtons[i].SetIcon(tControlInfo[i].nIconID); if (i < 9) m_flatButtons[i].SetShowText(FALSE); } // subclass listbox CListBox* pList = (CListBox*) GetDlgItem(IDC_GAME_INDEX); wpOrigListBoxProc = (WNDPROC) SetWindowLong(pList->GetSafeHwnd(), GWL_WNDPROC, (LONG) ListBoxSubclassProc); // get the full width CRect windowRect; GetWindowRect(&windowRect); m_nFullWidth = windowRect.Width(); // and the collapsed width CRect btnRect; GetDlgItem(IDC_FIRST)->GetWindowRect(&btnRect); int nSpace = btnRect.left - windowRect.left; GetDlgItem(IDC_PLAY)->GetWindowRect(&btnRect); m_nCollapsedWidth = btnRect.right + nSpace - windowRect.left; // load expand.collapsed icons m_hIconExpand = (HICON) LoadImage(theApp.m_hInstance, MAKEINTRESOURCE(IDI_TAGS_EXPAND), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); m_hIconCollapse = (HICON) LoadImage(theApp.m_hInstance, MAKEINTRESOURCE(IDI_TAGS_COLLAPSE), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); // collapse if desired m_bCollapsed = theApp.GetValue(tbCollapseGameReviewDialog); CollapseWindow(m_bCollapsed); // done // m_bInitialized = TRUE; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CAddDlg::OnBnClickedOk() { // 获得主窗口句柄,用来在列表框中增加数据(虽然这样不安全,但个人喜欢) CTextCodeConverterDlg* MainDlg = (CTextCodeConverterDlg*)this->GetParent(); ASSERT(MainDlg->GetSafeHwnd()); // 取得主窗口中的列表框句柄 CListBox* listBox = (CListBox*)MainDlg->GetDlgItem(IDC_LIST1); ASSERT(listBox->GetSafeHwnd()); GetDlgItemText(IDC_EDIT1,m_strEdit); // 如果在启动窗口时为修改内容,则删除对应位置数据之后,然后在增加 if (m_bUpdate == TRUE) { listBox->DeleteString(listBox->GetCurSel()); listBox->InsertString(listBox->GetCurSel(),m_strEdit); } OnOK(); }