SetClassLong不能立即設置效果 需要重繪。

在單文檔的 VIEW類裏

SetClassLong(GetSafeHwnd(),GCL_HBRBACKGROUND,(LONG)GetStockObject(2));

改變背景是可以的 能夠立即看出來

但是要是對話框裏的oncreate裏需要重繪

InvalidateRect(NULL,TRUE);

這樣纔會看出效果

 

From   MSDN:
Use   the   SetClassLong   function   with   care.   For   example,   it   is   possible   to   change   the   background   color   for   a   class   by   using   SetClassLong,   but   this   change   does   not   immediately   repaint   all   windows   belonging   to   the   class

 

/*#define WHITE_BRUSH         0
#define LTGRAY_BRUSH        1
#define GRAY_BRUSH          2
#define DKGRAY_BRUSH        3
#define BLACK_BRUSH         4
#define NULL_BRUSH          5
#define HOLLOW_BRUSH        NULL_BRUSH*/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章