void MyDrawText(LPCALC lpCalc, HDC hdc, RECT *rc, Z80_info_t* zinf, ViewType type, const TCHAR *fmt, ...) { TCHAR *p; va_list argp; RECT r = *rc; mspf_size = 0; mspf_break = 999; if (calc_size == FALSE) { calc_size = TRUE; MyDrawText(lpCalc, hdc, rc, zinf, REGULAR, fmt, zinf->a1, zinf->a2, zinf->a3, zinf->a4); TCHAR szFilltext[1024]; memset(szFilltext, 'A', mspf_size); szFilltext[mspf_size] = '\0'; RECT hr; CopyRect(&hr, rc); DrawText(hdc, szFilltext, -1, &hr, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_MODIFYSTRING); mspf_break = (int) _tcslen(szFilltext); if (mspf_break < mspf_size) { mspf_break -= 3; } else { mspf_break++; } calc_size = FALSE; } mspf_size = 0; // Initialize arguments va_start(argp, fmt); for (p = (TCHAR *) fmt; *p && (mspf_size < mspf_break+3); p++) { if(*p != '%') { TCHAR szChar[2] = _T("x"); szChar[0] = *p; press_text(szChar, DBCOLOR_BASE); } else { switch(*++p) { case 'c': { //condition TCHAR *s = va_arg(argp, TCHAR *); press_text(s, DBCOLOR_CONDITION); break; } case 'h': { //offset int val = (int) va_arg(argp, INT_PTR); TCHAR szOffset[8]; if (val & 0x80) { _stprintf_s(szOffset, _T("%d"), val - 256); } else { _stprintf_s(szOffset, _T("+%d"), val); } press_text(szOffset, RGB(0, 0, 0)); break; } case 'd': { //number int val = (int) va_arg(argp, INT_PTR); TCHAR szAddr[16]; _stprintf_s(szAddr, _T("%d"), val); press_text(szAddr, RGB(0, 0, 0)); break; } case 'l': { TCHAR *s = va_arg(argp, TCHAR *); press_text(s, RGB(0, 0, 0)); break; } case 's': { TCHAR *s = va_arg(argp, TCHAR *); press_text(s, DBCOLOR_BASE); break; } case 'g': { waddr_t waddr = OffsetWaddr(lpCalc->cpu.mem_c, REGULAR, zinf->waddr, 2 + ((char) va_arg(argp, INT_PTR))); TCHAR *name; name = FindAddressLabel(lpCalc, waddr); if (name) { press_text(name, RGB(0, 0, 0)); } else { TCHAR szAddr[16]; _stprintf_s(szAddr, _T("$%04X"), waddr.addr); press_text(szAddr, RGB(0, 0, 0)); } break; } case 'a': //address { waddr_t waddr = OffsetWaddr(lpCalc->cpu.mem_c, REGULAR, zinf->waddr, 2); TCHAR *name; int val = (int) va_arg(argp, INT_PTR); name = FindAddressLabel(lpCalc, addr_to_waddr(lpCalc->cpu.mem_c, val)); if (name) { press_text(name, RGB(0, 0, 0)); } else { TCHAR szAddr[16]; _stprintf_s(szAddr, _T("$%04X"), val); press_text(szAddr, RGB(0, 0, 0)); } break; } case 'r': { TCHAR *szReg = va_arg(argp, TCHAR *); if (!_tcscmp(szReg, _T("(hl)"))) { press_text(_T("("), DBCOLOR_BASE); press_text(_T("hl"), DBCOLOR_HILIGHT); press_text(_T(")"), DBCOLOR_BASE); } else press_text(szReg, DBCOLOR_HILIGHT); break; } case 'x': { int val = (int) va_arg(argp, INT_PTR); TCHAR szAddr[16]; StringCbPrintf(szAddr, sizeof(szAddr), _T("$%02X"), val); press_text(szAddr, RGB(0, 0, 0)); break; } } } } va_end(argp); }
void OnSplashWndPaint( HWND hWnd ) { PAINTSTRUCT ps; HDC hdc = NULL; RECT rt; //#ifdef _UNICODE //#define MY_T2(x) L#x //#else //#define MY_T2(x) x //#endif //#define MY_T(x) MY_T2(x) LPCTSTR szProduct = TMEX_NAME; //LPCTSTR szVersion = MY_T( VERSIONPRODUCTVERSIONSTR ); //LPCTSTR szCopy1 = MY_T( COPYRIGHT1 ); //LPCTSTR szCopy2 = MY_T( COPYRIGHT2 ); USES_CONVERSION; LPCTSTR szVersion = A2CT( VERSIONPRODUCTVERSIONSTR ); LPCTSTR szCopy1 = A2CT( COPYRIGHT1 ); LPCTSTR szCopy2 = A2CT( COPYRIGHT2 ); hdc = BeginPaint(hWnd, &ps); ::GetClientRect(hWnd, &rt); int width = rt.right - rt.left; // int height = rt.bottom - rt.top; int charWidth = width/lstrlen(szProduct); int MainTextHeight = iSplashInternalHeight*iTextHeightName/100; int y = (iSplashHeight - iSplashInternalHeight)/2; int TextWidth = 0; do { charWidth--; HFONT hf = MakeFont( charWidth, MainTextHeight ); HFONT hf1 = (HFONT)::SelectObject(hdc, hf); SIZE sz; GetTextExtentPoint( hdc, szProduct, lstrlen(szProduct), &sz ); TextWidth = sz.cx; ::SelectObject(hdc, hf1); ::DeleteObject( hf ); } while( TextWidth > iSplashInternalWidth && charWidth > 1 ); HPEN hPen = CreatePen( PS_SOLID, 1, crDarkBorder ); //GetSysColor(COLOR_WINDOWFRAME) ); HPEN hPen1 = (HPEN) ::SelectObject(hdc, hPen); HBRUSH hBrush = CreateSolidBrush( crBackground ); ::Rectangle( hdc, rt.left, rt.top, rt.right, rt.bottom ); rt.left++, rt.top++, rt.right--, rt.bottom--; // Inflate rectangle by 1 pixel ::FillRect( hdc, &rt, hBrush ); ::DeleteObject( hBrush ); ::SelectObject(hdc, hPen1); ::DeleteObject(hPen); int h; h = MainTextHeight; MyDrawText( hdc, y, szProduct, charWidth, h, width, crText, crTextBorder ); y += h; h = iSplashInternalHeight*iTextHeightVersion/100; MyDrawText( hdc, y, szVersion, charWidth*iCharWidthVersion/100, h, width, crText, crTextBorder ); y += h; h = iSplashInternalHeight*iTextHeightCopy1/100; MyDrawText( hdc, y, szCopy1, charWidth*iCharWidthCopy1/100, h, width, crText, crDarkBorder ); y += h; h = iSplashInternalHeight*iTextHeightCopy2/100; MyDrawText( hdc, y, szCopy2, charWidth*iCharWidthCopy2/100, h, width, crText, crDarkBorder ); y += h; EndPaint(hWnd, &ps); }