close

 

 

以前,在還沒發現這個API之前,要抓螢幕的正中間,實在是很麻煩,最後還甚至寫了一個專門的Function去處理這件事,現在,500? 不用 ! 100 ? 不用 .... 兩行就好=_=+ 

在afxwin.h裡面有一個Function叫做 : 

void CenterWindow(CWnd* pAlternateOwner = NULL);

只要你是繼承CWnd的類別,你都可以使用這個Function來將你的Dialog放到你視窗的正中間。

 

Parameters :

pAlternateOwner : Pointer to an alternate window relative to which it will be centered ( other than the parent window) . 

 

 

用法很簡單

Step1 : 找到你的OnInitDialog

BOOL CXXXXXDialog::OnInitDialog()
{

Step2 : add code 

            int w , h ;

            w = h = 300;

            SetWindowPos(NULL, 0, 0, w, h, SWP_SHOWWINDOW | SWP_NOMOVE) ;

            CenterWindow() ;

            return (TRUE) ;

}

 

 

 

 

 

 

 

 

 

arrow
arrow

    Eric 發表在 痞客邦 留言(1) 人氣()