AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Caret in ComboBox

Ein Thema von trockentaucher · begonnen am 30. Aug 2005 · letzter Beitrag vom 31. Aug 2005
 
DBR

Registriert seit: 19. Jul 2005
43 Beiträge
 
#4

Re: Caret in ComboBox

  Alt 31. Aug 2005, 17:03
Delphi-Quellcode:
const
  Hook: Hhook = 0;

var
  pos: integer;

procedure TForm1.ComboBox1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  pos := Combobox1.selstart;
end;

function MouseProc(HookCode: Integer; WParam: WPARAM;
  LParam: LPARAM): LRESULT; stdcall;
var pt: TPoint;
begin
  if (HookCode = HC_ACTION) and (WParam = WM_LBUTTONUP) then begin
    with Form1.Combobox1 do begin
      pt := ScreenToClient(PMOUSEHOOKSTRUCT(LParam)^.pt);
      if ptinrect(rect(0, 0, width, height), pt) then begin
        pos := selstart;
        result := 0;
        exit;
      end;
    end;
  end;
  result := CallNextHookEx(Hook, HookCode, WParam, LParam);
end;

procedure HookInst;
begin
  if Hook <> 0 then exit;
  Hook := SetWindowsHookEx(WH_MOUSE, MouseProc,
    HInstance, GetCurrentThreadId);
  if Hook = 0 then
    MessageBox(0, 'Der Hook wurde nicht installiert!',
      'FEHLER', MB_ICONERROR);
end;

procedure HookUninst;
begin
  if Hook <> 0 then UnhookWindowsHookEx(Hook);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
// ---- zum Testen ---------------
  combobox1.items[0] := 'Zeile 1';
  combobox1.items[1] := 'Zeile 2';
  combobox1.items[2] := 'Zeile 3';
  combobox1.items[3] := 'Zeile 4';
  combobox1.items[4] := 'Zeile 5';
// ------------------------------
  combobox1.itemindex := 0;
  HookInst;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  HookUninst;
end;

procedure TForm1.Button1Click(Sender: TObject);
var s: string;
begin
  s := Combobox1.text;
  insert('###', s, pos);
  Combobox1.text := s;
end;
Gruß DBR
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:14 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