Click here to Skip to main content
16,010,553 members
Home / Discussions / Mobile
   

Mobile

 
GeneralRe: My program is not work in Pocket PC 2003! Pin
João Paulo Figueira4-Sep-03 1:46
professionalJoão Paulo Figueira4-Sep-03 1:46 
GeneralRe: My program is not work in Pocket PC 2003! Pin
David12154-Sep-03 15:32
David12154-Sep-03 15:32 
GeneralRe: My program is not work in Pocket PC 2003! Pin
Jonas Larsson4-Sep-03 20:34
Jonas Larsson4-Sep-03 20:34 
QuestionScriptinghost for NetCF ???? Pin
carsonB3-Sep-03 2:53
carsonB3-Sep-03 2:53 
GeneralDatabase connection with pocket pc emulator Pin
shoukat rasool1-Sep-03 11:33
shoukat rasool1-Sep-03 11:33 
GeneralPhone call (TAPI) with PPC Pin
Member 55831131-Aug-03 13:01
Member 55831131-Aug-03 13:01 
GeneralRe: Phone call (TAPI) with PPC Pin
Member 5583112-Sep-03 6:42
Member 5583112-Sep-03 6:42 
Generalprecalculating button control size issue Pin
rodent¹28-Aug-03 4:43
rodent¹28-Aug-03 4:43 
using ppc2k2 with just wince api, i'm trying to determine the size required by a button control based on it's text. my understanding is that by default 8pt tahoma bold font is used for the button text.

in order to determine the minimum button size, my plan is to use DrawText() to return the RECT structure of the text based upon the 8pt tahoma bold font in the DC.

however, when i use the following code, i have to add padding to the RECT in order for the button to not be too small.

what am i not understanding about correctly measuring the size of text in the DC used by the button control?

thanks...
<br />
HWND hChildWnd;			// handle to push button<br />
RECT cliRect, txtRect;		// RECT size of main window client area & btn text<br />
HDC hdc;			// handle to client DC<br />
HFONT hBtnFnt, hOldFnt;		// handle to fonts<br />
LOGFONT lf;			// pointer to LOGFONT structure<br />
<br />
// get size of main window's client area<br />
GetClientRect(hWnd, &cliRect);<br />
<br />
// zero structures<br />
memset(&txtRect, 0, sizeof(RECT));<br />
memset(&lf, 0, sizeof(LOGFONT));<br />
<br />
// get client area DC<br />
hdc = GetDC(hWnd);<br />
<br />
// set up LOGFONT for an 8 pt bold Tahoma font, the font used<br />
// for the button text<br />
lf.lfHeight = -8 * GetDeviceCaps(hdc, LOGPIXELSY)/72;<br />
lf.lfWeight = FW_BOLD;<br />
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;<br />
_tcscpy(lf.lfFaceName, _T("Tahoma"));<br />
<br />
// create new font based on LOGFONT member data<br />
hBtnFnt = CreateFontIndirect(&lf);<br />
<br />
// select new font into DC, save old font, and calculate button text<br />
// and return it in RECT structure.<br />
hOldFnt = (HFONT)SelectObject(hdc, hBtnFnt);<br />
DrawText(hdc, szBtnTxt, -1, &txtRect, DT_CALCRECT);<br />
<br />
// select old font back into DC, delete new font and release DC<br />
SelectObject(hdc, hOldFnt);<br />
DeleteObject(hBtnFnt);<br />
ReleaseDC(hWnd, hdc);<br />
<br />
// add padding to text size<br />
// SHOULDN'T HAVE TO ADD THIS MUCH PADDING IF SIZING IS CORRECT<br />
// FIND OUT WHY I DONT UNDERSTAND HOW TO GET CORRECT TEXT SIZE<br />
txtRect.bottom += 6;<br />
txtRect.right += 30;<br />
	<br />
// create a centered pushbutton<br />
hChildWnd = CreateWindowEx(NULL, _T("BUTTON"), szBtnTxt,<br />
			WS_VISIBLE | WS_CHILD | BS_CENTER | BS_VCENTER | BS_PUSHBUTTON,<br />
			(cliRect.right/2 - txtRect.right/2) , cliRect.bottom - 25,<br />
			txtRect.right, txtRect.bottom,<br />
			hWnd, (HMENU)IDC_PROPBTN, g_hInst, NULL);

GeneralRe: precalculating button control size issue Pin
João Paulo Figueira28-Aug-03 6:07
professionalJoão Paulo Figueira28-Aug-03 6:07 
GeneralRe: precalculating button control size issue Pin
rodent¹28-Aug-03 6:19
rodent¹28-Aug-03 6:19 
GeneralRe: precalculating button control size issue Pin
rodent¹28-Aug-03 9:10
rodent¹28-Aug-03 9:10 
GeneralRe: precalculating button control size issue Pin
João Paulo Figueira28-Aug-03 12:03
professionalJoão Paulo Figueira28-Aug-03 12:03 
GeneralRe: precalculating button control size issue Pin
rodent¹28-Aug-03 12:43
rodent¹28-Aug-03 12:43 
GenerallfFaceName compiler error Pin
rodent¹27-Aug-03 14:42
rodent¹27-Aug-03 14:42 
GeneralRe: lfFaceName compiler error Pin
Daniel Strigl27-Aug-03 20:24
Daniel Strigl27-Aug-03 20:24 
GeneralRe: lfFaceName compiler error Pin
rodent¹28-Aug-03 2:26
rodent¹28-Aug-03 2:26 
GeneralRe: lfFaceName compiler error Pin
Daniel Strigl28-Aug-03 2:34
Daniel Strigl28-Aug-03 2:34 
GeneralRe: lfFaceName compiler error Pin
rodent¹28-Aug-03 3:36
rodent¹28-Aug-03 3:36 
GeneralReading and Writing Files Pin
Mahesh Varma27-Aug-03 0:45
Mahesh Varma27-Aug-03 0:45 
QuestionSTL ??? Pin
YRassul25-Aug-03 17:01
YRassul25-Aug-03 17:01 
AnswerRe: STL ??? Pin
Daniel Strigl25-Aug-03 20:09
Daniel Strigl25-Aug-03 20:09 
GeneralSucks II Pin
rodent¹25-Aug-03 16:04
rodent¹25-Aug-03 16:04 
GeneralIt Just Sucks! Pin
#realJSOP25-Aug-03 6:18
professional#realJSOP25-Aug-03 6:18 
GeneralRe: It Just Sucks! Pin
João Paulo Figueira25-Aug-03 6:45
professionalJoão Paulo Figueira25-Aug-03 6:45 
GeneralRe: It Just Sucks! Pin
Jonas Larsson25-Aug-03 7:13
Jonas Larsson25-Aug-03 7:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.