Balloon tip corrupting custom dialog background [modified]
-
Hello, I just started learning WinAPI a month ago. I have a dialog i created using custom class i register (so i am also in charge of WM_ERASEBKGND and WM_PAINT). Actually removing WM_ERASEBKGND part and selecting stock brush for my class doesn't change things. An Edit control placed on that dialog, which has ES_NUMBER style (greets me with that balloon tip when i try typing anything besides a number). Something odd is happening when this balloon tip pops out. All of my dialog's background text gets somehow copied and placed at an offset, close to and even under that edit box. If anyone could help me pinpointing what can i be doing wrong i would be very happy. Here is my wm_paint, which can be responsible for this behaviour, since... well, i have not much beside this. As you can see it's only drawing some text. Btw i didn't notice this behaviour when using static controls instead of painting text in WM_PAINT. MSDN says it's better resource-wise to paint, so i started. I also noticed it doesn't matter if i DrawText or FillRect with some color - this colorful rect is getting copied in the same bizarre way a text would. Please help.
case WM_PAINT: { HFONT czcionkabold=CreateFont(16, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, _T("Microsoft Sans Serif")); HDC hdc; PAINTSTRUCT ps; // ps.fErase - is this one doing anything at all? how do i use this? hdc=BeginPaint(hWar, &ps); SetBkMode(hdc, TRANSPARENT); SetTextColor(hdc, RGB(0,0,0)); defczcionka=SelectObject(hdc, czcionka); //global font to the entire app. with exceptions like below. RECT rct; rct.left=ps.rcPaint.left+5; rct.top=ps.rcPaint.top+5; rct.right=ps.rcPaint.right-10; rct.bottom=rct.top+20; DrawText(hdc, _T("Some header text"), -1, &rct, DT_LEFT|DT_TOP); rct.top=rct.top+25; rct.bottom=rct.top+20; DrawText(hdc, _T("Element 1:"), -1, &rct, DT_LEFT|DT_TOP); SelectObject(hdc, czcionkabold); //same as previous just bold rct.left=rct.left+60; DrawText(hdc, elsymbol, -1, &rct, DT_LEFT|DT_TOP); SelectObject(hdc, defczcionka); EndPaint(hWar, &ps); DeleteObject(czcionkabold); //local font gets deleted } return 0; break;
--edit-- I already figured out why disabled edit would flicker or contain random garbage, it was because it became a static element until enabled, and while processing WM_CTLCOLORSTATIC i was returning null brush and setting bkmode transparent. What i di -
Hello, I just started learning WinAPI a month ago. I have a dialog i created using custom class i register (so i am also in charge of WM_ERASEBKGND and WM_PAINT). Actually removing WM_ERASEBKGND part and selecting stock brush for my class doesn't change things. An Edit control placed on that dialog, which has ES_NUMBER style (greets me with that balloon tip when i try typing anything besides a number). Something odd is happening when this balloon tip pops out. All of my dialog's background text gets somehow copied and placed at an offset, close to and even under that edit box. If anyone could help me pinpointing what can i be doing wrong i would be very happy. Here is my wm_paint, which can be responsible for this behaviour, since... well, i have not much beside this. As you can see it's only drawing some text. Btw i didn't notice this behaviour when using static controls instead of painting text in WM_PAINT. MSDN says it's better resource-wise to paint, so i started. I also noticed it doesn't matter if i DrawText or FillRect with some color - this colorful rect is getting copied in the same bizarre way a text would. Please help.
case WM_PAINT: { HFONT czcionkabold=CreateFont(16, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, _T("Microsoft Sans Serif")); HDC hdc; PAINTSTRUCT ps; // ps.fErase - is this one doing anything at all? how do i use this? hdc=BeginPaint(hWar, &ps); SetBkMode(hdc, TRANSPARENT); SetTextColor(hdc, RGB(0,0,0)); defczcionka=SelectObject(hdc, czcionka); //global font to the entire app. with exceptions like below. RECT rct; rct.left=ps.rcPaint.left+5; rct.top=ps.rcPaint.top+5; rct.right=ps.rcPaint.right-10; rct.bottom=rct.top+20; DrawText(hdc, _T("Some header text"), -1, &rct, DT_LEFT|DT_TOP); rct.top=rct.top+25; rct.bottom=rct.top+20; DrawText(hdc, _T("Element 1:"), -1, &rct, DT_LEFT|DT_TOP); SelectObject(hdc, czcionkabold); //same as previous just bold rct.left=rct.left+60; DrawText(hdc, elsymbol, -1, &rct, DT_LEFT|DT_TOP); SelectObject(hdc, defczcionka); EndPaint(hWar, &ps); DeleteObject(czcionkabold); //local font gets deleted } return 0; break;
--edit-- I already figured out why disabled edit would flicker or contain random garbage, it was because it became a static element until enabled, and while processing WM_CTLCOLORSTATIC i was returning null brush and setting bkmode transparent. What i di