1. Perform function
Copy the code code as follows:
DBGrid1.Perform(WM_VSCROLL,SB_PAGEDOWN,0); //Control the scroll bar and turn pages backward
DBGrid1.Perform(WM_VSCROLL,SB_PAGEUP,0); //Control the scroll bar and page forward
2. SendMessage function
Copy the code code as follows:
SendMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEDOWN,0);
SendMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEUP,0);
3. PostMessage function
Copy the code code as follows:
PostMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEDOWN,0);
PostMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEUP,0);
Note: (difference between functions 2 and 3)
PostMessage just puts the message into the queue, returns regardless of whether other programs process it, and then continues execution;
SendMessage must wait for other programs to process the message before returning and continuing execution.
The return value of PostMessage indicates whether the PostMessage function is executed correctly;
The return value of SendMessage represents the return value of other programs after processing the message.
The most important thing when using these two message sending functions is to see whether your program pays attention to the lag of the message. PostMessage will cause the lag of the message, but SendMessage will not. However, if the SendMessage message processing fails, it will Cause the program to stop!