小项目
● 拖拽控件
● 设置编辑框属性
● 程序逻辑
● 获取焦点的事件
1 void CEventDemoDlg::OnSetfocusEditText() 2 { 3 // 获取焦点 4 MessageBox(L"Hello"); 5 }
● 启动以后会不停的弹 下消息框
● 解决办法多拖动一个按钮即可
初始化代码
1 m_hEvent = CreateEvent(nullptr, TRUE,FALSE,nullptr);//设置位手动 设置无信号
实现代码
1 void CEventDemoDlg::OnSetfocusEditText() 2 { 3 // 获取焦点 4 //MessageBox(L"Hello"); 5 if(m_hThreadGetCount == INVALID_HANDLE_VALUE) 6 m_hThreadGetCount = (HANDLE)_beginthreadex(nullptr, 0, ThreadGetCount, this, 0, nullptr); 7 8 if (m_hIsURL == INVALID_HANDLE_VALUE) 9 m_hIsURL = (HANDLE)_beginthreadex(nullptr, 0, ThreadGetCount, this, 0, nullptr); 10 11 ResetEvent(m_hEvent);//Event设置位有信号状态 12 } 13 unsigned CEventDemoDlg::ThreadGetCount(void* lParam) 14 { 15 CEventDemoDlg* pThis = (CEventDemoDlg*)lParam; 16 WaitForSingleObject(pThis->m_hEvent, INFINITE); 17 CString szEdit; 18 //pThism_Edit.GetWindowText() 19 int strLeng = pThis->GetDlgItemTextW(IDC_EDIT_TEXT, szEdit); 20 pThis->SetDlgItemTextW(IDC_STATIC, (LPCTSTR)strLeng); 21 return 0; 22 } 23 unsigned CEventDemoDlg::ThreadIsUrl(void* lParam) 24 { 25 return 0; 26 }
时间: 2024-10-10 01:54:27