can somebody tell me what invalidate(); really does because i heard its used to call the paint event, thing is if i put my code to resize an image on the window as a background it doesn't wanna draw it i see the the old pixels mixed with the new drawed ones..
so if i use invalidate before that it will make all other controls from the window flicker for some reason so is there another function i can use ?
and another thing how can i get a pixel color from the center of cbitmap and draw that color with a width and height ? :P
btw im using MFC, thanks.
Cwnd::Invalidate justs makes sure that the client area is painted the next time a WM_PAINT message is received; it doesn't 'force' a repaint. If you're rendering the background of a window then you might consider handling the WM_ERASBKGROUND message (CWnd::OnEraseBkgnd) and doing any background drawing there. To reduce the flickering of controls you should make sure that the parent of those controls has the WS_CLIPCHILDREN window style. To reduce flicker in the drawing itself then you might consider using double buffering - search the boards as there have been many discussions/examples regarding this.
>>how can I get the pixel colour<<
>>draw that color with a width and height<<
Not sure what you mean so I'll guess you're looking to fill a rectangle, in which case CDC::FillRect or CDC::FillSolidRect may be of some interest.
wow thx alot man exactly what i was lookin for i never knew that a simple thing like setting the window style causes that whole flickering problem lol...
ah 1 last thing please whenever i import a custom icon it looks bad as quality, the icon itself is 16x16, 32x32, 48x48 and 32bit colors i have no idea why it doesn't display correctly and when the app is loading i can see the mfc icon changing to my icon any ideas ? :P thanks.
heres a screenshot..
How are you drawing the icon (post some code)?
Could be that 32bit icons have a mask and an image, both have to be drawn to get the full effect. Or that the system has defaulted back to a 16/256 colour image for the icon.
Without knowing how you are drawing / setting the icon we would have to guess.
im using mfc on visual c++ 6.0 and im using the default drawing..
oh and the icon is true color on 16x16 32x32 48x48
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
well the icon quality is one thing but i can't figure out why it shows that mfc icon when its loading and switches fast to my icon and when i have too many windows in the taskbar the group icon is the mfc one.. lol
edit: ok nvm i fixed the icon problem looks like the default mfc thing has some weird probs
but the mfc icon is still displaying..
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon - so i just removed this line and looks perfect