没有结果,看来只有用钩子了
来源:互联网 发布:设ab都是n阶对称矩阵 编辑:程序博客网 时间:2024/04/30 00:21
- #include "stdafx.h"
- #include "find.h"
- #include "findDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- CFindDlg::CFindDlg(CWnd* pParent )
- : CDialog(CFindDlg::IDD, pParent)
- {
-
-
-
-
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CFindDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
-
-
-
- }
- BEGIN_MESSAGE_MAP(CFindDlg, CDialog)
-
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BTN_FIND, OnBtnFind)
- ON_BN_CLICKED(IDC_BTN_GET, OnBtnGet)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BTN_CAPTURE, OnBtnCapture)
-
- END_MESSAGE_MAP()
- BOOL CFindDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
-
- SetIcon(m_hIcon, TRUE);
- SetIcon(m_hIcon, FALSE);
-
-
- InitControls();
-
- return TRUE;
- }
- void CFindDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this);
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- 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;
-
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- HCURSOR CFindDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CFindDlg::OnBtnFind()
- {
- HWND hWnd;
- if (hWnd = FindWindowEx())
- {
- }
- AfxMessageBox(_T("end"));
- }
- HWND CFindDlg::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPCTSTR lpszClass, LPCTSTR lpszWindow)
- {
- HWND hWndFind, hWnd;
- if (hWndFind = ::FindWindowEx(hwndParent, hwndChildAfter, lpszClass, lpszWindow))
- {
- if (hWnd = ::FindWindowEx(hwndParent, hwndChildAfter, NULL, _T("Item View")))
- {
- m_hFindWnd = hWnd;
- AfxMessageBox(_T("find!"));
- return hWnd;
- }
- FindWindowEx(hWndFind, NULL, lpszClass, lpszWindow);
- FindWindowEx(hwndParent, hWndFind, lpszClass, lpszWindow);
- }
- return NULL;
- }
- HWND CFindDlg::FindWindowEx()
- {
- return FindWindowEx(NULL, NULL, NULL, NULL);
- }
- HWND CFindDlg::FindSibling(HWND hWndParent, HWND hwndChildAfter, LPCTSTR lpszClass, LPCTSTR lpszWindow)
- {
- HWND hWnd;
- return NULL;
- }
- HWND CFindDlg::FindChildren(HWND hWndParent, HWND hwndChildAfter, LPCTSTR lpszClass, LPCTSTR lpszWindow)
- {
- HWND hWnd;
- return NULL;
- }
- void CFindDlg::OnBtnGet()
- {
-
- HWND hWnd = ::GetDlgItem(m_hFindWnd, 0);
- if (hWnd)
- {
- AfxMessageBox("findx");
- }
- else
- {
- CString str;
- str.Format(_T("??%d??"), ::GetLastError());
- AfxMessageBox(str);
- }
- hWnd = ::GetWindow(hWnd, GW_CHILD);
- if (hWnd)
- {
- AfxMessageBox("find");
- }
- else
- {
- CString str;
- str.Format(_T("%d"), ::GetLastError());
- AfxMessageBox(str);
- }
- }
- void CFindDlg::OnButton2()
- {
- CListCtrl *pList = static_cast<CListCtrl*>(GetDlgItem(IDC_LIST2));
- if (pList == NULL)
- {
- AfxMessageBox("not found");
- return;
- }
- TCHAR str[256];
- ::GetWindowText(pList->m_hWnd, str, 256);
- CListCtrl list;
- list.Attach(pList->m_hWnd);
- list.GetItemText(0, 1, str, 256);
- AfxMessageBox(str);
- list.Detach();
- HWND hWnd = ::FindWindowEx(m_hFindWnd, NULL, _T("LISTVIEW"), NULL);
- if (!hWnd)
- {
- AfxMessageBox("sign");
- }
- }
- void CFindDlg::InitControls()
- {
- CListCtrl *pList = static_cast<CListCtrl*>(GetDlgItem(IDC_LIST2));
- if (pList == NULL)
- {
- AfxMessageBox("not found");
- return;
- }
-
- pList->SetExtendedStyle(pList->GetExtendedStyle() | LVS_EX_FULLROWSELECT);
- pList->InsertColumn(0, _T("title"), LVCFMT_LEFT, 80);
- pList->InsertColumn(1, _T("comment"), LVCFMT_LEFT, 80);
- pList->InsertColumn(2, _T("credit"), LVCFMT_LEFT, 80);
- pList->InsertItem(0, _T("shit"));
- pList->SetItemText(0, 1, _T("very good"));
- pList->SetItemText(0, 2, _T("amazing"));
- pList->InsertItem(1, _T("shit"));
- pList->SetItemText(1, 1, _T("very good"));
- pList->SetItemText(1, 2, _T("amazing"));
- }
- void CFindDlg::OnBtnCapture()
- {
- CString str;
- CPoint pt;
- GetCursorPos(&pt);
- CListCtrl *pList = static_cast<CListCtrl*>(WindowFromPoint(pt));
- if (pList)
- {
- str.Format(_T("%d"), pList->m_hWnd);
- AfxMessageBox(str);
- return;
- }
- HWND hWnd = ::WindowFromPoint(pt);
- CListCtrl list;
- list.Attach(hWnd);
-
- AfxMessageBox(list.GetItemText(0, 1));
- list.Detach();
- }