我原先是在sdk程式下面想用SendMessage發送一條WM_GETFONT消息給一個button控件從而取得這個button的字體的,但是返回值總是零值,但用相同的方法去取一個mfc程式里用CButton 類建立起來的button控件的字體時,就能得到正确的返回值,后來用spy++查看時才髮現,mfc將原來的視窗函式替換掉了,於是我跟進CWnd中,在進行SubClass時,他用的是m_pfnSuper這個類成員里保存的地址作為新視窗函式的地址的,但是卻怎麼也找不到這個變量是什麼時候被賦的值,新的視窗函式的實作碼到底在哪個地方,有沒有高人可以幫忙把它揪出來啊,多謝了.

解决方案 »

  1.   

    我關鍵就是想知道新的視窗函式是怎麼在處理WM_GETFONT這條消息並返因正確字體信息的
      

  2.   

    http://expert.csdn.net/Expert/topicview.asp?id=1228284
      

  3.   

    你看错了,应该去看CDialog::OnInitDialog函数。
    你要看也要看DoModal,在此过程中调用了(Win32API)::CreateDialogIndirect。
    所以在API中的东西都被编译过了,你是看不到的。
    你再回到MSDN中,看解释如何?The CreateDialogIndirect macro uses the CreateWindowEx function to create the dialog box. CreateDialogIndirect then sends a WM_INITDIALOG message to the dialog box procedure. If the template specifies the DS_SETFONT or DS_SHELLFONT style, the function also sends a WM_SETFONT message to the dialog box procedure. The function displays the dialog box if the template specifies the WS_VISIBLE style. Finally, CreateDialogIndirect returns the window handle to the dialog box.
      

  4.   

    demetry(智者橡木) 給的文章俺以前也看過,不過不是太明白,我都還沒怎麼看過mfc,mfc又包得太深,我現在只是想知道MFC里的新的視窗函式是怎樣處理這條消息的.richmain老兄講的東西我不是太明白,不過謝謝你的參與,會有分送的,俺有五千多的可用分一直送不掉啊
      

  5.   

    我剛剛試著自已先用CreateFontIndirect生成了一個HFONT並用SendMessage(hWnd,WM_SETFONT,(WPARAM)hFont,TRUE);傳給了button,然后再用WM_GETFONT去取的時候就能取出正確的值了,看來Button原來的視窗函式並不是沒處理這條消息,而是因為button使用的系統的字體,所以返回了null值!mfc的新的視窗函式可能就多做了如果是使用系統字體就返回系統字體而不是返回null的動作.
    The return value is a handle to the font used by the control, or NULL if the control is using the system font. 
    可是......我要怎麼取得繫統字體呢?