Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-31
11
Medium Priority
?
471 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 27

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 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
 
LVL 32

Expert Comment

by:Ephraim Wangoya
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:Ephraim Wangoya
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:Ephraim Wangoya
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

661 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