|
-
Jun 27th, 2001, 12:29 PM
#1
Thread Starter
PowerPoster
SetBkColor API call
The "Setbkcolor" API call sets the back color of an object with the hwnd/hdc property like this
Call Setbkcolor(command1.hwnd, RGB(34,54,123))
This does not work. It does not change the color of my command button.
Does anybody know why its not changing the color of my command button
-
Jun 27th, 2001, 12:49 PM
#2
Member
why are you using api? you have vb6, can't you just set the style to graphical and make the back color the color you want?
-
Jun 27th, 2001, 01:39 PM
#3
To start with, hWnd and hDC are two different things.
hWnd is a window handle, and hDC is the handle to a device context.
If a function needs a hDC, you can't just use the hWnd.
If a control doesn't expose the hDC as a property, you can get it using the GetWindowDC function. If you use this function, you should use ReleaseDC as soon as you don't need the hDC anymore, otherwise your application will leak handles.
But now we come to the real problem.
Visual Basic does recreate the device context every time it draws the command button. Your backcolor change won't be persistent, VB changes it back to it's property settings.
If all you want to do is to change the backcolor, I would suggest setting the backcolor property of the button (don't forget to change the style to graphical).
-
Jun 27th, 2001, 01:49 PM
#4
You don't even need API to change the backcolor. Change the Style property to Graphical then change the BackColor to whatever colour you want.
-
Jun 27th, 2001, 05:58 PM
#5
Thread Starter
PowerPoster
But..........
OK, Actually I did not have vb installed at that time so I just guessed that it may the hwnd but even if i need hdc, i get the hdc of command button and it does not change the backcolor even if i give it correct parameters.
If vb is not able to change the backcolor of the command button then will it work in C++?
And is there any API call to change the forecolor(Setforecolor) or textcolor(SetTextColor) to change the text color on any object?
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
|