解决头文件相互包含问题的方法
                                     



    所谓超前引用是指一个类型在定义之前就被用来定义变量和声明函数。
    一般情况下,C/C++要求所有的类型必须在使用前被定义,但是在一些特殊情况下,这种要求无法满足,例如,在类CMyView中保留了一个非模式对话框对象指针,该对象用于显示/修改一些信息。为了实现对话框"应用"按钮,把对话框做的修改立刻更新到view界面上,为此,需要在对话框类中需要保存view类的指针,这样定义关系就变成如下的代码:
   #ifndef __MYVIEW_H__
   #define __MYVIEW_H__
   //这是view类的头函数
   #include "MyDialog.h"
   class CMyView::public CView
   {
   protected:
       CMyDialog * pDlg;
       //这里是其他定义
   };
   #endif

深入浅出Win32多线程程序设计之线程通信
CString类型转换
Posted in VC&C# on 2006/11/24 / 评论(0) »
  因为一个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, ... );  
vc数据类型转换大全
int i = 100;
long l = 2001;
float f=300.2;
double d=12345.119;
char username[]="程佩君";
char temp[200];
char *buf;
CString str;
_variant_t v1;
_bstr_t v2;

一、其它数据类型转换为字符串


短整型(int)
itoa(i,temp,10);///将i转换为字符串放入temp中,最后一个数字表示十进制
itoa(i,temp,2); ///按二进制方式转换
长整型(long)
ltoa(l,temp,10);
浮点数(float,double)
用fcvt可以完成转换,这是MSDN中的例子:
int decimal, sign;

用VC编写基于Windows的精确定时程序
分页: 8/17 第一页 上页 3 4 5 6 7 8 9 10 11 12 下页 最后页 [ 显示模式: 摘要 | 列表 ]