随笔分类 -  MFC

CStatic控件SS_NOTIFY属性
摘要:SS_NOTIFYSends the parent window STN_CLICKED, STN_DBLCLK, STN_DISABLE, and STN_ENABLE notification codes when the user clicks or double-clicks the control.SS_NOTIFY属性使得CStatic控件能够接收鼠标事件并通知其父窗口,CStatic控件默认不接受鼠标事件PS:通过一个CStatic上tooltip不显示的问题发现 阅读全文
posted @ 2014-03-10 17:01 ximenchuixie 阅读(2926) 评论(0) 推荐(0)
MFC 线程中CWnd对象
摘要:尽量不要在MFC线程中将CWnd作为参数传递,会引起crash正确的做法:1. 将CWnd对应的handle传进来,通过CWnd::FromHandle()函数转换;2. 在线程中用SendMessage/PostMessage的方式进行通信。 阅读全文
posted @ 2013-09-14 00:32 ximenchuixie 阅读(236) 评论(0) 推荐(0)
MFC 发送 http 请求
摘要:http://msdn.microsoft.com/zh-cn/library/8yh4zs9e(v=vs.80).aspxhttp://www.cnblogs.com/Ray-chen/archive/2011/12/14/2287812.html 阅读全文
posted @ 2013-07-02 01:30 ximenchuixie 阅读(378) 评论(0) 推荐(0)
MCI 录制指定格式音频
摘要:可先用其他格式转换软件转换一段0秒指定格式的音频,然后用mcisendstring(L"open xxx.avi alias abc",0,0,0)打开,在进行录音mcisendstring(L"record abc",0,0,0)即可 阅读全文
posted @ 2013-07-02 00:00 ximenchuixie 阅读(189) 评论(0) 推荐(0)
MFC CFileFind
摘要:示例代码:转自MSDN:CFileFind finder; BOOL bWorking = finder.FindFile("*.*"); while (bWorking) { bWorking = finder.FindNextFile(); cout << (LPCTSTR) finder.GetFileName() << endl; }若要获得文件具体信息(如文件名,文件路径等)则在调用FindFile后至少调用一次FindNextFile; FindFile函数可理解为“开始搜索” 阅读全文
posted @ 2013-06-14 17:52 ximenchuixie 阅读(277) 评论(0) 推荐(0)
js 调 CDHtmlDialog API
摘要:头文件中声明:DECLARE_DISPATCH_MAP().c文件中加入BEGIN_DISPATCH_MAP(CMyDlg, CDHtmlDialog) DISP_FUNCTION(CMyDlg,"ResizeDialog",ResizeDialog,VT_EMPTY,VTS_I4 VTS_I4) //红色,javascript中调用的函数名;黄色,c++文件中实现的函数名END_DISPATCH_MAP() // VT_EMPTY: 返回值;VTS_I4 VTS_I4:参数OnInitDialog()中加入以下语句: En... 阅读全文
posted @ 2013-06-08 15:17 ximenchuixie 阅读(205) 评论(0) 推荐(0)
MFC MessageMap
摘要:例:ON_MESSAGE(WM_TEST,CLoadDllDlg::MyFunc) //自定义消息,函数原型应为 LRESULT MyFunc(WPARAM,LPARAM); ON_BN_CLICKED(IDC_BUTTON1,CLoadDllDlg::OnClickSendMsg)//内置消息,函数原型 void OnClickSendMsg();没有参数 阅读全文
posted @ 2013-06-03 23:03 ximenchuixie 阅读(192) 评论(0) 推荐(0)
MFC 指定加载资源(dll文件)的句柄
摘要:AfxSetResourceHandle() 阅读全文
posted @ 2013-06-03 18:46 ximenchuixie 阅读(239) 评论(0) 推荐(0)
MFC 跟踪鼠标事件
摘要:MFC 默认不发送鼠标消息,若要捕获鼠标消息,需手动调用TrackMouseEvent(&mouse) 函数。例:捕获鼠标停(onmousehover)、离开(onmouseleave)消息重载OnMouseMove函数void MyClass::OnMouseMove(UINT nFlags, CPoint point){ TRACKMOUSEEVENT mouse; mouse.cbSize = sizeof(TRACKMOUSEEVENT); mouse.dwFlags = TME_HOVER|TME_LEAVE; mouse.dwHoverTime = 10; mouse.hw 阅读全文
posted @ 2013-05-19 23:23 ximenchuixie 阅读(562) 评论(0) 推荐(0)
MFC 时间类 CTime
摘要:常用用法举例:CTime t1;t1 = CTime::GetCurrentTime(); //获得当前时间CTime t1;CTime t2;CTimeSpan tx;tx = t1 - t2; //t1 与t2之间的时间段int day = tx.GetDays(); //t1与t2之间间隔的天数, 其他GetTotalHours()/*间隔的小时数*/,GetTotalMinites()/*间隔的分钟数*/类似GetHours()与GetTotalHours()区别:例如 CTimeSpan tx(1,2,3,4);//间隔时间为1天2小时3分钟4秒GetHours()返回2GetTot 阅读全文
posted @ 2013-05-12 22:09 ximenchuixie 阅读(434) 评论(0) 推荐(0)
MFC 对话框 鼠标指针 变手形状
摘要:重载OnSetCursor函数BOOL CTest::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message){ if (pWnd->GetDlgCtrlID() == IDC_TEST) //IDC_TEST 控件ID { HCURSOR hCursor = LoadCursor(NULL,IDC_HAND); return hCursor != NULL ? (SetCursor(hCursor) != NULL) : FALSE; } return CDialogEx::OnSetCursor(pWnd, nHitTest, mess 阅读全文
posted @ 2013-04-24 17:18 ximenchuixie 阅读(439) 评论(0) 推荐(0)
MFC 注册表操作
摘要:CRegKey reg; HRESULT hr = reg.Open(HKEY_LOCAL_MACHINE,L"SOFTWARE\\Microsoft\\abc",KEY_READ|KEY_WRITE);//打开注册表路径 if (hr != ERROR_SUCCESS) { TRACE0("open reg wrong\n"); return; } DWORD dwHotKey; hr = reg.QueryDWORDValue(L"dwTestKey",dwHotKey);//读dwTestKey值 if (hr != ERROR 阅读全文
posted @ 2013-04-23 15:28 ximenchuixie 阅读(280) 评论(0) 推荐(0)
CImage, LoadFromResource 方法
摘要:LoadFromResource,只能加载BMP格式的图片CImage::LoadFromResource() is a very thin wrapper around the LoadImage API示例:onpaint()中:HINSTANCE hIns = AfxGetInstanceHandle(); m_img.LoadFromResource(hIns,IDR_PIC);m_img.StretchBlt(dc,CRect(0,0,m_img.GetWidth(),m_img.GetHeight()),CRect(0,0,m_img.GetWidth(),m_img.GetHei 阅读全文
posted @ 2013-04-22 01:07 ximenchuixie 阅读(1489) 评论(0) 推荐(0)