Solved

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

Posted on 2014-01-31
11
425 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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