RGB Preview Dialog
Posted
by Hakan Bulut
on March 6th, 2002
This application shows a COLORREF structure that use Slider Control to determinates your 24-bit RGB color and shows also simple way to communicate between CSliderCtrl, CEdit, and CStatic.
void CRGBDlg::OnVScroll( UINT nSBCode,
UINT nPos,
CScrollBar* pScrollBar)
{
CSliderCtrl* pSlider = (CSliderCtrl*) pScrollBar;
CString szColorValue;
int i = pSlider->GetDlgCtrlID () - IDC_SLIDER1;
// Now, nColor = current SliderPosValue
nColor[i] = pSlider->GetPos();
szColorValue.Format("%d", nColor[i]);
SetDlgItemText(i + IDC_EDIT1, szColorValue);
// Get a pointer to the static window.
CStatic* pStatic = &m_ctlPaintStatic;
pStatic->UpdateWindow();
pStatic->Invalidate();
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
// PaintST.cpp : implementation file
//
void CPaintST::OnPaint()
{
CPaintDC dc(this); // device context for painting
CBrush* pOldBrush;
GetClientRect(rcStatic);
CBrush brBack(m_crBkColor);
dc.FillRect(rcStatic, &brBack);
pOldBrush = dc.SelectObject(&brBack);
dc.SelectObject(pOldBrush);
// Do not call CStatic::OnPaint() for painting messages
}
BOOL CPaintST::OnEraseBkgnd(CDC* pDC)
{
CBrush brBackgnd;
// Get a pointer to the parent window
CRGBDlg* pColorDlg = (CRGBDlg*) GetParent();
ASSERT(pColorDlg != NULL);
// Get new color value from SliderCtrl.
m_crBkColor = RGB ((BYTE) pColorDlg->nColor[0],
(BYTE) pColorDlg->nColor[1],
(BYTE) pColorDlg->nColor[2]);
GetClientRect(rcStatic);
brBackgnd.CreateSolidBrush(m_crBkColor);
pDC->FillRect(rcStatic, &brBackgnd);
return CStatic::OnEraseBkgnd(pDC);
}

Comments
In what time? 2008? 2001? 2009? What the difference?
Posted by Hakan Bulut on 01/12/2008 04:49pmWhen these codes write would be curious about?
ReplyUse Wm_CtlColor
Posted by Legacy on 05/15/2002 12:00amOriginally posted by: Eric Schmidt
-
ReplyGood idea..
Posted by Hakan Bulut on 01/12/2008 04:07pmVery good.
Replyheh...
Posted by Legacy on 04/21/2002 12:00amOriginally posted by: g.sharp
it was so amusing to read everyone getting all serious about code like this... i just had to say something
-O
-
ReplySo you say
Posted by Hakan Bulut on 01/12/2008 04:10pmYou may say as you wanted.
ReplyYou've missed the point...
Posted by Legacy on 03/09/2002 12:00amOriginally posted by: Ryan Binns
How many times have you borrowed someone else's code and not had to modify it, even one tiny little bit??? I have used a fair amount of code from this site, and I have never had one bit of code that I didn't have to change to suit my application.
This code is obviously not going to suit every situation, but it works perfectly for the situation it was designed for. If you make sure that the slider control IDs are defined consecutively, then there will be no problem at all.
If you "criticisers" are not smart enough to work this out, then I suggest you take your comments elsewhere, rather than abusing someone who wants to share some of their code with other people.
-
-
ReplyThe answer of this unrequired polemic.
Posted by Hakan Bulut on 01/13/2008 10:30amI'm 33 years old!. If you are just as allright?
ReplyThank you
Posted by Hakan Bulut on 01/12/2008 04:13pmThanks for carriage. It works very fast.
ReplyThanks...
Posted by Legacy on 03/08/2002 12:00amOriginally posted by: Hakan
Thanks to Andy because of this good comment. Thanks as well to Mr. Bruce. I know, this just the first day's homework of Visual C++ programming class. I didn't say "I am a professional". For Painter: Sorry pal but I think of this is fastest and simple the code way to control 3 slider controls, at the same time. I want to note something down:
ReplyThe important line of this function is this? (int i = pSlider->GetDlgCtrlID () - IDC_SLIDER1;)
If you ask to this question that means you must obtain information about GetDlgCtrlID() Please take a look at the MSDN for "GetDlgCtrlID()"..
By the way, the greatest thanks go to Mr. Rick Wallach who support me morally..
Yours faithfully
Thanks..
Posted by Legacy on 03/07/2002 12:00amOriginally posted by: Anoop
Sometimes some code is not submitted just to prove something, but to show how something can be done.
-
-
-
-
-
-
-
-
ReplyAt first!
Posted by Hakan Bulut on 01/13/2008 10:47amWe can be a people who have an idea of what is the people and a people is what mean that in the humanity history. We can be ask a question to ourselves in our minds, so could i be a people? Some take a look at the back whom are there in this world and whom are came to the world. I am so sorry that because of the putting up this bad things and the bad position in which completely oputside of the humanity.
ReplyI wont reguest from you feeling shame!.
Posted by Hakan Bulut on 01/13/2008 10:35amThis is just to be brazen-faced!. If I am going to go to put something down!...
ReplyAnyway
Posted by Hakan Bulut on 01/12/2008 04:44pmAll posts are looks like a game piece.
ReplyI have been coming more.
Posted by Hakan Bulut on 01/12/2008 04:40pmHow much more can i come? To be rescued from this LOL position.
ReplyYes
Posted by Hakan Bulut on 01/12/2008 04:31pmBecause the Visual C++ Resource editor has been counted it automatically.
ReplyYes so.
Posted by Hakan Bulut on 01/12/2008 04:27pmYou are right. I think so too alltime.
ReplySorry pal
Posted by Hakan Bulut on 01/12/2008 04:24pmThere is something in this life but no left choice to coming success. This was the one of that things.
ReplyLOL?
Posted by Hakan Bulut on 01/12/2008 04:21pmPLEASE, I WANT TO DRAW THE ATTENTION IN THAT DOT. I am not taking a clue if the life is to take only a clue. I can not take it anymore this is impossible.
ReplyAhh...I'm sorry but what's the point of this code
Posted by Legacy on 03/06/2002 12:00amOriginally posted by: painter
I'm sorry but this looks like the first day's homework of Visual C++ programming class...
and this line -
int i = pSlider->GetDlgCtrlID () - IDC_SLIDER1;
has huge possibilities to produce bug.
Reply