Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Nonvcl Listbox LB_SETTOPINDEX (https://www.delphipraxis.net/128494-nonvcl-listbox-lb_settopindex.html)

EWeiss 30. Jan 2009 19:49


Nonvcl Listbox LB_SETTOPINDEX
 
Wieder ListBox kommt noch einiges ;)

Habe eine Function angelegt für MouseWeel.

Delphi-Quellcode:
type
  TSkinListBox = class
  private
    LStyle:    DWORD;
    hFDefault: hFont;
    BColor,
    FColor:    COLORREF;
    FHOwner:   HWND;
    function DefaultFont: hFont;
    procedure SetCTLFont(hCtL: HWND; Font: hFont);
    procedure SubClass(WinHandle: HWND);
    procedure UnSubClass(WinHandle: HWND);
  public
    Handle: HWND;
    procedure DrawItem(lP: Integer);
    procedure ListSetTopIndex(hList: HWND; nTopIndex: Integer);
    function ListGetTopIndex(hList: HWND): Integer;
    constructor Create(hOwner: HWND; FullpathImageName: string; x, y, xW, yH,
      ListID: integer; Visible: Boolean; BackBitmap: string; AktForecolor: COLORREF;
      InAktForecolor: COLORREF; BackColor: COLORREF);
    destructor Destroy; override;
  end;
Delphi-Quellcode:
function TSkinListBox.ListGetTopIndex(hList: HWND): Integer;
var
  nGetTopIndex: Integer;
begin
    nGetTopIndex := -1;

    if hList <> 0 then
    begin
       nGetTopIndex := SendMessage(hList, LB_GETTOPINDEX, 0, 0);
       if nGetTopIndex > -1 then
         inc(nGetTopIndex);
    end;
    Result := nGetTopIndex;
end
Wenn ich nun in der ListBoxProc(nicht in der Classe implementiert) TSkinListBox.ListGetTopIndex aufrufe dann meckert der compiler !
Zitat:

[Pascal Error] uListBox.pas(286): E2076 This form of method call only allowed for class methods
Wie kann ich das abfangen ?

gruss Emil

Sir Rufo 30. Jan 2009 19:58

Re: Nonvcl Listbox LB_SETTOPINDEX
 
Musst Du die Proc dann nicht als class procedure deklarieren? ;)

EWeiss 30. Jan 2009 19:59

Re: Nonvcl Listbox LB_SETTOPINDEX
 
Zitat:

Zitat von Sir Rufo
Musst Du die Proc dann nicht als class procedure deklarieren? ;)

Hmm verstehe nicht was du jetzt meinst.

gib mir einen TIP ;)
Kann zwar halbwegs mit API aber einige dinge von Delphi sind mir noch nicht bekannt :)

gruss EMil

Sir Rufo 30. Jan 2009 20:01

Re: Nonvcl Listbox LB_SETTOPINDEX
 
Delphi-Quellcode:
type
  TSkinListBox = class
  private
    LStyle:    DWORD;
    hFDefault: hFont;
    BColor,
    FColor:    COLORREF;
    FHOwner:   HWND;
    function DefaultFont: hFont;
    procedure SetCTLFont(hCtL: HWND; Font: hFont);
    procedure SubClass(WinHandle: HWND);
    procedure UnSubClass(WinHandle: HWND);
  public
    Handle: HWND;
    procedure DrawItem(lP: Integer);
    procedure ListSetTopIndex(hList: HWND; nTopIndex: Integer);
    class function ListGetTopIndex(hList: HWND): Integer; // <-- DA IS :)
    constructor Create(hOwner: HWND; FullpathImageName: string; x, y, xW, yH,
      ListID: integer; Visible: Boolean; BackBitmap: string; AktForecolor: COLORREF;
      InAktForecolor: COLORREF; BackColor: COLORREF);
    destructor Destroy; override;
  end;
Du willst ja mit der Klasse die Funktion aufrufen und nicht mit einer Objekt-Referenz ... das muss man bei der Klassendefinition berücksichtigen.

EWeiss 30. Jan 2009 20:06

Re: Nonvcl Listbox LB_SETTOPINDEX
 
Danke!
Ahh wieder was dazu gelernt.
Funktioniert.
Delphi-Quellcode:
class function TSkinListBox.ListGetTopIndex(hList: HWND): Integer;
var
  nGetTopIndex: Integer;
begin
    nGetTopIndex := -1;

    if hList <> 0 then
    begin
       nGetTopIndex := SendMessage(hList, LB_GETTOPINDEX, 0, 0);
       if nGetTopIndex > -1 then
         inc(nGetTopIndex);
    end;
    Result := nGetTopIndex;
end;
Ähnlich byRef in VB denk ich mal..
Muss man wissen ;)

gruss Emil


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:34 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz