2016-09-06 5 views
1

SolidBrushをグローバルに作成する方法はありますか、既存のブラシをクローンする必要がありますか?GDI +グローバルに新しいSolidBrushを作成

グローバル変数:

Gdiplus::Brush* WhiteBrush; 

スコープコード:

{ 
    Gdiplus::SolidBrush white(Gdiplus::Color(0, 0, 0)); 
    WhiteBrush = white.Clone(); 
} 

答えて

1

あなたはグローバル宣言にブラシを新しいことができます。実行時静的オブジェクトの初期化中に構築されます。

#include <memory>  
std::unique_ptr<Brush> WhiteBrush(new SolidBrush(Color(255, 255, 255, 255))); 

非スマートポインタのバージョンは次のようになります。

Brush * WhiteBrush = new SolidBrush(Color(255,255,255,255)); 
関連する問題