博文

不在这里写了(2008-04-27 15:01:00)

摘要:重新搞了个空间http://hi.csdn.net/ToCpp......

阅读全文(1445) | 评论:0

CWnd使用(2008-03-17 16:24:00)

摘要:一般情况下开始学习MFC时都知道CWnd是MFC窗口类的基类,稍微深入学习后突然想从最基本的学起,即自己从CWnd派生一个窗口类而不是总通过AppWizard产生一个预先定义好的窗口类,其实更加赤裸点就是直接把CWnd做为窗口类,以下为范例程序: #include <afxwin.h> class CMyApp:public CWinApp { public:        BOOL InitInstance();        virtual int ExitInstance(); }; CMyApp theApp;   BOOL CMyApp::InitInstance() {        CWnd* pMainWnd=new CWnd;        pMainWnd->CreateEx(0,0,"MyWnd",         WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX,         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,         NULL, NULL);        this->m_pMainWnd=pMainWnd;        m_pMainWnd->ShowWindow(m_nCmdShow);        m_pMainWnd->UpdateWindow();  &nb......

阅读全文(9654) | 评论:0

又是指针和数组(2008-03-06 14:49:00)

摘要:#include <stdio.h>
int main()
{
 int a[5]={1,2,3,4,5};
 int i;
 int *ptr=(int*)(&a+1);
 printf("ptr=%p\n",ptr);
 for(i=0;i<5;i++)
  printf("%p\n",a+i);
 printf("%d,%d\n",*(a+1),*(ptr-1));
} 以下是输出 ptr=0013FF64
0013FF50
0013FF54
0013FF58
0013FF5C
0013FF60
2,5 哎,想了半天才发现是&a+1而不是a+1真是粗心啊!......

阅读全文(2168) | 评论:0

MFC is back(2007-11-21 12:09:00)

摘要:Hello again. My name is Ale Contenti, and I’m the Dev Lead for the VC++ Libraries. I’m writing this blog entry from my hotel room in Barcelona. Steve Teixeira and I are here for TechEd Developers Europe. Let me tell you that the atmosphere here is just great! Lots of people and a lot of Visual Studio and C++ users. Lots of interest in Visual Studio 2008 and all the new features and functionality we’ve added to the product.   Kate Gregory, Steve and I covered more than 7 talks about different C++ topics, ranging from debugging to interop to MFC. My main talk was about “MFC Updates for Visual Studio 2008 and Beyond”.   In this session I introduced the major new features we’re implementing for MFC.  With these features, developers will be able to create modern applications that leverage the “look and feel” of Microsoft Office, Internet Explorer and Visual Studio.   My MFC talk was in a pretty big room, and the audience was extremely interested! It was great to......

阅读全文(2587) | 评论:0

google vs tencent(2007-09-29 16:57:00)

摘要:
前些时看到Tencent发布了一个日程管理软件,当时觉得界面还蛮好看的,但是是个测试版好多东西还不能用,后来又在网上无意中发现google也有个在线日历,打开后发现两者的界面是如此相似,也不知道是谁模仿谁……

......

阅读全文(2105) | 评论:0

指针趣事(2007-09-18 23:53:00)

摘要:       今天是个大晴天,温暖的阳光透过窗子照进了这间宽敞的办公室,办公室里三三两两的人们正在各自的计算机前努力工作,一切都显得那么的安静、祥和、有条不紊 …… “啊~!救命啊!Solmyr 你又用文件夹砸我!” “愚蠢者是应该受到惩罚的。” 画外音: …… 呃,好吧,我得承认有点小小的例外。这里是一家软件公司,发出惨叫的这位是 zero ,新进的大学生;这边一脸优雅,看上去很有修养一点也不象刚刚砸过人的这位,是 Solmyr ,资深程序员,负责 zero 这一批新人的培训。啊,故事开始了 …… “我干了什么啦?”zero 揉着鼻子问道,“这次你拿来砸我的文件夹又大了一号!” “你过来自己看看你犯下的错误。”Solmyr 翻出了 zero 刚刚交上来的一段代码: ……
char* msg = “Connectting ... Please wait“
……
if( Status == S_CONNECTED )
strcpy(msg, “Connectted“);
…… “我犯了什么错误啦?这是一个很平凡的字符串声明而已”,zero 不满的说到。 “你看不出来吗?connect 这个单词的进行时和过去时你都拼错了,多打了一个 t”,Solmyr 不紧不慢地回答。 “就为了这个你又用文件夹砸我 …… 啊!这次又是光盘盒!” “这是商用软件,你以为是在 QQ 上和 PPMM 聊天,有错别字不要紧啊?更糟糕的是,我故意留了这么长的时间给你,到现在你还没发现你真正的错误在什么地方。你可真不是一般的菜啊~”,Solmyr 故意拖了个长音,满意的看到 zero 处于爆发的边缘,“好吧,让我们从基础开始,C 语言中是怎样处理字符串的?” “这个我知道”,zero 显得很有自信,“C/C++ 语言中,字符串是一段连续的字符型内存单元,每个单元存放一个字符,并用 \0 作为结尾的标记。” “那么使用指针之前,我们应当 ……” “我们应当保证这个指针指向合法的内存,要么指向一块已经存在的内存,要么为它动态分配一块。”,zero 开始露出得意的笑容 —— 这种程度的问题,哈! “好!那么你的代码中 msg 这个指针指向哪里?”......

