Solved

Delphi 6 - TListView OnColumnRightClick Event get Incorrect Column Object

Posted on 2003-11-12
3
249 Views
Last Modified: 2010-04-03
I have a Listview in my Application, it is displayed in Report Mode with ShowColumnHeaders set to True, I have code in the OnColumnRightClick Event which makes use of the Column Object,

But the Column Object Passed to the Event is incorrect if you have scrolled horizontally, Delphi seems to return the column which would have been there if you hadn't have scrolled.

Can't think of a way around this, thought maybe find out how far I have scrolled and then add up all the column widths and therefore being able to manually determine the column which was clicked - that didn't work because TListView does not expose the Scrollbars and I dont know how else to find out how far I have scrolled.

NOTE: OnColumnClick event dosn't have this problem but I already use this Event to sort my list view.

Any suggestions?

Thanks,

-D
0
Comment
Question by:DRyall
[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
3 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 9731227
well seems to be a bug

following workaround

procedure TForm1.ListView1ColumnRightClick(Sender: TObject;
  Column: TListColumn; Point: TPoint);
var
  i,cw,cc : integer;

  col : TListColumn;
begin
  col := nil;
  i := getscrollpos(listview1.Handle,sb_horz); //currentscrollbarpos
  i := i + point.x;
  cc := 0;
  cw := 0;
  while (cc < listview1.Columns.Count) and
        (cw < i) do
  begin
    cw := cw + listview1.Columns[cc].width; //add width
    if cw < i then
      inc(cc);
  end;
  if (cc < listview1.Columns.Count) then
    col := listview1.Columns[cc];

  if assigned(col) then
    //do your action
    showmessage(Col.Caption);
end;

meikl ;-)
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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

717 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