color change
-
I am trying to change colors using variables in the initialization of a RGB command. The following are the commands used in MFC/Visual C++ 6.0: int a = 200; int b = 180; int c = 125; CMainFrame::CMainFrame() { //Set color frame colorbar.CreateSolidBrush(RGB (a, b, c)); } void CMainFrame::OnPaint() { CPaintDC dc(this); CRect rc(100,150,150,200); a = 140; dc.FillSolidRect(&rc,RGB(a,b,c)); } No matter what I set a to, it always displays with the original value for color. Is there a way to change the RGB colors after initialization? Please let me know at sid_kraft@msn.com. Thanks in advance, Sid Kraft Sid
-
I am trying to change colors using variables in the initialization of a RGB command. The following are the commands used in MFC/Visual C++ 6.0: int a = 200; int b = 180; int c = 125; CMainFrame::CMainFrame() { //Set color frame colorbar.CreateSolidBrush(RGB (a, b, c)); } void CMainFrame::OnPaint() { CPaintDC dc(this); CRect rc(100,150,150,200); a = 140; dc.FillSolidRect(&rc,RGB(a,b,c)); } No matter what I set a to, it always displays with the original value for color. Is there a way to change the RGB colors after initialization? Please let me know at sid_kraft@msn.com. Thanks in advance, Sid Kraft Sid
Seems this will work properly. check for local definitions of variable 'a' You always filling a rectangle with a value 140,180,125 the how you could track the difference? When filling a solid rectangle, you don't need to create teh solid brush. the brush you have created is not selected by any dc. so if you are not using that, remove the same. SaRath.
"Don't Do Different things... Do Things Differently..." Understanding State Pattern in C++ -
I am trying to change colors using variables in the initialization of a RGB command. The following are the commands used in MFC/Visual C++ 6.0: int a = 200; int b = 180; int c = 125; CMainFrame::CMainFrame() { //Set color frame colorbar.CreateSolidBrush(RGB (a, b, c)); } void CMainFrame::OnPaint() { CPaintDC dc(this); CRect rc(100,150,150,200); a = 140; dc.FillSolidRect(&rc,RGB(a,b,c)); } No matter what I set a to, it always displays with the original value for color. Is there a way to change the RGB colors after initialization? Please let me know at sid_kraft@msn.com. Thanks in advance, Sid Kraft Sid
a rectangle with green color(almost) of course OnPaint in CSDIView::OnPaint()_**
**_
whitesky