Learning message (11): Testing the mouse message related to the twmmouse Structure

Source: Internet
Author: User
The message structure consistent with twmmouse is as follows:
Detail {left-click} twmlbuttondown {left-click} twmlbuttonup {left-click to raise} twmmbuttondblclk {middle-click} twmmbuttondown {middle-click to press} twmmbuttonup {middle-click to move} else {right-click} twmrbuttondown {right-click and press} twmrbuttonup {right-click to raise}
 

Code file:

Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) memo1: tmemo; checkbox1: tcheckbox; button1: tbutton; Procedure formcreate (Sender: tobject); Procedure button1click (Sender: tobject); protected procedure success (VAR message: Success); message success; Procedure wmlbuttondown (VAR message: twmlbuttondown); message wm_lbuttondown; Procedure wmlbuttonup (VAR message: twmlbuttonup); Message failed; procedure failed (VAR message: Success); Message failed; Procedure wmmbuttondown (VAR message: twmmbuttondown ); message wm_mbuttondown; Procedure wmmbuttonup (VAR message: twmmbuttonup); Message failed; Procedure wmmousemove (VAR message: twmmousemove); message wm_mousemove; procedure failed (VAR message: Success); Message failed; procedure wmrbuttondown (VAR message: twmrbuttondown); message wm_rbuttondown; Procedure wmrbuttonup (VAR message: twmrbuttonup); message success; end; var form1: tform1; implementation {$ R *. DFM} procedure merge (Sender: tobject); begin memo1.clear; end; procedure merge (Sender: tobject); begin memo1.align: = alleft; cursor: = ssvertical; memo1.clear; position: = poscreencenter; checkbox1.caption: = 'move the cursor accepted message'; button1.caption: = 'clear list'; end; Procedure tform1.wmlbuttondblclk (VAR message: twmlbuttondblclk); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('double click % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmlbuttondown (VAR message: twmlbuttondown); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('Press the left mouse button: % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmlbuttonup (VAR message: twmlbuttonup); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('left mouse lifted: % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmmbuttondblclk (VAR message: twmmbuttondblclk); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('double click % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmmbuttondown (VAR message: twmmbuttondown); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('Press % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmmbuttonup (VAR message: twmmbuttonup); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('hover the mouse up: % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmmousemove (VAR message: twmmousemove); var X, Y: integer; s: string; begin if not checkbox1.checked then exit; X: = message. xpos; Y: = message. ypos; s: = format ('move the mouse: % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmrbuttondblclk (VAR message: twmrbuttondblclk); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('right-click: % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmrbuttondown (VAR message: twmrbuttondown); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('right-click and press: % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end; Procedure tform1.wmrbuttonup (VAR message: twmrbuttonup); var X, Y: integer; s: string; begin X: = message. xpos; Y: = message. ypos; s: = format ('right-click to raise: % d, % d', [x, y]); memo1.lines. add (s); message. result: = 0; end.
 

Form file:

object Form1: TForm1  Left = 0  Top = 0  Caption = 'Form1'  ClientHeight = 206  ClientWidth = 321  Color = clBtnFace  Font.Charset = DEFAULT_CHARSET  Font.Color = clWindowText  Font.Height = -11  Font.Name = 'Tahoma'  Font.Style = []  OldCreateOrder = False  OnCreate = FormCreate  PixelsPerInch = 96  TextHeight = 13  object Memo1: TMemo    Left = 8    Top = 8    Width = 185    Height = 89    Lines.Strings = (      'Memo1')    TabOrder = 0  end  object CheckBox1: TCheckBox    Left = 199    Top = 8    Width = 122    Height = 17    Caption = 'CheckBox1'    TabOrder = 1  end  object Button1: TButton    Left = 199    Top = 173    Width = 75    Height = 25    Caption = 'Button1'    TabOrder = 2    OnClick = Button1Click  endend
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.