/*★ Frame に Win32 API で描画する 前田 稔 ★*/ #include #pragma comment(lib, "user32.lib") #pragma comment(lib, "gdi32.lib") #using #using #using using namespace System; using namespace System::Windows::Forms; using namespace System::Drawing; //フォームを作成するクラス ref class FormClass : public System::Windows::Forms::Form { private: public: Form^ form; //Constructor FormClass() { form = gcnew Form(); Paint += gcnew PaintEventHandler(this, &FormClass::MyHandler); } void MyHandler(Object^ sender, PaintEventArgs^ e) { HWND hWnd = (HWND)this->Handle.ToInt32(); HDC hdc; hdc= ::GetDC(hWnd); for(int i=20; i<220; i++) { ::SetPixel(hdc,i,20,RGB(255,0,0)); ::SetPixel(hdc,i,40,RGB(0,0,255)); ::SetPixel(hdc,i,41,RGB(0,0,255)); ::SetPixel(hdc,i,42,RGB(0,0,255)); } ::ReleaseDC(hWnd,hdc); } }; //★ main() 関数 int main() { // コントロールが作成される前に、Windows XP ビジュアル効果を有効にします Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // メイン ウィンドウを作成して、実行します Application::Run(gcnew FormClass()); return 0; }