从visual C++.NET 2002(VC 7.0)开始,一些存在于MFC的基础类被重写和修订,削减了与 其他MFC类之间的关系。这些类库可以独立被用于任何的native C++工程。

  • CFileTime
  • CFileTimeSpan
  • CFixedStringT
  • CImage
  • COleDateTime
  • COleDateTimeSpan
  • CPoint
  • CRect
  • CSimpleStringT
  • CSize
  • CStrBufT
  • CStringData
  • CStringT
  • CTime
  • CTimeSpan
  • IAtlStringMgr
CSimpleStringT
 |
 +--CStringT
     |
     +--CFixedStringT

测试代码

例子

https://github.com/codepongo/utocode/tree/master/windows/independentmfc

int 
main(int argc, char* argv[])
{
    /* string */
    CStringT< char, StrTraitATL< char, ChTraitsCRT< char > > > str;
    str = "hi";
    str += ",independent MFC!\n";
    printf(str);


    /* point size rect */
    CPoint pt;
    CRect rc;
    CSize sz;
    rc.left = rc.top = 0;
    rc.right = rc.bottom = 100;
    sz = rc.Size();
    pt.x = 10;
    pt.y = 10;
    printf("rect(%d, %d, %d, %d):(%d,%d) move (%d, %d)\n",
        rc.left, rc.top, rc.right, rc.bottom, sz.cx, sz.cy, pt.x, pt.y);

    /* time */
    CTime tms;
    CTime tm;
    str.Format("%04d-%02d-%02d %02d:%02d:%02d\n",
        tms.GetYear(), tms.GetMonth(), tms.GetDay(), tm.GetHour(), tm.GetMinute(), tm.GetSecond());
    printf(str);

    CFileTime ft;
    CFileTimeSpan fts;
    COleDateTime dt;
    COleDateTimeSpan dts;

    str.Format("%lld\n", ft.GetTime());
    printf(str);

    /* image */
    CImage image;
    image.Load(L"image.png");
    str.Format("width:%d height%d\n", image.GetWidth(), image.GetHeight());
    printf(str);

    system("pause");
    return 0;
}

对MFC无依赖

参考

ATL/MFC Shared Classes

Classes Shared by MFC and ATL

MFC Hierarchy Chart

CString模板结构解析

标签: cplusplus, windows
日期: 2014-01-10 17:30:06, 11 years and 6 days ago
留言

回复不允许使用html标签

通过电子邮件通知我有后续评论.