随笔- 182
文章- 1
评论- 28
阅读-
57万
随笔分类 - MFC
Microsoft Foundation Classes
响应键盘消息
摘要:一:首先介绍键盘消息系统消息: ALT,F1,——F24等,是由系统内部处理的,程序本身就存在,比如F1是帮助键。 WM_SYSKEYDOWN WM_SYSKEYUP WM_SYSCHAR非系统消息: 是由我们自己加上去的, WM_KEYDOWN WM_KEYUP WM_CHAR二、添加消息(一般WM_KEYDOWN),在消息响应函数OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)有三个变量,nChar这是虚拟键代码,另外两个不常用,用时参看MSDN。如果要响应组合键,可以用GetAsyncKeyState()检测按键状态如: case VK_U
阅读全文
使继承CStatic的类响应消息
摘要:CStatic缺省是不响应消息的。在资源编辑器中把静态控件属性中的的NOTIFY选上,或者在代码设置。如:this->ModifyStyle(0, SS_NOTIFY);
阅读全文
获取控制台程序的HWND和HINSTANCE
摘要:一,获取HWND的方法:1,API:HWND GetConsoleWindow(NULL)Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.HeaderDeclared in Wincon.h; include Windows.h.LibraryUse Kernel32.lib.DLLRequires Kernel32.dll.2, 通过调用
阅读全文
重载OnOK、OnCancle、OnClose
摘要:MFC默认建立的Dialog按Esc响应OnCancel,回车响应OnOK,都会关闭对话框,只要重载OnOk和OnCancel函数即可,但此时点击关闭按钮无法关闭窗口,还需要再重载OnClose函数。代码如下:void CMFCDemoDlg::OnBnClickedOk(){// TODO: Add your control notification handler code here//OnOK();}void CMFCDemoDlg::OnBnClickedCancel(){// TODO: Add your control notification handler code here/
阅读全文
_CrtDbgReport: String too long or IO Error
摘要:_CrtDbgReport: String too long or IO Errorwprintf_s不能正常输出中文的解决办法使用如下方法调用wprintf_s输出中文时往往出现带?的乱码:wprintf_s(L"%s",(LPCWSTR)cmdLineArr[1]);解决方案:包含头文件locale.h,并在程序开始调用setlocale(LC_ALL, "chs");这样wprintf_s便能正常打印出中文字符串了://指定当前程序的编码为简体中文,这样才能用wprintf正确输出中文#includelocale.hsetlocale(LC_ALL,"chs");同样对于TRACE(
阅读全文
获取CListCtrl选种第几项
摘要:INT nItem = 0; POSITION pos = m_blcPlaylist.GetFirstSelectedItemPosition(); if (pos == NULL) TRACE0("No items were selected!\n");else { while (pos) { nItem = m_blcPlaylist.GetNextSelectedItem(pos); TRACE1("Item %d was selected!\n", nItem); // you could do your own processing on nItem here }
阅读全文
Common File Extensions Used by Visual C++
摘要:SUMMARYVisual C++ writes and uses a number of files during the build process. This article describes the file extensions commonly used in a Visual C++ project. Back to the topMORE INFORMATIONFiles Used by Visual C++.C -- C language source file: This file is compiled as a C file. If it contains C++ c
阅读全文
函数调用约定
摘要:函数调用约定 __stdcall是函数调用约定的一种,函数调用约定主要约束了两件事: 1.参数传递顺序 2.调用堆栈由谁(调用函数或被调用函数)清理 常见的函数调用约定:stdcall cdecl fastcall thiscall naked call __stdcall表示 1.参数从右向左压入堆栈 2.函数被调用者修改堆栈 3.函数名(在编译器这个层次)自动加前导的下划线,后面紧跟一个@符号,其后紧跟着参数的尺寸 在win32应用程序里,宏APIENTRY,WINAPI,都表示_stdcall,非常常见。MFC缺省调用约定 1、_stdcall是Pas
阅读全文
DrawImage调查
摘要:Status DrawImage( [in] Image *image, [in] const Point *destPoints, [in] INT count, [in] INT srcx, [in] INT srcy, [in] INT srcwidth, [in] INT srcheight, [in] Unit srcUnit, [in] ImageAttributes *imageAttributes, [in] DrawImageAbort callback, [in] VOID *callbackData);imageAttributes [in] ImageAttribute
阅读全文
GDI+资料
摘要:VC6下的GDI+双缓冲http://www.vckbase.com/document/viewdoc/?id=1811GDI和GDI+对象的相互转换http://www.vckbase.com/document/viewdoc/?id=1680GDI+编程基础(一)GDI+ Vs GDIhttp://www.vckbase.com/document/viewdoc/?id=1440GDI+编程(...
阅读全文
How can I convert from GdiPlus::Image to CBitmap?
摘要:Draw the image in a memory device context in which the CBitmap object is selected.Like in next example:Code:using namespace Gdiplus;Image* pImage = Image::FromFile(L"c:\\test.gif");Status status = pIm...
阅读全文
Custom draw 和 Owner draw 的区别
摘要:"Custom Draw" is a feature shared by all of Microsoft's common controls, which allows you to interject your own code while the control is drawing itself. In this way, you can customize the appearance ...
阅读全文
CListCtrl资料
摘要:使用Custom Draw优雅的实现ListCtrl的重绘http://blog.csdn.net/dylgsy/archive/2006/06/21/818550.aspxNeat Stuff to Do in List Controls Using Custom Drawhttp://dev.firnow.com/course/3_program/c++/cppsl/2008419/11064...
阅读全文
环境变量以及ControlSet
摘要:用户环境变量HKEY_CURRENT_USER\Environment\系统环境变量HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Session Manager\Environment\pathHKEY_LOCAL_MACHINE\SYSTEM\ControlSet001下记录着“系统服务、驱动、系统控制、枚举信息”等的相关设置。那么Con...
阅读全文
VARIANT and VARIANTARG Data Types
摘要:The following definition of VARIANT is described in OAIDL.H automation header file:struct tagVARIANT{ union { struct __tagVARIANT { VARTYPE vt; WORD wReserved1; WORD wReserved2; WORD wReserved3; unio...
阅读全文
Windows Management Instrumentation (Windows 管理规范) 的秘密
摘要:问题 1:WMI 是什么,它能帮我做什么?问题 2: WMI 适用于那些平台?问题 3:如果 WMI 向外界暴露特定的功能,我如何才能知道?问题 4:如果 WMI 没有提供我想要的功能,我应该怎么办? 问题 5:在哪里可以找到使用 WMI 的示例脚本?问题 6: 为什么我的脚本可以在某个版本的 Windows 上运行,但在另外一个版本的 Windows 上却不能运行?问题 7:为什么 WMI 操作...
阅读全文
MFC坐标转换
摘要:MapDialogRect,转换对话框坐标为像素坐标 功能:该函数把指定的对话框单位映射成屏幕单位(像素)。函数MapDialogRect用变换坐标替换指定的RECT结构中的坐标,这就使得该结构可以用来创建对话框或定位对话框内的控制。 函数原型:BOOL MapDialogRect(HWND hDlg,LPRECT IpRect); 参数: hDlg:标识对话框。MapDialogRec...
阅读全文
16.2.2火车站售票系统模拟程序(CriticalSection)
摘要:#include<iostream>#include<Windows.h>using namespace std;DWORD WINAPI ThreadProc1(LPVOID lpParameter);DWORD WINAPI ThreadProc2(LPVOID lpParameter);CRITICAL_SECTION CriticalSection;int tick...
阅读全文
16.1.4火车站售票系统模拟程序(Event)
摘要:#include<iostream>#include<Windows.h>using namespace std;DWORD WINAPI ThreadProc1(LPVOID lpParameter);DWORD WINAPI ThreadProc2(LPVOID lpParameter);HANDLE hEvent;int tickets = 100;int main(...
阅读全文
15.4.1火车站售票系统模拟程序(Mutex)
摘要:#include <iostream>#include <Windows.h>using namespace std;int tickets = 100;HANDLE hMutex;DWORD WINAPI ThreadProc1(LPVOID lpParameter);DWORD WINAPI ThreadProc2(LPVOID lpParameter);int mai...
阅读全文