36 ATLASSERT(HDestDC != NULL);
39 HBRUSH HOldBrush =
static_cast<HBRUSH
>(
40 SelectObject(HDestDC, GetStockObject(HOLLOW_BRUSH))
47 RDest.left, RDest.top,
48 RDest.right, RDest.bottom
52 SelectObject(HDestDC, HOldBrush);
72 _itot_s(value, retval.GetBufferSetLength(max_digits + 1), max_digits + 1, 10);
73 retval.ReleaseBuffer();
75 for (
int i = 0; i < (max_digits + 1); i++)
77 if (retval.GetAt(i) == 0)
79 retval = retval.Left(i);
102 retval.Format(_T(
"%.*g"), precision, number);
123 else if (value < 0.0)
139 DWORD error = GetLastError();
143 FORMAT_MESSAGE_ALLOCATE_BUFFER |
144 FORMAT_MESSAGE_FROM_SYSTEM |
145 FORMAT_MESSAGE_IGNORE_INSERTS,
148 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
156 MessageBox( NULL, (LPCTSTR)lpMsgBuf, _T(
"Error"), MB_OK | MB_ICONINFORMATION );
158 LocalFree( lpMsgBuf );
176 GetTextMetrics(dc, &tm);
178 int char_height = tm.tmHeight + tm.tmExternalLeading;
180 return (char_height);
203 rect.top = rect.left = 0;
206 rect.bottom = char_height;
209 UINT format = DT_WORDBREAK | DT_LEFT | DT_CALCRECT;
211 format |= DT_EDITCONTROL;
213 int box_height = ::DrawText(dc, text, 1, &rect, format);
215 if (char_height != 0)
216 lines = (int)ceil(((
float)box_height)/((float)char_height));
237 HDC dc = ::CreateCompatibleDC(NULL);
241 HFONT old_font = (HFONT)::SelectObject(dc, font);
244 if (::GetTextExtentPoint32(dc, str, str.GetLength(), &sz) != 0)
247 ::SelectObject(dc, old_font);
266 TCHAR TRUEpath[MAX_PATH];
268 LPCTSTR lpPath = NULL;
269 LPCTSTR lpFileName = FullFileName;
270 LPCTSTR lpExtension = NULL;
271 DWORD nBufferLength = MAX_PATH;
272 LPTSTR lpBuffer = &TRUEpath[0];
273 LPTSTR *lpFilePart = NULL;
275 DWORD chars = SearchPath(lpPath,lpFileName,lpExtension,nBufferLength,
276 lpBuffer,lpFilePart);
299 HINSTANCE hInstance = _Module.GetResourceInstance();
300 HRSRC hResource = ::FindResource(hInstance, MAKEINTRESOURCE(nDlgID), RT_DLGINIT);
303 if (hResource == NULL)
306 HGLOBAL hGlobal = ::LoadResource(hInstance, hResource);
309 LPVOID lpResource = ::LockResource(hGlobal);
310 if (lpResource == NULL)
313 BOOL bSuccess = TRUE;
315 UNALIGNED WORD* lpnRes = (WORD*)lpResource;
316 while (bSuccess && *lpnRes != 0)
318 WORD nIDC = *lpnRes++;
319 WORD nMsg = *lpnRes++;
320 DWORD dwLen = *((UNALIGNED DWORD*&)lpnRes)++;
323 #define WIN16_LB_ADDSTRING 0x0401 324 #define WIN16_CB_ADDSTRING 0x0403 325 #define AFX_CB_ADDSTRING 0x1234 328 if (nMsg == AFX_CB_ADDSTRING)
329 nMsg = CBEM_INSERTITEM;
330 else if (nMsg == WIN16_LB_ADDSTRING)
332 else if (nMsg == WIN16_CB_ADDSTRING)
335 ATLASSERT(nMsg == LB_ADDSTRING || nMsg == CB_ADDSTRING || nMsg == CBEM_INSERTITEM);
338 if (nMsg == CBEM_INSERTITEM)
341 item.mask = CBEIF_TEXT;
343 item.pszText = CA2T(LPSTR(lpnRes)).m_szBuffer;
345 if (::SendDlgItemMessage(DlgHwnd, nIDC, nMsg, 0, (LPARAM) &item) == -1)
348 else if (nMsg == LB_ADDSTRING || nMsg == CB_ADDSTRING)
352 int result = ::SendDlgItemMessage(DlgHwnd, nIDC, nMsg, 0, (LPARAM)CA2T(LPSTR(lpnRes)).m_szBuffer);
358 lpnRes = (WORD*)((LPBYTE)lpnRes + (UINT)dwLen);
CString Double_To_String(double number, int precision)
Convert a double to a CString, with a given number of significant digits.
int GetTextLineCount(HDC dc, CString text, int width, BOOL IsEditControl)
Returns the number of lines of text required to fit a string in a given width.
BOOL FilePresent(LPCTSTR FullFileName)
Tests for the presence of a file using SearchPath.
int GetTextLength(CString str, HFONT font)
Measure the length, in pixels, of a string using a given font.
BOOL OutlineRect(HDC HDestDC, const RECT &RDest)
Draw a rectangular outline with the current pen.
void DlgComboInit(int nDlgID, HWND DlgHwnd)
Load combo boxes with strings stored in a resources file.
int GetCharHeight(HDC dc)
Returns the height of a standard test string, in pixels.
double Sgn(double value)
Test the sign of a double.
void GetLastErrorString()
Show a Message Box containing human-friendly information about the last failed system API call...
CString Int_To_String(int value, int max_digits)
Convert a multi-digit integer into a CString.