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 to send a pageup or pagedown to a TListBox 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
27-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
76
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I would like to control the pageup event of a TListBox by 
listbox1keydown(self,vk_next,[]); , but it produces an error message. Why?

Answer:

Calling the onKeyDown event handler directly accomplishes nothing. To make the 
control scroll you have to send either the key or a scroll message to the control 
itself. For the key that would take the following form:

1   
2   procedure PostKey(hWindow: HWND; key: Word);
3   begin
4     if IsWindow(hWindow) then
5     begin
6       PostMessage(hWindow, WM_KEYDOWN, key, MakeLong(0, MapVirtualKey(key, 0)));
7       PostMessage(hWindow, WM_KEYUP, key, MakeLong(0, MapVirtualKey(key, 0) or 
8   $C0000000));
9     end;
10  end;
11  
12  PostKey(listbox.handle, VK_NEXT);


Since PostKey puts the messages into the message loop they will not get processed 
unless your code falls back to the message loop or calls 
Application.ProcessMessages. You could replace the PostMessage with a SendMessage 
in this case since the key yields no character.

Sending a scroll message directly would look like this:
13  
14  listbox.perform(WM_VSCROLL, SB_PAGEDOWN, 0);
15  listbox.perform(WM_VSCROLL, SB_ENDSCROLL, 0);


			
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