// demoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "demo.h"
#include "demoDlg.h"
#include "SkinScrollBar/SkinScrollBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CdemoDlg dialog
CdemoDlg::CdemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CdemoDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CdemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CdemoDlg, CDialog)
ON_WM_PAINT()
ON_WM_DESTROY()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_ATTACH, &CdemoDlg::OnBnClickedAttach)
ON_BN_CLICKED(IDC_DETACH, &CdemoDlg::OnBnClickedDetach)
END_MESSAGE_MAP()
// CdemoDlg message handlers
BOOL CdemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
SubclassUI_ScrollBar_Hook();
SubclassUI_ScrollBar_SetBitmap(::LoadBitmap(::AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_SCROLLBAR)), RGB(255, 0, 255));
HWND h = ::GetDlgItem(m_hWnd, IDC_COMBO1);
WCHAR sz[50];
for(int i = 0; i < 50; ++i)
{
swprintf_s(sz, 50, L"item%d", i);
::SendMessage(h, CB_ADDSTRING, 0, (LPARAM)sz);
}
::SendMessage(h, CB_SETCURSEL, 0, 0L);
h = ::GetDlgItem(m_hWnd, IDC_COMBOBOXEX2);
COMBOBOXEXITEM cbex = {0};
cbex.mask = CBEIF_TEXT;
cbex.pszText = sz;
cbex.iIndent = 0;
for(int i = 0; i < 50; ++i)
{
cbex.iItem = i;
swprintf_s(sz, 50, L"item%d", i);
::SendMessage(h, CBEM_INSERTITEM, 0, (LPARAM)&cbex);
}
::SendMessage(h, CB_SETCURSEL, 0, 0L);
h = ::GetDlgItem(m_hWnd, IDC_LIST1);
for(int i = 0; i < 50; ++i)
{
swprintf_s(sz, 50, L"ListItem%d", i);
::SendMessage(h, LB_ADDSTRING, 0, (LPARAM)sz);
}
HWND hTree = ::GetDlgItem(m_hWnd, IDC_TREE1);
HTREEITEM hItem = NULL, hParent = NULL;
TVINSERTSTRUCT tvis = {0};
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_TEXT;
tvis.item.cchTextMax = 50;
for(int i = 0; i < 15; ++i)
{
swprintf_s(sz, 50, L"item%d", i);
tvis.hParent = hParent;
tvis.item.pszText = sz;
hItem = (HTREEITEM)::SendMessage(hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
::SendMessage(hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hParent);
hParent = hItem;
}
HWND hListView = ::GetDlgItem(m_hWnd, IDC_LIST2);
LVCOLUMN lvl = {0};
lvl.cchTextMax = 50;
lvl.cx = 100;
lvl.mask = LVCF_TEXT|LVCF_WIDTH;
for(int i = 0; i < 5; ++i)
{
swprintf_s(sz, 50, L"Item%d", i);
lvl.pszText = sz;
::SendMessage(hListView, LVM_INSERTCOLUMN, (WPARAM)i, (LPARAM)&lvl);
}
LVITEM li = {0};
li.cchTextMax = 50;
li.mask = LVIF_TEXT;
for(int i = 0; i < 100; ++i)
{
swprintf_s(sz, 50, L"row%d", i);
li.pszText = sz;
li.iItem = i;
::SendMessage(hListView, LVM_INSERTITEM, 0, (LPARAM)&li);
}
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CdemoDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CdemoDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CdemoDlg::OnBnClickedAttach()
{
HWND h = NULL;
h = ::GetDlgItem(m_hWnd, IDC_COMBO1);
COMBOBOXINFO cbi;
cbi.cbSize = sizeof(COMBOBOXINFO);
::GetComboBoxInfo(h, &cbi);
SubclassUI_ScrollBar_Attach(cbi.hwndList);
h = ::GetDlgItem(m_hWnd, IDC_COMBOBOXEX2);
h = (HWND)::SendMessage(h, CBEM_GETCOMBOCONTROL, 0, 0L);
::GetComboBoxInfo(h, &cbi);
SubclassUI_ScrollBar_Attach(cbi.hwndList);
h = ::GetDlgItem(m_hWnd, IDC_EDIT1);
SubclassUI_ScrollBar_Attach(h);
h = ::GetDlgItem(m_hWnd, IDC_RICHEDIT21);
SubclassUI_ScrollBar_Attach(h);
h = ::GetDlgItem(m_hWnd, IDC_LIST1);
SubclassUI_ScrollBar_Attach(h);
h = ::GetDlgItem(m_hWnd, IDC_LIST2);
SubclassUI_ScrollBar_Attach(h);
h = ::GetDlgItem(m_hWnd, IDC_TREE1);
SubclassUI_ScrollBar_Attach(h);
}
void CdemoDlg::OnBnClickedDetach()
{
HWND h = ::GetDlgItem(m_hWnd, IDC_COMBO1);
COMBOBOXINFO cbi;
cbi.cbSize = sizeof(COMBOBOXINFO);
::GetComboBoxInfo(h, &cbi);
SubclassUI_ScrollBar_Detach(cbi.hwndList);
h = ::GetDlgItem(m_hWnd, IDC_COMBOBOXEX2);
h = (HWND)::SendMessage(h, CBEM_GETCOMBOCONTROL, 0, 0L);
::GetComboBoxInfo(h, &cbi);
SubclassUI_ScrollBar_Detach(cbi.hwndList);
h = ::GetDlgItem(m_hWnd, IDC_EDIT1);
SubclassUI_ScrollBar_Detach(h);
h = ::GetDlgItem(m_hWnd, IDC_RICHEDIT21);
SubclassUI_ScrollBar_Detach(h);
h = ::GetDlgItem(m_hWnd, IDC_LIST1);
SubclassUI_ScrollBar_Detach(h);
h = ::GetDlgItem(m_hWnd, IDC_LIST2);
SubclassUI_ScrollBar_Detach(h);
h = ::GetDlgItem(m_hWnd, IDC_TREE1);
SubclassUI_ScrollBar_Detach(h);
}
void CdemoDlg::OnDestroy()
{
SubclassUI_ScrollBar_Unhook();
}
liaoguobao
- 粉丝: 1
- 资源: 3
最新资源
- GJB150A-2009军用装备实验室环境试验方法(共19份标准文件)
- 浩辰CAD看图王8.6.0最新版本下载,轻量化CAD看图软件,无需下载专业CAD软件,即可实现CAD看图、CAD图纸编辑、格式转换、三维览图等
- SW materials
- 英雄联盟评论数据集和停用词表
- 整合Springboot shiro jpa mysql 实现权限管理系统(附源码地址)
- 微信小游戏小鸟飞行游戏
- 20190313-100538-非对称电容在变压器油中10kv高压电作用下产生力的现象
- GB材料数据库(!请注意鉴别其中的材料参数并不是完全正确!)
- JAVA商城,支持小程序商城、 供应链商城 小程序商城 H5商城 app商城超全商城模式官网 支持小程序商城 H5商城 APP商城 PC商城
- springboot的在线商城系统设计与开发源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