Delphi's ribbon glitchy images - delphi

I am trying to use the ribbon control in delphi, but I'm having problems with the icons. I have one ImageList (16x16 - apparently higher resolutions are bad - the ribbon malfunctions) and I want to use it for ribbon icons. But this problem keeps happenning:
When I have the "Large icons" checkbox unchecked, the small buttons (Action2) are fine. But the bigger one is not.
On the other hand, when I tick the checkbox, this happens:
How do I setup the ribbon correctly? This is crazy :/

So, well, I figured it out. In order to use both image types, one has to have two separate ImageLists - each one holding different icons dimensions. The ActionManager has more fields for Images, which I didn't notice first - Images, DisabledImages, LargeImages(that's it!) and LargeDisabledImages. So in order to have the full functionality of the Ribbon, you have to keep 4 ImageLists.
(I am keeping the answer here for future reference)

Related

Can I enlarge the menu font size in Delphi 2?

Everything I've found says I can't do this with Delphi 2's TMainMenu but if somebody here has managed it somehow, I'd really like to know the trick. I found code that changes the System menu font size but none that confines the change to only the application. Anyone here know how to do this or do I have to just accept Delphi 2's tiny menu font size that appears on today's large screen monitors? (Moving the app to an upgraded Delphi is not the answer I need ;-)
The only way to achieve per application custom menu fonts is with an owner drawn menu. Delphi 2 does not support owner drawn menu items directly in the VCL properties of a TMainMenu component. This support was introduced only in Delphi 4.
You could still implement an owner drawn menu, but it would involve implementing them using standard Windows API techniques, and handling the required messages on the forms which own the menus involved. It is not especially difficult but not as straightforward as the event based implementation available in Delphi 4 and later.
You can still use a TMainMenu to define your menus but in your application you would then need to programmatically set the owner draw flag on the menu items and handle the resulting messages appropriately. Doing this, you will need to handle all aspects of drawing the menu - you cannot simply set/change the font and leave the system to draw the menu items. You may also need to provide additional handling for any keyboard shortcuts you have set up.
If this is a viable approach then information on implementing owner drawn menus at the API level can be found here.

Picturebox controls and memory

I am planning on using many pictureboxes as controls instead of e.g. buttons, mostly because the controls need to look like icons and not buttons. Would pictureboxes kill memory too much when compared with buttons? Is there a way to make a button appear as an icon instead of a picturebox, that is, can a button be made to look like a .png small icon image file instead of a button with no border?
Lastly, there will be several tabs available to the user via a tabcontrol, each of which has maybe 10-15 pictureboxes that can be clicked on. Is there a shortcut for addhandler if many pictureboxes are used within a tab as a replacement for a buttonbar (no longer supported in VB.NET 2010)?
The button control SUPPORTS pictures already!
Most likely too (more importantly!) the buttonis LIGHTWEIGHT and will consume less memory than pictureboxes
Use the Property sheet to assign the image(s)
You can assign a different image for the button up and down states too!!

How to make my Deskband's (Taskbar Toolbar) Form transparent

