how to set the tabwidth of the listbox portion of a TComboBox in Delphi - delphi

You can easily achieve a multicolumn effect in a listbox by setting the TabWidth property of TListbox. For example, http://delphi.about.com/cs/adptips2000/a/bltip1200_3.htm
I need to do the same in the drop down list of a ComboBox, but comboboxes don't publish any TabWidth property.
Any ideas?

In a comment to this answer advising you to owner-draw the list box items you say:
I'm wondering why I must do that when the required functionality already exists on a listbox
A combo box is actually composed of three native child windows - the combo box itself, an embedded edit, and a list box. You can use the GetComboBoxInfo() function to fill a COMBOBOXINFO structure (i.e. a TComboBoxInfo record) with information about the control, and it will return the 3 HWND elements in it. With that you are able to alter the appearance and behaviour of the list box. In principle.
For the list box to use the tab stops it needs to have the LBS_USETABSTOPS style flag set. Unfortunately this can't be turned on later, the list box has to be created with it. So you could use the functionality only if you were able to turn the style flag on for the list box, which is created during the CreateWindowEx() call for the combo box. AFAICS this can only be done by hooking the CreateWindowEx() call itself, identifying the internal call that creates the list box, and altering the passed style. This means runtime modification of code, and not in your executable but in a Windows DLL.
Owner-drawing the list items looks like it would be much easier.

From what I know there is not so simple way as TabWidth here but you can override Paint method and draw it yourself. Looking at listbox and combobox sources may help.

Related

Firemonkey styles - duplicate a certain style lookup to customize

In a Firemonkey project, I have a TListBox with numerous items. Depending on the state of any given item, I intend to show the Detail as either red or white (on a black background). Of course I need to use the styles to do this.
I right-click one of the TListBoxItem controls and choose "Edit Custom Style...". It's my understanding that it's supposed to produce a new copy of whatever the current style lookup is just for this one control. In my case, I had already set it to listboxitemrightdetail prior to trying to customize it. What I would expect is that when I make a change to the font color in this style and "Apply and Close", that one single list box item should get that change.
However, instead of that one, ALL of the items in this list box got that change. The change I made actually modified the listboxitemrightdetail rather than producing a copy of it just for that one control.
In the end, I intend to have two style lookups, for example listboxitemreddetail and listboxitemwhitedetail which I can toggle on each list item in runtime.
What am I doing wrong, and what's the appropriate way to duplicate a style lookup to have two different versions?

Delphi combobox csOwnerDrawFixed set text property

I am using the csOwnerDrawFixed style to incorporate my style into a TCombobox. The problem is that I can no longer use the Text Property. I suppose it is read only. Is there a way to enable the text property?
No this is not possible. What you are observing is a simple reflection of the underlying Win32 control's behaviour.
When you select the csOwnerDrawFixed style that is mapped to the combo box CBS_OWNERDRAWFIXED style. And when a combo box has that style, then WM_SETTEXT always fails with CB_ERR, and WM_GETTEXT always returns an empty string.
The reason for this is that when you use the csOwnerDrawFixed style then the combo box does not have an associated edit control. Therefore there is nowhere for it to store window text. You only get an associated edit control if the combo box style is csDropDown or csSimple.

How make a control that look like the "download" dialog of firefox

