本文整理汇总了C++中CListBox::GetSafeHwnd方法的典型用法代码示例。如果您正苦于以下问题:C++ CListBox::GetSafeHwnd方法的具体用法?C++ CListBox::GetSafeHwnd怎么用?C++ CListBox::GetSafeHwnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CListBox
的用法示例。
在下文中一共展示了CListBox::GetSafeHwnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnInitDialog
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
}
示例2: OnBnClickedOk
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();
}