鼠标悬停时改变图片框,鼠标离开时重置
Changing picture box on mouseover, and resetting on mouseleave
我正在开发一个windows窗体程序,很难找到如何在c++中做到这一点。MSDN有这个页面,http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.image,但与VB相比,c++文档是缺乏的。
这是我目前所知道的。这种方法应该避免常见的闪烁问题,但我不确定从那里去,因为我需要它回到鼠标离开后的原始图像。
void InitializeComponent(void)
{
this->btnExit->BackColor = System::Drawing::Color::Transparent;
this->btnExit->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
this->btnExit->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"btnExit.Image")));
this->btnExit->Location = System::Drawing::Point(764, 4);
this->btnExit->Name = L"btnExit";
this->btnExit->Size = System::Drawing::Size(30, 20);
this->btnExit->TabIndex = 3;
this->btnExit->TabStop = false;
this->btnExit->Click += gcnew System::EventHandler(this, &mainForm::btnExit_Click);
}
#pragma endregion
private: System::Void btnExit_OnMouseEnter(System::Object^ sender, System::EventArgs^ e) {
Image^ get ();
void set (Image^ value);
}
谢谢。
private: System::Void btnExit_MouseEnter(System::Object^ sender, System::EventArgs^ e) {
btnExit->Image = Image::FromFile("C:\Users\...\image.png");
}
工作,不确定这是不是正确的方法。
相关文章:
- WinAPI挂钩鼠标
- 将鼠标悬停在问题上时与预期">"相关的代码错误
- 跟踪滚动条上的鼠标事件
- SendInput()鼠标移动计算
- 为什么我的点没有在 OpenGL 中绘制鼠标所在的位置?
- 如何在鼠标挂钩过程中检测拖动
- 在函数范围内在堆栈上分配的数组在离开函数时是否总是被释放?
- Win32 发送输入鼠标移动滞后并冻结
- 将鼠标和键盘输入发送到 unity3d 游戏 (Rust)
- 有没有办法区分Qt小部件是通过鼠标单击还是通过按表键获得焦点?
- 在 macOS 中使用 C/C++ 设置鼠标光标图像
- 如何通过拖动鼠标QT检查按钮?鼠标移动事件
- SDL2 调整窗口大小后如何缩放鼠标坐标?
- 鼠标离开 GLFW窗口后触发 GLFW 鼠标回调?
- ncurses检测鼠标何时离开窗口
- MFC鼠标移动/离开,悬停在按钮上
- 使用供过于求来防止鼠标离开窗口
- Qt QItemDelegate提交数据并在鼠标上关闭编辑器,离开视图小部件(listView)
- Qt鼠标离开事件,而按下按钮
- 鼠标悬停时改变图片框,鼠标离开时重置