邪恶八进制信息安全团队技术讨论组's Archiver

sunnlo 2006-7-16 13:49

[转载]vc++.net鼠标事件处理

文章作者:sunnlo
原始连接:[url]http://hi.baidu.com/sunnlo/blog/item/9dc3544ef89dd309b2de0538.html[/url]

代码如下:
[code]//Form1.h
//省略vc自动生成的代码

private:static bool shouldpaint=false;

private: System::Void Form1_MouseDown(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)
   {
    shouldpaint=true;
   }

private: System::Void Form1_MouseUp(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)
   {
    shouldpaint=false;
   }

private: System::Void Form1_MouseMove(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)
   {
    if(shouldpaint){
    Graphics *graphics=CreateGraphics();
    graphics->FillEllipse(new SolidBrush(
     Color::BlueViolet),e->X,e->Y,4,4);
    }
   }

private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
   {
    MessageBox::Show(S"用鼠标在窗体上按下左键挪动就会画画\n我的qq是29899004");
   }[/code]

编译好的应用程序请到[url]http://sunnlo.phpnet.us/mouse.exe[/url]下载

页: [1]
© 1999-2008 EvilOctal Security Team