码迷,mamicode.com
首页 > Windows程序 > 详细

《windows程序设计》滚轮消息(13)

时间:2018-10-06 20:39:31      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:word   project   最小   cal   cti   reg   ram   messages   over   

技术分享图片

代码如下:

program Project2;

  {$APPTYPE CONSOLE}

  {$R *.res}

uses
  System.SysUtils,
  windows,
  Winapi.Messages,
  Vcl.Dialogs;

type
  Point = record
    x: Integer;
    y: Integer;
  end;

var
  swndClass: tagWNDCLASS;
  message: MSG;
  mHwnd: hwnd;
  cxClient, cyClient: Integer;

function WindowProc(hwnd: hwnd; uMsg: UINT; wParam: wParam; lParam: lParam): LRESULT; stdcall;
var
  i: integer;
  uhdc: HDC;
  ps: PAINTSTRUCT;
begin
  case uMsg of
    WM_CREATE:
      begin

      end;
    WM_SIZE:
      begin
        cxclient := loword(lParam);
        cyclient := HiWord(lParam);
        result := 0;
        Exit;
      end;
    wm_paint:
      begin
        uhdc := BeginPaint(hwnd, ps);
        EndPaint(hwnd, ps);
        Exit;
      end;
    WM_MOUSEWHEEL:
      begin
        if int16(HiWord(wParam)) > 0 then
        begin
          Writeln(滚轮上滚);
        end
        else
        begin
          Writeln(滚轮下滚);
        end;
      end;
    WM_MBUTTONDOWN:
      begin
        Writeln(按下鼠标中键);
      end;
    WM_MBUTTONUP:
      begin
        Writeln(释放鼠标中键);
      end;
    WM_MBUTTONDBLCLK:
      begin
        Writeln(双击鼠标中键);
      end;
  end;

  result := DefWindowProc(hwnd, uMsg, wParam, lParam);
end;

begin
  swndClass.cbClsExtra := 0; //窗口类扩展,无
  swndClass.cbWndExtra := 0; //窗口实例扩展
  swndClass.hbrBackground := COLOR_BACKGROUND; //窗口背景颜色黑色
    //LoadCursor()
  swndClass.hCursor := LoadCursor(0, IDC_ARROW); //窗口采用箭头光标
  swndClass.hIcon := LoadIcon(0, IDI_APPLICATION); //窗口最小化图标:采用缺省图标
  swndClass.hInstance := hInstance; //窗口实例句柄
  swndClass.lpfnWndProc := @WindowProc; //窗口处理函数
  swndClass.lpszClassName := myWnd; //窗口类名
  swndClass.lpszMenuName := nil; //窗口菜单
  swndClass.style := CS_DBLCLKS; //窗口样式
  if RegisterClass(swndClass) = 0 then
  begin
    Writeln(windows class register error!);
    Exit;
  end;

  mHwnd := CreateWindowEx(0, myWnd, Delphi Windows, WS_OVERLAPPEDWINDOW,  {滚动条添加}
    CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, HWND_DESKTOP, 0, hInstance, 0);

  ShowWindow(mHwnd, SW_SHOW);
  UpdateWindow(mHwnd);
  while GetMessage(message, 0, 0, 0) do
  begin
    TranslateMessage(message);
    DispatchMessage(message);
  end;
end.

 

《windows程序设计》滚轮消息(13)

标签:word   project   最小   cal   cti   reg   ram   messages   over   

原文地址:https://www.cnblogs.com/YiShen/p/9748242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!