C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[23744] 메뉴의 크기 변경... 도와주세용~~
처음하는 빌더~ [sy1024] 1119 읽음    2003-01-18 16:10
안녕하세요.. 제가 요즘 터치 스크린을 위한 프로그램을 하는데요..

메뉴가 넘넘 작아서 터치를 하기가 불편하네요..

메뉴의 크기나 폰트의 크기를 변경할 수 없을까요?

검색하다보니 아래와 같은 소스가 있어 사용해 보았는데 크기나 폰트가 변함이 없네요..

BEGIN_MESSAGE_MAP은 헤더파일 class TMainForm : public TForm{} 안에 선언하는 것은 맞는지요..

혹시 메뉴의 크기나 폰트를 변경해보신 고수님들은 답변 부탁드립니다..


//in header...

void __fastcall WMDraw(TMessage &Msg);
void __fastcall WMMeasure(TMessage &Msg);

BEGIN_MESSAGE_MAP
  MESSAGE_HANDLER(WM_DRAWITEM, TMessage, WMDraw)
  MESSAGE_HANDLER(WM_MEASUREITEM, TMessage, WMMeasure)
END_MESSAGE_MAP(TForm)

//in source...

__fastcall TMainForm::TMainForm(TComponent *Owner)
    : TForm(Owner)
{
    TMenuItemInfo ItemInfo;
    ItemInfo.cbSize = sizeof(TMenuItemInfo);
    ItemInfo.fMask = MIIM_TYPE;

    for(int index = 0; index<Menu->Items->Count; index++)
    {
        GetMenuItemInfo(Menu->Handle, index, true, &ItemInfo);
        ItemInfo.fType = ItemInfo.fType|MFT_OWNERDRAW;
        ItemInfo.dwTypeData = Menu->Items->Items[index]->Caption.c_str();
        ItemInfo.cch = Menu->Items->Items[index]->Caption.Length()+1;

        SetMenuItemInfo(Menu->Handle, index, true, &ItemInfo);

        for(int index2=0; index2<Menu->Items->Items[index]->Count; index2++)
        {
            GetMenuItemInfo(Menu->Items->Items[index]->Handle, index2, true, &ItemInfo);
            ItemInfo.fType = ItemInfo.fType|MFT_OWNERDRAW;
            ItemInfo.dwTypeData = Menu->Items->Items[index]->Items[index2]->Caption.c_str();
            ItemInfo.cch = Menu->Items->Items[index]->Items[index2]->Caption.Length();

            SetMenuItemInfo(Menu->Items->Items[index]->Handle, index2, true, &ItemInfo);
        }
    }
}
//---------------------------------------------------------------------------

/*
void __fastcall TMainForm::Test1Measure(TMessage &Msg)
{
    LPMEASUREITEMSTRUCT lpmis = (MEASUREITEMSTRUCT*)Msg.LParam;
//void __fastcall Test1MeasureItem(TObject *Sender, TCanvas *ACanvas,
//          int &Width, int &Height);
    int Index = lpmis->itemID;
    char text[100];
    GetMenuString(Menu->Handle, Index, text, 100, MF_BYCOMMAND);

    TFont *MenuFont = new TFont();
    MenuFont->Name = "Tahoma";
    MenuFont->Size = 20;
    MenuFont->Style = TFontStyles()<<fsBold;

    SIZE S;
    HDC HMenuDC = GetDC(0);
    HFONT OldFont = SelectObject(HMenuDC, MenuFont->Handle);

    // get te appropriate "extents"
    GetTextExtentPoint32(HMenuDC, text, strlen(text), &S);
    ReleaseDC(0, HMenuDC);

    // set the sizes appropriately
    lpmis->itemWidth = S.cx;
    lpmis->itemHeight = S.cy;

    SelectObject(HMenuDC, OldFont);
    Msg.Result = true;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Test1Draw(TMessage &Msg)
{
    LPDRAWITEMSTRUCT lpdis = (DRAWITEMSTRUCT*)Msg.LParam;
//void __fastcall Test1DrawItem(TObject *Sender, TCanvas *ACanvas,
//          TRect &ARect, bool Selected);
    if(lpdis->CtlType != ODT_MENU)
    {
        TForm::Dispatch(&Msg);
        return;
    }

    int Index = lpdis->itemID;
    UINT ItemState = lpdis->itemState;
    HDC HMenuDC = lpdis->hDC;
    RECT R = lpdis->rcItem;

    // get he menu caption from the Index
    char text[100];
    GetMenuString(lpdis->hwndItem, Index, text, 100, MF_BYCOMMAND);

    // this is new font
    //////////////////////
    TFont *MenuFont = new TFont();
    MenuFont->Name = "Tahoma";
    MenuFont->Size = 200;
    MenuFont->Style = TFontStyles()<<fsBold;
    //////////////////////

    TBrush *MenuBrush = new TBrush();

    if(ItemState & ODS_SELECTED)
    {
        MenuBrush->Color = clHighlight;
        ::SetTextColor(HMenuDC, ColorToRGB(clHighlightText));
    }

    else
    {
        MenuBrush->Color = clBtnFace;
        ::SetTextColor(HMenuDC, ColorToRGB(clWindowText));
    }

    HFONT OldFont = SelectObject(HMenuDC, MenuFont->Handle);
    ::SetBkMode(HMenuDC, TRANSPARENT);
    ::FillRect(HMenuDC, &R, MenuBrush->Handle);
    ::OffsetRect(&R, 2, 0);
    ::DrawText(HMenuDC, text, strlen(text), &R, DT_LEFT|DT_VCENTER|DT_SINGLELINE);

    SelectObject(HMenuDC, OldFont);
    delete MenuFont;
    delete MenuBrush;
    Msg.Result = true;
}
//---------------------------------------------------------------------------
*/

+ -

관련 글 리스트
23744 메뉴의 크기 변경... 도와주세용~~ 처음하는 빌더~ 1119 2003/01/18
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.