2007. szeptember 13., csütörtök

Painting the Form Menu bar


Problem/Question/Abstract:

When i uses programs like the game freecell that comes with windows 9x i see that there is a text in the menu bar tht tells me how many cards left me.

How can i make something like that in my programs ?

Answer:

Well, First of all we need to put a main menu component on our form.
Now set the OwnerDraw property to true.

If you have an item that you wish to paint by yourself, now is the time to create it and to make the OnDrawItem.
In this line you put also this line:

{... }
ACanvas.TextOut(1, ARect.Top + 1, 'I''m in the MainMenuDrawbar');
{... }

Note, If you need to use a changed variable you can do it from another function and ll you need to do afther the change is to call the API function DrawMenuBar.

If you are using Delphi 2,3 Use the Messages WM_MESUREITEM and the message WM_DRAWITEM to make this effect.

Nincsenek megjegyzések:

Megjegyzés küldése