开发者

Writing controls like a button in C++\Win32 (not MFC or CLI)?

开发者 https://www.devze.com 2022-12-27 03:54 出处:网络
I have several questions concerning the controls like a button, if You could answer i would be very much pleased.

I have several questions concerning the controls like a button, if You could answer i would be very much pleased.

Questions:

  1. Is there any way to create a control like a button, but开发者_JAVA技巧 not-standard, i mean, not that strict-rectangled button
  2. How do I handle mouse hover events within the control

Regards, Galymzhan Sh


It's relatively easy. If you want the same behaviour as a button (click, hover etc etc), then the best bet is to subclass the button control.

Have a read of the following MSDN articles:

http://msdn.microsoft.com/en-us/library/bb773183.aspx
http://msdn.microsoft.com/en-us/library/ms997565.aspx
http://msdn.microsoft.com/en-us/library/ms633569.aspx


This one is tricky one.
I developed my own GUI, it is advance topic.
Here is how i developed mine.

  1. Create class called button

    • In button class, create all variables needed like the width and Height of the button

    • Have a render function

    • If you gonna let users load their own texture for the button, you should include a load function

  2. Create class for wrapper

    • Have a Add button function and use ids for buttons
    • Have a EventProc that checks for hovers, clicks...
    • Have a Render controls function to render all buttons

This is just simple way to write buttons

0

精彩评论

暂无评论...
验证码 换一张
取 消