Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How select first item in ListView with use key TAB Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
17-Sep-02
Category
VCL-General
Language
Delphi 2.x
Views
95
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

When I hand over focus with key TAB to ListView, ListView not select first item. 
How on it?

Answer:

We have two ListView components. First component with name ListView1 contains two 
events.


1   procedure TForm1.ListView1Enter(Sender: TObject);
2   begin
3     HookHandle := SetWindowsHookEx(WH_KEYBOARD, @MsgHook, 0, GetCurrentThreadID);
4   end;
5   
6   procedure TForm1.ListView1Exit(Sender: TObject);
7   begin
8     UnHookWindowsHookEx(HookHandle);
9   end;



Second component with name ListView2 is activate with procedure MsgHook.

10  
11  function MsgHook(Code: Integer; WParam: WPARAM; LParam: LPARAM): Integer; stdcall;
12  const
13    KeyTAB: Integer = 983041;
14  begin
15    if (Code = HC_ACTION) then
16    begin
17      if LParam = KeyTAB then
18      begin
19        frmMain.lsvCCM.SetFocus;
20        SendMessage(Form1.ListView2.Handle, WM_KEYDOWN, VK_DOWN, 1);
21  
22        Result := -1;
23        Exit;
24      end;
25    end;
26  
27    Result := CallNextHookEx(HookHandle, Code, WParam, LParam);
28  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC