-
July 23rd, 2018, 02:31 AM
#16
Re: Changing the color of elements - Win API
Originally Posted by binary2
For creating a filled rectangle I have this code:
Code:
hdc=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
rect = {0, 0, 500,500};
brush = CreateSolidBrush(RGB(50, 151, 151));
FillRect(hdc, &rect, brush);
DeleteObject(brush);
This goes in "case WM_CREATE:"
The problem is that the rectangle is created at x = 0, y = 0 relative to the screen instead of the window
You might use a "control" approach instead and place an empty border-less custom-colored static control on the main window for achieving exactly the same result. A zero-cost benefit would be no need in playing with screen-to-window coordinate translation.
Last edited by Igor Vartanov; July 23rd, 2018 at 02:35 AM.
Best regards,
Igor
-
July 23rd, 2018, 02:53 AM
#17
Re: Changing the color of elements - Win API
Originally Posted by binary2
Thank you!
Is there a way to set a border color and style to a "static" control? I'm interested in applying a dotted border to the top and bottom of the control
Bitmap-based brush might help. Please note that you are to draw the bitmap with the entire control border, including all the style effects, e.g. bevels, round corners, etc.
Per my experience, classic Windows controls like button, edit box, static, etc. are real stubborn things and PITA to customize. Sometimes it's simpler to implement a your own control from scratch than subclass any of the native old-school Windows controls.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|