Board index » cppbuilder » Owner Draw menus

Owner Draw menus


2004-09-23 05:13:27 PM
cppbuilder105
Is their a way of changing the font and size of menu items, We require the font being a lot larger than the standard menu font to allow for touch screen complance, using builder you don't seem to be able to change these.
With thanks
 
 

Re:Owner Draw menus

Quote
Is their a way of changing the font and size of menu items, We
require the font being a lot larger than the standard menu font to
allow for touch screen complance, using builder you don't seem to be
able to change these.
Have a look at TMenu::OwnerDraw property and
TMenuItem::OnAdvancedDrawItem event. Just to give an idea, it could
look like this:
void __fastcall TForm1::MenuAdvancedDrawItem(TObject *Sender,
TCanvas *ACanvas, TRect &ARect, TOwnerDrawState State)
{
ACanvas->Brush->Color = RGB(random(256), random(256),
random(256));
ACanvas->FillRect(ARect);
ACanvas->Font->Color = RGB(random(256), random(256), random(256));
ACanvas->Font->Style = TFontStyles() << fsBold;
ACanvas->TextRect(ARect, 5, 0, "HELLO!");
}
void __fastcall TForm1::MenuMeasureItem(TObject *Sender, TCanvas
*ACanvas,
int &Width, int &Height)
{
Width = 100;
}
HTH,
Steve.
 

Re:Owner Draw menus

"Steve Aletto" < XXXX@XXXXX.COM >wrote:
Quote

[...] it could look like this:
Have you been able to resize the the TMainMenu as it lives in
the non-client area? I've been able to draw the items using
the font, color, size of my choice but windows clips it.
~ JD
 

{smallsort}

Re:Owner Draw menus

"Graham" < XXXX@XXXXX.COM >wrote:
Quote

Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard return at the
end of each line.
Quote
Is their a way of changing the font and size of menu items, We require the font being a lot larger than the standard menu font to allow for touch screen complance, using builder you don't seem to be able to change these.
You have to simulate the TMainMenu to alter it's size because
windows will clip the drawing performed in the non-client area
of the form which is where the TMainMenu lives.
You do this by using a TToolBar with TToolButton that have
their Style property set to tbsDropDown. Then for each of the
main menu items, create a TPopupMenu and assign it to the
TToolButton. When finished, it will look and behave exactly
like a TMainMenu.
Then all you have to do is incorporate Steve's sample code to
custom draw the menu items.
~ JD
 

Re:Owner Draw menus

"Graham" < XXXX@XXXXX.COM >wrote in message
Quote
Is their a way of changing the font and size of menu items
Have you looked at the global TScreen::MenuFont property yet?
Gambit