?
Solved

Delphi 6 - TListView OnColumnRightClick Event get Incorrect Column Object

Posted on 2003-11-12
3
Medium Priority
?
250 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 200 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

770 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