color new
-
I am trying to create a color fill that will change relative to a new value being input from the "OnHScroll" function. When I input a new value for the red color variable in the RGB function and re-display, the color never changes to the new value. See code segment below. How do I change? ... ... int a=0,b=190,c=230,x; CMainFrame::CMainFrame() { //Set color frame colorbar.CreateSolidBrush(RGB (a, b, c)); }; void CMainFrame::OnPaint() { CPaintDC dc(this); dc.TextOut (5,40,"Red Color Is:"); //Output color frame colorbar.DeleteObject(); colorbar.CreateSolidBrush(RGB(a,b,c)); dc.SelectObject(colorbar); CRect rc(100,150,150,200); dc.Rectangle (&rc); } void CMainFrame::OnHScroll(UINT nSBCode, UINT nPos, CWnd* pCtrl) { //Convert pointer to slider pointer CSliderCtrl *pSld; pSld = (CSliderCtrl*)pCtrl; //Get new position x = pSld->GetPos(); a = x; CString s; s.Format("%d",x); //Output value for red stcred.SetWindowText(s); } Note that: 1.) Initialize the colorbar to have values RGB(a,b,c) 2.) Variable "a" read in from the "OnHScroll" function and set to a new value. 3.) "OnPaint" deletes the old colorbar and re-creates with new "a" variable value, should display as output with the new color but doesn't, still displays as original a,b,c values. Please advise, Sid kraft sid_kraft@msn.com Thanks in advance, Sid Kraft. Sid
-
I am trying to create a color fill that will change relative to a new value being input from the "OnHScroll" function. When I input a new value for the red color variable in the RGB function and re-display, the color never changes to the new value. See code segment below. How do I change? ... ... int a=0,b=190,c=230,x; CMainFrame::CMainFrame() { //Set color frame colorbar.CreateSolidBrush(RGB (a, b, c)); }; void CMainFrame::OnPaint() { CPaintDC dc(this); dc.TextOut (5,40,"Red Color Is:"); //Output color frame colorbar.DeleteObject(); colorbar.CreateSolidBrush(RGB(a,b,c)); dc.SelectObject(colorbar); CRect rc(100,150,150,200); dc.Rectangle (&rc); } void CMainFrame::OnHScroll(UINT nSBCode, UINT nPos, CWnd* pCtrl) { //Convert pointer to slider pointer CSliderCtrl *pSld; pSld = (CSliderCtrl*)pCtrl; //Get new position x = pSld->GetPos(); a = x; CString s; s.Format("%d",x); //Output value for red stcred.SetWindowText(s); } Note that: 1.) Initialize the colorbar to have values RGB(a,b,c) 2.) Variable "a" read in from the "OnHScroll" function and set to a new value. 3.) "OnPaint" deletes the old colorbar and re-creates with new "a" variable value, should display as output with the new color but doesn't, still displays as original a,b,c values. Please advise, Sid kraft sid_kraft@msn.com Thanks in advance, Sid Kraft. Sid
sidkraft wrote:
//Output value for red stcred.SetWindowText(s);
Use
InvalidateRect(...)
with your colorfill rect as a parameter afterstcred.SetWindowText(s);
which fires the Onpaint Message and you will get the result Knock out 't' from can't, You can if you think you can :cool: