[ ページコメント(0) ] [ トラックバック(0) ]
Counter: 1128,
today: 2,
yesterday: 1
縦書きコンボボックス
縦書きといっても
通常のコンボボックスに縦書き描画しているだけなので
1文字目くらいしか表示されないと思います。
まずCTategakiComboというクラスを作成し、
コンボボックスに割り当てます。
CTategakiCombo m_combo;
次にOnInitDialog等で縦書きフォントを割り当てます。
m_combofont.CreateFont( 12, 0, 2700, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET | SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_LH_ANGLES, DEFAULT_QUALITY, DEFAULT_PITCH, "@MS 明朝" ); m_combo.SetFont( &m_combofont );
あとは正しく縦書きフォントを表示させるため、
CTategakiComboのDrawItemを継承し実装します。
void CTategakiCombo::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
char text[256];
CRect rect;
CString str;
COLORREF oldcolor;
int oldmode;
LOGFONT logfont;
CFont *font;
if( lpDrawItemStruct->itemID != -1 )
{
if( font = GetFont() )
{
if( font->GetLogFont( &logfont ) )
{
oldmode = SetBkMode( lpDrawItemStruct->hDC, TRANSPARENT );
if( lpDrawItemStruct->itemState & ODS_FOCUS )
{
oldcolor = SetTextColor( lpDrawItemStruct->hDC, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
FillRect( lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, GetSysColorBrush( COLOR_HIGHLIGHT ) );
}
else
{
oldcolor = SetTextColor( lpDrawItemStruct->hDC, GetSysColor( COLOR_WINDOWTEXT ) );
FillRect( lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, GetSysColorBrush( COLOR_WINDOW ) );
}
GetLBText( lpDrawItemStruct->itemID, text );
TextOut( lpDrawItemStruct->hDC,
lpDrawItemStruct->rcItem.left + 5 + logfont.lfHeight,
lpDrawItemStruct->rcItem.top + 5, text, (int)strlen(text) );
SetTextColor( lpDrawItemStruct->hDC, oldcolor );
SetBkMode( lpDrawItemStruct->hDC, oldmode );
if( lpDrawItemStruct->itemState & ODS_FOCUS )
{
DrawFocusRect( lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem );
}
}
}
}
}
ちなみにコンボボックスのプロパティで
オーナードローを有効にしておいて下さい。
これで完成です。
付箋の編集