I'm working on a Windows Deskband in Delphi XE2 for Windows XP, Vista and 7 (Win32 and Win64)...
I've implemented all the necessary interfaces (ITrayDeskBand, IDeskBandInfo, IDeskBand2, IDeskBand) in my code, and that all works exactly as it should (there are no warnings on Vista/7 complaining about compatibility as others have experienced).
The problem I have is that my Deskband Form appears with a non-transparent band. Also, only certain Controls are displaying (in this case TBitBtn and TImage containing a PNG). I need it to display TEdit and TComboBox objects properly too, but they won't appear at all.
I've tried enabling GlassFrame and SheetOfGlass properties on my Form, but this doesn't help one bit.
Furthermore, the Form itself is exceeding the top boundary of the Taskbar, meaning you cannot (for example) resize the Taskbar if the cursor is in-line with the top of the Taskbar immediately above my Deskband.
I believe there is something Delphi's VCL TForm type is doing behind the scenes which renders the TForm type incompatible as a Deskband container... but this is just a suspicion.
Here's a screenshot illustrating the various problems:
As you can see (above), the Deskband's Form is pale (instead of Transparent), it overlaps the top of the Taskbar (preventing resizing and Autohide triggering when the Taskbar is "hidden")
Any ideas?
UPDATE 1
Okay, I have been playing around and noticed that a totally different behaviour is observed when creating a TToolBar control to be used for the Deskband, rather than a form:
Notice there are three TToolButton controls (with their text virtually invisible due to the Glass theme)? There should also be a TEdit and TComboBox between two separators, but these refuse to display at all.
Also notice the artefacting (the repetition of actual Taskbar Icons)?
I'm not sure if this is a step in the right direction or not, but it might help you (or others) to deduce a solution!
Okay... I've finally figured this out, and it is the most absurd thing I've ever come across.
I'm posting my findings here for the benefit of others (to save you going through the nuisance I've just been through).
To get all of the controls on your Deskband Form to display and function properly, simply set the Visible property of your Form (in the IDE designer) to True.
Ridiculous, I know, but it works and is easily repeatable.

Positioning controls in Delphi 5 so they fill the form client area when the form is resized in the same sort of proportions as they did initially

I have a DBGrid above a group box with some buttons and edit fields and another group box below that again with some buttons. I cannot fins a setting for the align and/or anchors for the DBGrid and the group boxes so they fill the form without overlapping or leaving blank bits of form.
I am using Delphi 5 on XP Pro with all updates installed.
If I remember, there is no built-in way to do this. When I did this in Delphi I implemented it manually in the event handler for the form resize event. You can recalculate the new positions for each control based on the size of the form and the proportions of the layout you want. You can simplify it by breaking the form in to panels and setting most of the controls to align to one or more edges of their parent panel. That way you mostly just have to resize a few panels. If you have a complex form you still might need to reposition some individual controls.
You might also find a third-party container control out there which makes this easier. I would search for combinations of "flow", "layout", "table", "container".
We've struggled with this as well, and I agree with Charles M that there is no built-in way to do this.
If you're looking for an outside solution, the ExpressLayout control from Developer Express allows you to fine-tune the positioning of controls on Delphi forms. They advertise "Screen Resolution Independence - Automatically Resizable Interfaces - Look & Feel Standardization...", so it might be worth looking into.
I've never used that particular control, but we use a lot of other Developer Express controls in our commercial projects. The controls and support are excellent.
See: http://www.devexpress.com/Products/VCL/ExLayoutControl/
They don't have a trial version, but do have a 60-day no-questions-asked money-back guarantee.

How do I merge TMainMenu's that use separate imagelists and retain the correct images by each menu item?

I have a program with two TForm classes and have added a TMainMenu to them each. I am then trying to merge them dynamically at run-time.
My problem is that when they merge the menu items in the merged in TMainMenu now display images stored in the imagelist in the form they were merged into rather than the images stored in their original form's imagelist.
Am I doing something wrong? is there a work around so that the menu item's continue to use the imagelist in the form they originated from?
I use the merged-in form in a number of projects, otherwise a single shared imagelist would make sense.
If I need to clarify anything, please say.
Thanks
Peter
The way I handle this is to have a single image list on a datamodule, and then include that in each form so that they can share that single set of icons.
I had exactly the same problem a while ago, but I also ran into other menu merge problems because my app was MDI, so I decided to do things in a completely different way.
What you could try, though, is dynamically adding one form's images to the other form's ImageList, and 'redirecting' the ImageIndexes. Might be a bit tricky, but should work.
What I eventually ended up with, is using the Toolbar2000 package for all my menus and toolbars. You can then download a very nice piece of code, called TB2Merge, which does exactly what you want. It also makes use of some of Toolbar2000's infrastructure to link a menu item's image to a different TImageList --- infrastructure that is not present in the VCL's TMainMenu. Be sure to read TB2Merge's documentation thoroughly!

Resources