Windows CE开发EVC简单功能代码,高手看看,谢谢
[复制链接]
下面代码主要实现滑动条设置RGB颜色功能,(窗口就三个滑动条:RED,GREEN,BLUE)为什么我的窗口看不到显示的颜色。
BOOL CSliderUseDlg::OnInitDialog()
{
CSliderCtrl *pSliderRed=(CSliderCtrl*)GetDlgItem(IDC_SLIDER_RED);
ASSERT(pSliderRed!=NULL);
pSliderRed->SetRange(0,255);
pSliderRed->SetPos(128);
CSliderCtrl *pSliderGreen=(CSliderCtrl*)GetDlgItem(IDC_SLIDER_GREEN);
ASSERT(pSliderGreen!=NULL);
pSliderGreen->SetRange(0,255);
pSliderGreen->SetPos(128);
CSliderCtrl *pSliderBlue=(CSliderCtrl*)GetDlgItem(IDC_SLIDER_BLUE);
ASSERT(pSliderBlue!=NULL);
pSliderBlue->SetRange(0,255);
pSliderBlue->SetPos(128);
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CSliderUseDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
{
int iRed,iGreen,iBlue;
if((pScrollBar->GetDlgCtrlID()==IDC_SLIDER_RED)||(pScrollBar->GetDlgCtrlID()==IDC_SLIDER_GREEN)||(pScrollBar->GetDlgCtrlID()==IDC_SLIDER_BLUE))
{
CSliderCtrl *pSliderRed=(CSliderCtrl*)GetDlgItem(IDC_SLIDER_RED);
CSliderCtrl *pSliderGreen=(CSliderCtrl*)GetDlgItem(IDC_SLIDER_GREEN);
CSliderCtrl *pSliderBlue=(CSliderCtrl*)GetDlgItem(IDC_SLIDER_BLUE);
iRed=pSliderRed->GetPos();
iGreen=pSliderGreen->GetPos();
iBlue=pSliderBlue->GetPos();
}
UpdateData(TRUE);
CBrush colorBrush;
COLORREF clRGB;
clRGB =RGB(iRed,iGreen,iBlue);
CClientDC * pClientDC;
pClientDC= new CClientDC(this);
colorBrush.CreateSolidBrush(clRGB);
CRect rect(80,120,160,200);
pClientDC->FillRect(rect,&colorBrush);
delete pClientDC;
CDialog::OnHScroll(nSBCode,nPos,pScrollBar);
}