How to get size of check and gap in check box?

前端 未结 7 1437
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 06:46

I have a check box that I want to accurately measure so I can position controls on a dialog correctly. I can easily measure the size of the text on the control - but I don\'

相关标签:
7条回答
  • 2020-12-15 07:17

    Ok dudes my way is maybe not the fastes to use in runtime, but it works for me in any case i have tested so far. In the beginnin of my proggys i put in a function to get the size and store it in a global variable (yeah i have heard this would be bad, but i dont care about this)

    here the explanation:

    1. Create a treeview (invisible if u want)
    2. Create an imagelist with atleast 1 image inside (size 16x16)
    3. Set the imagelist to the treeview ("TVSIL_NORMAL")
    4. Get the "TVSIL_STATE" imagelist from the treeview (u have to create "TVSIL_NORMAL" before, otherwise this one will fail!)
    5. Use ImageList_GetIconSize(..) and store the size. Wow, the checkboxs and the radio-buttons have the same size as the state icons of the treeview. Now u have what u want!
    6. Destroy the "TVSIL_NORMAL" imagelist
    7. Destroy the treeview

    this code needs only a few microseconds at the beginning of my proggies and i can use the value everytime i need it.

    0 讨论(0)
提交回复
热议问题