Im new in MFC/C++ an Im trying to fill my windows with pixels.I found out that there is a function which is called :
SetPixel(X,Y,RGB(,,));
After I tried to put use it in my loop I found out that this function stops after an amount of pixels.So It don't give me the result I actually want to reach. Here is my code :
void PIXELPROG::OnPaint() { if (IsIconic()) { CPaintDC dc(this); SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; dc.DrawIcon(x, y, m_hIcon); } else { CDialogEx::OnPaint(); } CStatic * XText = (CStatic *)GetDlgItem(IDC_X); CStatic * YText = (CStatic *)GetDlgItem(IDC_YWERT); CString XYWert; for (int x=0,y=0;;) { GetDC()->SetPixelV(x, y, RGB(y,x,y)); XYWert.Format(L"%d",y); XText->SetWindowTextW(XYWert); ++x; if (x == 500) { ++y; x = 0; } if (y == 100) { break; } } } I also don't get any errors.It is just stopping. I also tried it with
SetPixelV()
But didn't helped neither. Someone got an idea ?
SetWindowTextW()uses the message queue which overflows, blocking further messages. Since you are inside a message handler, the messages can't be handled. What are you trying to do with that loop? Maybe a different approach to solving your real problem would help.