学习记录:
两个类,一个为主类
1个为:CCkDlg,主类
1个为: Https,用来做HTTPS请求获得页面状态。
测试界面如下:
CCkDlg 类里定义函数
void CCkDlg::printf_r(CString str) //用于输出日志信息 { m_log.SetSel(-1,-1); m_log.ReplaceSel(str + " ",1); }
Https 类里:
#pragma once class CCkDlg; //集成cckDlg class Https { public: Https(void); ~Https(void); void test(void); };
Https类里调用CCkDlg类里的函数
void Https::test()
{
//CWnd* pWnd = AfxGetApp()->GetMainWnd(); CCkDlg* ck = (CCkDlg*)AfxGetApp()->GetMainWnd(); //获得主程序句柄 ck->printf_r(L"Hello words"); //获得定义的
MessageBoxW(NULL,L"https",L"https",MB_OK);
}
之后CCkDlg ,界面按钮响应事件:
void CCkDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here Https* Thttps = new Https; Thttps->test(); }