Visual C++窗体设计技巧集2006-10-13 13:45如何制作透明窗体 使用SetLayeredWindowAttributes可以方便的制作透明窗体,此函数在w2k以上才支持,而且如果希望直接使用的话,可能需要下载最新的SDK。不过此函数在w2k的user32.dll里有实现,所以如果你不希望下载巨大的sdk的话,可以直接使用GetProcAddress获取该函数的指针。
SetLayeredWindowAttributes的函数原型如下:
BOOL SetLayeredWindowAttributes(HWND hwnd, // handle to the layered windowCOLORREF crKey, // specifies the color keyBYTE bAlpha, // value for the blend functionDWORD dwFlags // action);
Windows NT/2000/XP: Included in Windows 2000 and later.Windows 95/98/Me: Unsupported.(注意了,在win9x里没法使用的)Header: Declared in Winuser.h; include Windows.h.Library: Use User32.lib.
一些常量: Read the rest of this entry »
1. 如何获取应用程序的实例句柄?应用程序的 实例句柄保存在CWinAppIm_hInstance 中,可以这么调用AfxGetInstancdHandle获得句柄.Example: HANDLE hInstance=AfxGetInstanceHandle();
2. 如何通过代码获得应用程序主窗口的指针?主窗口的 指针保存在CWinThread::m_pMainWnd中,调用 AfxGetMainWnd实现。AfxGetMainWnd() ->ShowWindow(SW_SHOWMAXMIZED); //使程序最大化.
Read the rest of this entry »
1个简单AT定时At 1:00 ShutDown /f /sAt 12:10 /every:星期一,星期二,星期三,星期四,星期五,星期六,星期日 ShutDown /f /s
申请Windows Vista RC1 CD-KEY的方法 许多朋友拿不到Vista RC1的CD-KEY,今晚研究了一下,翻出旧新闻找到一个隐秘的地址,意外地发现竟然可以在这里抢先获得RC1的CD-KEY,不同的Passport只能获取一次,并且它们是不相同的,大家可以试试看 (转自cnbeta) http://www.microsoft.com/windowsvista/PCTrialResults1.aspx?s=29&refer=%2Fwindowsvista%2Fzh-cn%2Fpreview.mspx
Windows Xp Professional Service Pack 2 English (Bootable With Sp2 Integrated).iso序列号Works perfect CD Key M3RTY-PH3DH-Q82D7-JFCB3-DRHRJUse this key: 47YK2-D8R6C-BPQBY-F4R3R-TVBTH
LEFT:expression((document.body.clientWidth-370)/2);POSITION:absolute;;TOP: expression((document.body.clientHeight-290)/2);
CString/string/char *比较详解
(一) 概述string和CString均是字符串模板类,string为标准模板类(STL)定义的字符串类,已经纳入C++标准之中;CString(typedef CStringT> CString)为Visual C++中最常用的字符串类,继承自CSimpleStringT类,主要应用在MFC和ATL编程中,主要数据类型有char(应用于ANSI),wchar_t(unicode),TCHAR(ANSI与unicode均可);char*为C编程中最常用的字符串指针,一般以’\0′为结束标志; Read the rest of this entry »
解决头文件相互包含问题的方法
所谓超前引用是指一个类型在定义之前就被用来定义变量和声明函数。 一般情况下,C/C++要求所有的类型必须在使用前被定义,但是在一些特殊情况下,这种要求无法满足,例如,在类CMyView中保留了一个非模式对话框对象指针,该对象用于显示/修改一些信息。为了实现对话框”应用”按钮,把对话框做的修改立刻更新到view界面上,为此,需要在对话框类中需要保存view类的指针,这样定义关系就变成如下的代码: #ifndef __MYVIEW_H__ #define __MYVIEW_H__ //这是view类的头函数 #include “MyDialog.h” class CMyView::public CView { protected: CMyDialog * pDlg; //这里是其他定义 }; #endif Read the rest of this entry »
[u][color=#810081]深入浅出Win32多线程程序设计之线程通信[/color][/u] Read the rest of this entry »
因为一个MFC CString类的对象包含TCHAR类型的字符,所以确切的字符类型取决于你所定义的预处理符号。大体来说,CString 很像STL string,这意味着你必须把它当成不透明的对象,只能使用CString提供的方法来修改CString对象。CString有一个string所不具备的优点:CString具有接收MBCS和Unicode两种字符串的构造函数,它还有一个LPCTSTR转换符,所以你可以把CString对象直接传给一个接收LPCTSTR的函数而不需要调用c_str()函数。// ConstructingCString s1 = “char string”; // construct from a LPCSTRCString s2 = L”wide char string”; // construct from a LPCWSTRCString s3 ( ” ”, 100 ); // pre-allocate a 100-byte buffer, fill with spacesCString s4 = “New window text”; // You can pass a CString in place of an LPCTSTR: SetWindowText ( hwndSomeWindow, s4 ); // Or, equivalently, explicitly cast the CString: SetWindowText ( hwndSomeWindow, (LPCTSTR) s4 ); 你可以从你的字符串表中装载一个字符串,CString的一个构造函数和LoadString()函数可以完成它。Format()方法能够从字符串表中随意的读取一个具有一定格式的字符串。 // Constructing/loading from string tableCString s5 ( (LPCTSTR) IDS_SOME_STR ); // load from string tableCString s6, s7; // Load from string table. s6.LoadString ( IDS_SOME_STR ); // Load printf-style format string from the string table: s7.Format ( IDS_SOME_FORMAT, “bob”, nSomeStuff, … ); Read the rest of this entry »