dポイントプレゼントキャンペーン実施中!

現在visual studio 2008 Express Editionで、c++/cli .NET のFormアプリケーションを作成しています。
Bitmapクラスに格納した画像データを、全画面で背景を黒にして表示させたいのですが、やり方がわかりません。誰か教えてください!!

A 回答 (1件)

 こんばんは。



 フルスクリーン見たいにしたいのでしょうか。ポップアップスタイルでデスクトップ全体を覆ってしまえば良い様な気がします。
 以下はキーボードのどれかを押す度にフルスクリーン⇔ウィンドウを切り替えます。参考程度に。

//メンバ変数
private: System::Windows::Forms::FormBorderStyle formBorderStyleOrg;
private: System::Drawing::Rectangle rectOrg;
private: System::Drawing::Bitmap^ bitmap;

public: Form1(void)
{
InitializeComponent();
//
//TODO: ここにコンストラクタ コードを追加します
//
//取り敢えずココでビットマップをロードする
this->bitmap = dynamic_cast<System::Drawing::Bitmap^>(gcnew System::Drawing::Bitmap("test.bmp"));
}

//KeyPress
private: System::Void Form1_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e)
{
//ポップアップでなければ
if(this->FormBorderStyle != System::Windows::Forms::FormBorderStyle::None)
{
//デスクトップを取る
System::Windows::Forms::Screen^ scr = System::Windows::Forms::Screen::PrimaryScreen;

//現在のボーダースタイルを退避する
this->formBorderStyleOrg = this->FormBorderStyle;

//現在のウィンドウ領域を退避する
this->rectOrg = this->Bounds;

//ボーダースタイルをポップアップにする
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;

//デスクトップの領域を設定する
this->Bounds = scr->Bounds;
}
//元に戻す
else
{
//以前のボーダースタイルを設定する
this->FormBorderStyle = this->formBorderStyleOrg;

//以前のウィンドウ領域を設定する
this->Bounds = this->rectOrg;
}
}

//Paintイベント
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
{
//黒いブラシを作成する
System::Drawing::Brush^ brush = gcnew System::Drawing::SolidBrush(System::Drawing::Color::Black);

//ビットマップが有効なら
if(this->bitmap != nullptr)
{
const int x = (this->ClientSize.Width - this->bitmap->Width) / 2;
const int y = (this->ClientSize.Height- this->bitmap->Height) / 2;

//背景を黒く塗り潰す
e->Graphics->FillRectangle(brush, this->ClientRectangle);

//中心にビットマップを描く
e->Graphics->DrawImage(this->bitmap, System::Drawing::Point(x, y));
}
//ブラシを消す
delete brush;
}
    • good
    • 0
この回答へのお礼

フォームのプロパティの設定を
WindowState→Maximized
FormBorderStyle→None
と、任意に変えられるようにしたら一応フルスクリーンができるようになりました!
ご丁寧な回答ありがとうございます。
非常に参考になるようなところが多いので、今後のプログラムの参考にさせていいただきます。

お礼日時:2009/03/26 20:11

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!