Board index » cppbuilder » Predefined TBitmap compatible bitmaps for basic colors for TMenItem entries?
Randall Parker
![]() CBuilder Developer |
Randall Parker
![]() CBuilder Developer |
Predefined TBitmap compatible bitmaps for basic colors for TMenItem entries?2003-10-04 11:13:10 AM cppbuilder114 Are there any bit maps in BCB v6 that are compatible with (the right size) the VCL class TBitMap that have been premade and are somewhere part of BCB v6? Or, better yet, is there some way on-the-fly to make a bitmap that will be a solid TColor color that will be the right size to use when instantiating a TBitmap? I want to take a list of lines that the user has drawn on a graph, loop thru and build up a list of TMenuItem objects that have the right TColor associated with them so I can show a list of colors and line names in a submenu of a context pop-up menu. |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2003-10-04 03:06:27 PM
Re:Predefined TBitmap compatible bitmaps for basic colors for TMenItem entries?
"Randall Parker" < XXXX@XXXXX.COM >wrote in message
QuoteI want to take a list of lines that the user has drawn on a graph, line directly onto the menu's Canvas when needed? Gambit |
Randall Parker
![]() CBuilder Developer |
2003-10-05 03:18:33 AM
Re:Predefined TBitmap compatible bitmaps for basic colors for TMenItem entries?
Well, I don't want a line. I want a square box. Look at the way the
color-choosing pop-down lists show their rows. I want to do that but in a menu item. Also, if I used this DrawItem event how would I position the text to the right of the color box? Normally the text is specified with the Caption property. If I just go drawing on the TMenuItem canvas the TMenuItem isn't going to know to shift the Caption over to make room for the color. This will create alignment problems. I think what I need is a method that will take a TColor and create and return a 16x16 TBitmap that I can then assign to the TMenuItem::Bitmap. So I need a way to specify the size of and fill in a bitmap in memory. TMenuItem* MyMenuItem = new TMenuItem(); MyMenuItem->Caption = "Some Investment"; TBitmap* MyBitMap = new TBitmap(); TColor MyTColor = clMoneyGreen; // Then somehow create a 16x16 area filled in with MyTColor. // ???????????????????? // Use one of the LoadFromXXX to put that memory-created bitmap // into the MyBitMap object. // ???????????????????? // Then finish: MyMenuItem->Bitmap = MyBitMap; So how to create a bitmap memory area in memory? Remy Lebeau (TeamB) wrote: Quote"Randall Parker" < XXXX@XXXXX.COM >wrote in message {smallsort} |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2003-10-05 06:19:12 AM
Re:Predefined TBitmap compatible bitmaps for basic colors for TMenItem entries?
"Randall Parker" < XXXX@XXXXX.COM >wrote in
message news: XXXX@XXXXX.COM ... QuoteWell, I don't want a line. I want a square box. however you want. QuoteAlso, if I used this DrawItem event how would I position TextRect()). Both allow you to specify the offset where you want the text to be drawn. Simply draw the box first and then specify on offset that is at least the width of the box, maybe a few extra pixels for spacing. QuoteNormally the text is specified with the Caption property. If I just necessarily alignment. You can draw the text whereever you want. If you want to support aligning the Caption relative to the color box, then simply adjust the offset you use for TextOut/Rect(). The OnDrawItem event provides the rectangle for the MenuItem, simply adjust the Left member before calling TextOut/Rect(). The Sender parameter is a pointer to the TMenuItem so you can grab the current Caption. QuoteI think what I need is a method that will take a TColor and create effient without needing to use extra memory. Specifying a Bitmap just accomplished the same thing that I have suggested here, except that the MenuItem is handling the custom-drawing for you instead of you doing it manually, but the end effect is still the same - the MenuItem custom-draws the bitmap, then shifts the Caption and draws it alongside the bitmap. But then you're instilling the extra memory for every single bitmap you allocate, whereas using the OnDrawItem event is dynamic and does not use extra memory, especially for something is simple as a solid box of a single color. QuoteSo I need a way to specify the size of and fill in a bitmap in memory. |