阅读全文(2045) | 评论:0

Key Concept: Polymorphism in C++(2007-09-05 22:35:00)

摘要:The crucial point about references and pointers to base-class types is that the static typethe type of the reference or pointer, which is knowable at compile timeand the dynamic typethe type of the object to which the pointer or reference is bound, which is knowable only at run timemay differ. The fact that the static and dynamic types of references and pointers can differ is the cornerstone of how C++ supports polymorphism. When we call a function defined in the base class through a base-class reference or pointer, we do not know the precise type of the object on which the function is executed. The object on which the function executes might be of the base type or it might be an object of a derived type. If the function called is nonvirtual, then regardless of the actual object type, the function that is executed is the one defined by the base type. If the function is virtual, then the decision as to which function to run is delayed until run time. The version of the virtual functi......

阅读全文(2838) | 评论:1

转载 MFC消息详解 (2007-09-05 14:48:00)

摘要:MFC消息详解
1. 怎样使用MFC发送一个消息用MFC发送一个消息的方法是,
    首先,应获取接收消息的CWnd类对象的指针;
    然后,调用CWnd的成员函数SendMessage( )。
        LRESULT Res=pWnd->SendMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
        pWnd指针指向目标CWnd类对象。变量Msg是消息,wParam和lParam变量包含消息的参数,如鼠标单击哪里或选择了什么菜单项。目标窗口返回的消息结果放在变量Res中。
        发送消息到一个没有CWnd类对象的窗口,可以用下列目标窗口的句柄直接调用Windows API:
        LRESULT Res=::SendMessage(HWND hWnd, UINT Msg,  WPARAM wParam, LPARAM lParam);
        这里的hWnd是目标窗口的句柄。
2. 怎样用MFC寄送一个消息
    用MFC寄送一个消息与发送一个消息几乎相同,但寄送时用PostMessage( ) ,而不是用SendMessage( );返回值Res也不一样,Res不是一个由目标窗口返回的值,而是一个布尔值,用来表示消息是否成功地放到消息队列中。
3. 检索一个寄送消息
    正常情况下,一旦消息被寄送后,应用程序在后台发送它。但是在特殊情况下,需要你自己去删除一个消息,例如想在应用程序接收到某种消息之前停止应用程序。有两种......

阅读全文(3176) | 评论:0

float ToolBar && dock ToolBar(2007-09-01 11:21:00)

摘要:A docked toolbar is a child of the frame window it's docked to, but a floating toolbar is a child of the mini frame window that surrounds it. The mini frame window is a popup window owned by the frame window, but it's not a child of the frame window. (A popup window is a window with the style WS_POPUP; a child window has the WS_CHILD style instead.) The distinction is important because popup windows owned by a frame window are destroyed before the frame window is destroyed. Child windows, on the other hand, are destroyed after their parents are destroyed. A floating toolbar no longer exists when the frame window's OnDestroy function is called.......

阅读全文(3074) | 评论:1

消息传递过程(2007-09-01 01:05:00)

摘要:
据说是在Run中调用AfxWndProc(侯捷说的我在源码中找了会没找到,也不晓得是哪个间接调用的),在该函数里面接着调用AfxCallWndProc,然后AfxCallWndProc中有这么一段 // special case for WM_INITDIALOG CRect rectOld; DWORD dwStyle = 0; if (nMsg == WM_INITDIALOG) _AfxPreInitDialog(pWnd, &rectOld, &dwStyle);   // delegate to object's WindowProc lResult = pWnd->WindowProc(nMsg, wParam, lParam);   // more special case for WM_INITDIALOG if (nMsg == WM_INITDIALOG) _AfxPostInitDialog(pWnd, rectOld, dwStyle); 如果不是WM_INITDIALOG消息则调用CWnd的WindowProc,这时就有点迷惑了,应该说CCmdTarget是处理消息的基类其中的OnCmdMsg为什么不先调用呢,其实我也不清楚,查看了源代码后发现在WindowProc中会判断消息的类型里面有这么段: CWnd::WindowProc if (message == WM_COMMAND) {        if (OnCommand(wParam, lParam))        {               lResult = 1;               goto LReturnTrue;        } ......

阅读全文(3676) | 评论:0