Solved

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

Posted on 2014-01-31
11
408 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 25

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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