dcsimg
Results 1 to 2 of 2

Thread: Button Color Simulator

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    810

    Button Color Simulator

    After creating a new MAC OCX style button, I found it somewhat difficult to figure out the association between the color code (RGB) and the actual color produced. So I borrowed on Derp's idea of a color tester and modified my simulator.

    I could not find a way to get the button handle from the OCX, so I added a Public Get to recover the handle. Then I could recover each pixel and add it to the corner simulator automatically. What this showed is 2 white pixels still present on each corner. It turns out that I wasn't adding a pixel to those locations, and the white background was showing through. So I printed out each pixel color for the rectangular area created for the button without adding any new color pixels. Areas outside the rounded corner would display FFFFFFFF (Invalid), and areas inside the rounded corner would display FFFFFF (White). Below is the Upper Left Corner using 0/1 to make it more readable.
    0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
    0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1
    0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
    0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

    This identified the exact locations that needed to be painted. At the same time, I adjusted the ragged edge displayed for the upper corners. These changes were added to the Colors.vbp program, which is also attached. The file produced by this program can be added to the Resource Editor and the OCX.

    Changing each color element will display the result in Hex format in the Text Box below the scroll bars. As well, the resulting color will display in the small Picture Box, and its effect on the button and the current corner simulation. Changing all three colors to 255 (vbWhite) will produce a gray button.

    The Background Check Box provides a gray background so that unpainted pixels can be seen.

    The Resource file (Button.RES) has been updated, so using DrawMACButton or DrawMacOSXColored should produce the same result. DrawMacOSXColored is very inefficient, but it is useful if you want to play with the base coloring (vbBlue).

    J.A. Coutts
    Note: The Handle recovery function produces an error in the OCX and cannot be used there.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by couttsj; Dec 19th, 2019 at 05:50 PM.

  2. #2
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,750

    Re: Button Color Simulator

    JFYI, here are some more "buttons"



    These are several 9-patches combined into a single PNG image (for emulating bootstrap buttons), all with proper alpha-channel. These are prepared to be "9-patch stretched" onto the button face.

    cheers,
    </wqw>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width