i have these function for get the string size:
SIZE GetStringSize(string text, HWND hdccontrol=GetForegroundWindow())
{
RECT textrect={0};
HDC txthdc=GetDC(hdccontrol);
DrawText (txthdc,text.c_str(),-1,&textrect,DT_CALCRECT);
ReleaseDC(hdccontrol,txthdc);
SIZE a={textrect.right-textrect.left, textrect.bottom-textrect.top};
return a;
}
the 1st string size isn't correct. then i get the correct one. so why i get, sometimes, the wrong size?
something to do with my HDC's font's or something. so i can't control it correctly :( can anyone advice me?