|
prasad_som wrote: It doesn't have any effect there.
Whats do you mean. If I didnt called the default procedure for WM_PAINT, then how will the button get painted? Nothing will appear in the place of button. Isn't it?
nave
|
|
|
|
|
Naveen R wrote: Whats do you mean. If I didnt called the default procedure for WM_PAINT, then how will the button get painted?
You are confusing between painting a control and drawing a control.
In case of of non-owner drawn control windows takes care of drawing/creating control. WM_PAINT message is meant to paint invalidated area.
Now about calling base class OnPaint . It simply does default painting routines and validates invalidated area.
So Consider this function,
void CMyButton::OnPaint()
{
CButton::OnPaint();
and code following has no effect
CPaintDC dc(this);
}
Consider another scenario,
void CMyButton::OnPaint()
{
CPaintDC dc(this);
invalidated area will be validated and
CButton::OnPaint has no effect.
CButton::OnPaint();
}
Hope this clears your doubts.
|
|
|
|
|
prasad_som wrote: void CMyButton::OnPaint(){ CButton::OnPaint();// //Here at above line invlaidated client area will be validated and code following has no effect CPaintDC dc(this); // device context for painting //drawing routine follows}
I never said to create another CPaintDC below the CButton::OnPaint(); He can use CClientDC dc(this) to create a device context and do painting to it. Surely it will work.
nave
|
|
|
|
|
I already tried something with WM_PAINT, but it didn't work. And after reading this article in MSDN i give up on WM_PAINT...
"Handling WM_PAINT
The most extreme choice is to implement a WM_PAINT handler and do all the painting yourself."
http://msdn2.microsoft.com/en-us/library/ms364048(vs.80).aspx
|
|
|
|
|
Why dont you use the class CBitmapButton???
nave
|
|
|
|
|
|
Can you explain how do you think that i should use CBitmapButton class? As i see that class only helps in inserting bitmaps on to buttons, but it still needs me to draw the button (because my bitmap is displayed only on one small portion of button).
|
|
|
|
|
that's a problem .. I will tell you another way.
Make the button owner draw, in the DrawItem Function,do as follows
DrawItem()
{
DrawFrameControl();// This function will draw a statndard button.
// here , draw your bitmap
}
nave
|
|
|
|
|
|
|
OK thanks, this looks like something i needed.
|
|
|
|
|
I did it, it works now, thank you.
|
|
|
|
|
nave
|
|
|
|
|
Naveen R wrote: I never said to create another CPaintDC below the CButton::OnPaint();
Yes, but it is what should be used in OnPaint messages.
CClientDC associated with whole client area of window, as opposed to CPaintDC which is associated to invalidated rect only.
So consider how logical is it to use CClientDC there.
BTW,havn't you come across this line whenever added WM_PAINT message handler throught class wizard ?
// Do not call CButton::OnPaint() for painting messages
|
|
|
|
|
Igor Jerosimic wrote: OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
As told by Navin, you need to do all drawing stuff in case of owner drawn controls.
And should not call base version, as this function is supposed to override in derived control.
|
|
|
|
|
Have you see this?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
WhiteSky wrote: See A Better Bitmap Button Class[^] if helpfuls
i liked it sometime before
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Re
|
|
|
|
|
|
CImageButton class is very lousy way of replacing API function DrawFrameControl and i definitely don't need that...
All that code is easily replaced with these 4 lines of code:
CPaintDC dc(this);
CRect rc;
GetClientRect(&rc);
dc.DrawFrameControl(&rc, DFC_BUTTON, DFCS_BUTTONPUSH);
http://img214.imageshack.us/img214/6206/drawingfx6.png
|
|
|
|
|
Hello,
I have the following situation:
Input is char *buf (which is the content of a web page).
I have the following code
char v; <br />
for (i=0; i<strlen(buf); i++)<br />
{<br />
v = buf[i]; <br />
}
I get a negative v if the page has Greek characters I get negative values for v. Something like v=-50. Is there any method to get the character behind -50 ?
Thanks.
|
|
|
|
|
Sounds like you should be scraping the content of the page as Unicode (wide chars, wchar_t ) instead of ANSI (narrow chars, char ).
The standard ASCII table, which you are really using like-it-or-not when dealing with char types, does not have a lot of extended characters in it, and the ones it has can be treated differently by different systems. For example, -50 is 0xCE , which can be Î or ╬ , or some other character...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks for the reply. The whole application is developed around ANSI and changing everyting looks like not such a good idea. I was wandering if there is any mechanism to determine the “real character” behind -50. If I know that the real character is a greek character I can convert it into a html entity for example and I can get something like %u03C.
|
|
|
|
|
I dont know you checked my post or not...but this will work..isnt it?
CString cstext = L"03C5";
wchar_t Greek;
int nChar;
swscanf( cstext, L"%x", &nChar );
Greek = nChar;
nave
|
|
|
|
|
I did . Thanks.
I do not use CString (not using MFC). Your solution works but I am trying to find a way to determine if there is a possible to find our which Greek character is assigned to -50 (if there is such a possibility).
|
|
|
|