I have a application that like firefox, can be enhanced from plugins available from internet.
Now, I want to provide in Delphi (2010) a dialog similar to the download from firefox. I have no skills in build graphical controls.
Using the standard controls of Delphi, what could be the best way... using a TListView/TStringGrid with custom draw or...
The idea is show a icon in the left, a title with subtitle with 1-3 lines on the middle and date/version on the right. That row must be selectable and that is all.
For the UI part,
The easiest way: Use TNextGrid in "Slide view" from bergsoft. It's one of my favorite VCL controls. Check this screenshot:
http://www.bergsoft.net/res/screenshots/next-grid/slides-style.gif
The most flexible way: Use TVirtualStreeTree with custom draw, but it'll take some time to get use to that most powerful tree view control and apply a custom draw.
The Most promising way: Use TMS software's advanced poly list (in beta stage currently), check the Screenshots in the following page and it's very nice looking!:
http://www.tmssoftware.com/site/advpolylist.asp
use VirtualStringTree from SoftGems.
Use TFrame to create a custom control for one download, and then reuse it.
Use a TDataSet descendant (eg. TClientDataSet, JVCL's TjvMemoryData or any other dataset you like) to have a table with all the fields needed to describe your download. For example:
Plugin_Name - Char(255)
Plugin_Icon - Blob
Downloaded_Size - Int64
Total_Size - Int64
//etc.
(Of course the above fields are provided just as an example - the actual fields are up to you).
After this, connect a TDataSource to your table and use an TDBCtrlGrid to show your data as you wish. For the above example, you can put on your record a TDBLabel, TDBImage, TjvDBProgressBar (unfortunately we don't have a data-aware gauge shipped with Delphi) etc. all these connected to the appropriate fields.
In this way you can simulate a list (if you set TDBCtrlGrid's Column property to 1) with a custom layout in which you can do select, add, delete etc.
HTH

how can i make a TRibbonComboBox act like a TCombobox with Style of csDropDownList?

how can i make a TRibbonComboBox act like a TCombobox with Style of csDropDownList? we don't want the user to be able to edit the choices in the list.
we need to use TRibbonComboBox because we want the current selection to be visible.
Microsoft word shows a combobox where you can select an item but cannot edit the item itself.
should i consider trying a TCombobox in the ribbon? i'd expect it won't look or not work correctly.
thank you for you comments!
You can just use TRibbonComboBox.ReadOnly:
Determines whether the user can change the text of the edit control.
And furthermore:
Setting ReadOnly to true ensures that the text is not altered, while still allowing the user to select text. The selected text can then be manipulated by the application, or copied to the Clipboard.
(see documentation)

Delphi control that could mimic "Add-ons|Extension list" of Firefox?

My aim is to update the look of the GUI in my app. Currently my GUI contains a lot of listboxes which are used to edit some objects in an old fashioned way, that is, user double-clicks an item and a dialog is shown to modify the corresponding object.
I think a good modern approach is how Firefox displays the extensions installed (a snapshot below).
My question is about how to build such a GUI in Delphi(win32) easily? Are there any components you use mimicing such behaviour or will I just need to code this from stratch using panels? (IMO a very cumbersome job I'd like to avoid - the selection logic, resizings, etc...)
You can do something similar (not exactly) with standard components; TDBCtrlGrid, TSpeedButton,...
alt text http://img8.imageshack.us/img8/9585/imagen29ox3.png
If you're using Delphi 2007 or Delphi 2009, you might be able to do something similar using TCategoryButtons (from the 'Additional' component palette page). Drop it on a form and right click to display the popup menu, and then click "Categories Editor...". Add a category with the resulting dialog, set it's caption, and optionally set up Items it contains. Not exactly the same, but it might do what you need.
You could also use a dialog with a TTreeView (if you have categories of objects) or TListView to emulate the Delphi 2007 Projects->Options dialog. Clicking an item in the TreeView or ListView displays the proper page of a TPageControl to configure the object.
I mostly agree with Lars, but I would use a frame for each item instead of a panel. That would separate into its own file, and you would get easy designtime support for it.
Using a TFrame for each list item and put them all Aligned Top on a TScrollBox might work. Also see TDBCtrlGrid which does something like that in combination with datasets.
It can be done with existing Delphi controls.
For instance in the TCustomListBox control you can create your own OnDrawItem event to draw your own list item. You also need to create your own OnMeasureItem to change the item height.
In some cases it is very limited, so if you want more freedom you will need to do it from scratch.

Resources