Solved

How to output an "up arrow" or "down arrow" character...

Posted on 2014-01-31
11
414 Views
Last Modified: 2014-02-15
Hi Experts...
    I've got a CheckListBox where I'd like to be able to show for each individual item in the list, a character that indicates "ascending" or descending". In other words, I'd like to be able to tack on a character at the end of each of the TString items, that looks like an "up arrow" or a "down arrow"... or a little upwards/downwards pointing triangle would do too. Do you know of any escape character or ALT sequence that would let me output such a character?

Thanks!
    Shawn
0
Comment
Question by:shawn857
  • 6
  • 4
11 Comments
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 39825339
Your intention is to move items up/down in list? Can you draw your idea?
May be is solution to add two buttons below/on right of box and this buttons get selected item and moves up/down.
0
 

Author Comment

by:shawn857
ID: 39825889
No no, I don't want to move items in a list.... not at all. I want to know what kind of "escape character" or "escape sequence" to make an image of up arrow or down arrow, or an up triangle or down triangle. Do you see?

Thanks
   Shawn
0
 

Author Comment

by:shawn857
ID: 39827305
I think I better explain more clearly what I'm doing and what I'm asking: In my app, I let the user make some specifications on how to sort a file of data. I use a TChecklistBox to display the various fields of the record, and the user can check off the fields he wishes to use as sort keys. OK, no problem there. What I'd like to be able to let the user also do is to specify whether the sort order of these sort keys be Ascending or Descending. I figured if I could somehow display an indicative "up arrow" or "down arrow" following the name of the sort key shown in the TCheckListBox items, then the user could just double-click an item to toggle this arrow up or down, to mean Ascending or Descending. Alternatively, is there a way to show a image file within an item in a TCheckListBox?

Thanks!
   Shawn
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
ID: 39829244
Use custom draw event of checklist box, here is a simple example using arrows stored in an image list object

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, StdCtrls, CheckLst;

type
  TForm1 = class(TForm)
    CheckListBox1: TCheckListBox;
    ImageList1: TImageList;
    procedure CheckListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CheckListBox1DrawItem(Control: TWinControl;
  Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
  DC: HDC;
  Title: string;
  R: TRect;
  ImageIndex: Integer;
  BP: TBitmap;
begin
  DC := TCheckListBox(Control).Canvas.Handle;
  FillRect(DC, Rect, GetStockObject(WHITE_BRUSH));
  Title := TCheckListBox(Control).Items[Index];
  DrawText(DC, PChar(Title), Length(Title), Rect, DT_SINGLELINE or DT_VCENTER or DT_LEFT or DT_END_ELLIPSIS);

  BP := TBitmap.Create;
  try
    ImageList1.GetBitmap(Index MOD 2, BP);
    BitBlt(DC, Rect.Right - 17, Rect.Top + 1, 16, 16, BP.Canvas.Handle, 0, 0, SRCCOPY);
  finally
    BP.Free;
  end;
end;

end.

Open in new window


Form
object Form1: TForm1
  Left = 192
  Top = 114
  Width = 286
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object CheckListBox1: TCheckListBox
    Left = 72
    Top = 56
    Width = 129
    Height = 169
    ItemHeight = 16
    Items.Strings = (
      'Item 1'
      'Item 2'
      'Item 3'
      'Item 4'
      'Item 5')
    Style = lbOwnerDrawFixed
    TabOrder = 0
    OnDrawItem = CheckListBox1DrawItem
  end
  object ImageList1: TImageList
    Left = 72
    Top = 16
    Bitmap = {
      494C010102000400040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000001000000001001000000000000008
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C00000000000000000000000000000000000000000000000000000000007C
      007C007C00000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C00000000000000000000000000000000000000000000000000000000007C
      007C007C00000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C0000000000000000000000000000000000000000000000000000007C007C
      007C007C007C0000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000007C007C007C
      007C007C007C007C0000000000000000000000000000000000000000007C007C
      007C007C007C0000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000000000000000007C007C
      007C007C007C0000000000000000000000000000000000000000007C007C007C
      007C007C007C007C000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000000000000000000000000000007C007C
      007C007C007C0000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000000000000000000000000000007C
      007C007C00000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000000000000000000000000000007C
      007C007C00000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      007C000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000424D3E000000000000003E000000
      2800000040000000100000000100010000000000800000000000000000000000
      000000000000000000000000FFFFFF00FC7FFEFF00000000FC7FFEFF00000000
      FC7FFC7F00000000FC7FFC7F00000000FC7FF83F00000000FC7FF83F00000000
      E00FF01F00000000E00FF01F00000000F01FE00F00000000F01FE00F00000000
      F83FFC7F00000000F83FFC7F00000000FC7FFC7F00000000FC7FFC7F00000000
      FEFFFC7F00000000FEFFFC7F00000000}
  end
end

Open in new window

0
 

Author Comment

by:shawn857
ID: 39831197
Thanks Ewangoya, I'm going to play with this. Would you happen to have a small green "up arrow" image in the same style as these red arrows?

Alternatively, do you think it might be just simpler to just change the background color of the item to green (for "Ascending" sort order) or red (for "Descending" sort order)? Would that be easier? I'm thinking it might be more straightforward for my users and look less "cluttered"....

Thanks!
    Shawn
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Expert Comment

by:ewangoya
ID: 39831767
Have you tried glyFX library, they have some pretty nice images including arrow images for free.

http://www.glyfx.com/
0
 

Author Comment

by:shawn857
ID: 39852360
Ewangoya, do you have any thoughts on the other comment I asked:

"Alternatively, do you think it might be just simpler to just change the background color of the item to green (for "Ascending" sort order) or red (for "Descending" sort order)? Would that be easier? I'm thinking it might be more straightforward for my users and look less "cluttered"....

Is this even possible?

Thanks!
    Shawn
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 39852827
You are better off working with the arrows. A much smaller image would look better.

With color coding you would have to explain to your users what each color means, so you would need some space to add that label, and using hints just makes the screen look crowded
0
 

Author Comment

by:shawn857
ID: 39854321
But would it be difficult to change the background color of each item? Is there a property for that, or would I still have to "OwnerDraw" each item manually? I would really only use two colors (green and red) so there wouldn't be much explanations needed to my users...

Thanks!
   Shawn
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 39858743
You would still have to draw it yourself, there is no property for that
0
 

Author Closing Comment

by:shawn857
ID: 39861972
Thank you Ewangoya!

Cheers
   Shawn
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use Hashing sha1 in Delphi 2010 4 201
Sending Gmail through Delphi 3 91
Delphi Form ownership 4 73
Delphi: Connect to running MS Outlook 4 48
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now