/*! オーナードロー・サイズ計測 @param[in] hWnd 親ウインドウハンドル @param[in] pstMeasureItem サイズ情報 @return HRESULT 終了状態コード */ VOID AaItemsMeasureItem( HWND hWnd, LPMEASUREITEMSTRUCT pstMeasureItem ) { HDC hDC; INT rdLength, rdHeight; LPSTR pcConts; RECT stRect; // 項目の文字列取得 pcConts = AacAsciiArtGet( pstMeasureItem->itemID ); if( !pcConts ) return; rdLength = strlen( pcConts ); ListBox_GetItemRect( ghItemsWnd, pstMeasureItem->itemID, &stRect ); hDC = GetDC( ghItemsWnd ); DrawTextExA( hDC, pcConts, rdLength, &stRect, DT_LEFT | DT_EDITCONTROL | DT_NOPREFIX | DT_CALCRECT ); ReleaseDC( ghItemsWnd, hDC ); pstMeasureItem->itemHeight = (stRect.bottom - stRect.top); if( 256 <= pstMeasureItem->itemHeight ) pstMeasureItem->itemHeight = 255; free( pcConts ); return; }
void CFilePreviewCtrl::DrawTextLine(HDC hdc, DWORD nLineNo) { CRect rcClient; GetClientRect(&rcClient); DWORD dwOffset = 0; DWORD dwLength = 0; { CAutoLock lock(&m_csLock); dwOffset = m_aTextLines[nLineNo]; if(nLineNo==m_uNumLines-1) dwLength = (DWORD)m_fm.GetSize() - dwOffset; else dwLength = m_aTextLines[nLineNo+1]-dwOffset-1; } if(dwLength==0) return; //get data from our file mapping LPBYTE ptr = m_fm.CreateView(dwOffset, dwLength); //draw this line to the screen CRect rcText; rcText.left = -(int)(m_nHScrollPos * m_xChar); rcText.top = (nLineNo - m_nVScrollPos) * m_yChar; rcText.right = rcClient.right; rcText.bottom = rcText.top + m_yChar; DRAWTEXTPARAMS params; memset(¶ms, 0, sizeof(DRAWTEXTPARAMS)); params.cbSize = sizeof(DRAWTEXTPARAMS); params.iTabLength = m_xChar*m_cchTabLength; DWORD dwFlags = DT_LEFT|DT_TOP|DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS; if(m_TextEncoding==ENC_UTF8) { // Decode line strconv_t strconv; LPCWSTR szLine = strconv.utf82w((char*)ptr, dwLength-1); DrawTextExW(hdc, (LPWSTR)szLine, -1, &rcText, dwFlags, ¶ms); } else if(m_TextEncoding==ENC_UTF16_LE) { DrawTextExW(hdc, (WCHAR*)ptr, dwLength/2-1, &rcText, dwFlags, ¶ms); } else if(m_TextEncoding==ENC_UTF16_BE) { // Decode line strconv_t strconv; LPCWSTR szLine = strconv.w2w_be((WCHAR*)ptr, dwLength/2-1); DrawTextExW(hdc, (LPWSTR)szLine, -1, &rcText, dwFlags, ¶ms); } else // ASCII { DrawTextExA(hdc, (char*)ptr, dwLength-1, &rcText, dwFlags, ¶ms); } }
/* MAKE_EXPORT DrawTextExW_new=DrawTextExW */ int WINAPI DrawTextExW_new(HDC hdc, LPWSTR lpchTextW, int cchText, LPRECT lprc, UINT dwDTFormat, LPDRAWTEXTPARAMS lpDTParams) { int result; ALLOC_WtoA(lpchText); result = DrawTextExA(hdc, lpchTextA, cchText, lprc, dwDTFormat, lpDTParams); if(!result) return 0; STACK_AtoW(lpchTextA, lpchTextW); return result; }