Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • T TrafficMonitor
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 813
    • Issues 813
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • zhongyang219
  • TrafficMonitor
  • Wiki
  • 插件开发指南

插件开发指南 · Changes

Page history
插件开发指南更新 authored Feb 11, 2022 by Zhong Yang's avatar Zhong Yang
Hide whitespace changes
Inline Side-by-side
插件开发指南.md
View page @ c4336c1a
...@@ -325,6 +325,20 @@ virtual int GetItemWidth() const ...@@ -325,6 +325,20 @@ virtual int GetItemWidth() const
* 返回的值为DPI为96(100%)时的宽度,主程序会根据当前系统DPI的设置自动按比例放大,因此你不需要为不同的DPI设置返回不同的值。 * 返回的值为DPI为96(100%)时的宽度,主程序会根据当前系统DPI的设置自动按比例放大,因此你不需要为不同的DPI设置返回不同的值。
* 这里的返回值代表了自绘区域所需要的最小宽度,DrawItem函数中的参数w的值可能会大于这个值 * 这里的返回值代表了自绘区域所需要的最小宽度,DrawItem函数中的参数w的值可能会大于这个值
### GetItemWidthEx
**函数原型**
```c++
virtual int GetItemWidthEx(void* hDC) const;
```
**说明**
此函数的作用和GetItemWidth一样,为了兼容旧版本的插件,在保留了GetItemWidth函数的情况下添加了此函数。和GetItemWidth函数相比,此函数增加了参数*hDC*,它是绘图的上下文句柄,可以根据它来计算显示区域的宽度。
主程序在需要获取显示项目的宽度时,会先调用此函数,如果返回值为0,再调用GetItemWidth函数。
### DrawItem ### DrawItem
**函数原型** **函数原型**
...@@ -349,6 +363,53 @@ virtual void DrawItem(void* hDC, int x, int y, int w, int h, bool dark_mode) ...@@ -349,6 +363,53 @@ virtual void DrawItem(void* hDC, int x, int y, int w, int h, bool dark_mode)
是否为深色模式。 是否为深色模式。
### OnMouseEvent
**函数原型**
```c++
virtual int OnMouseEvent(MouseEventType type, int x, int y, void* hWnd, int flag);
```
**说明**
当插件显示区域有鼠标事件时由主程序调用。
*type*
MouseEventType类型的枚举项,表示鼠标事件的类型。
#### MouseEventType
| 枚举项 | 说明 |
| ------------ | -------------- |
| MT_LCLICKED | 点击了鼠标左键 |
| MT_RCLICKED | 点击了鼠标右键 |
| MT_DBCLICKED | 双击了鼠标左键 |
*x, y*
鼠标指针所在的坐标。此坐标是基于任务栏窗口或主窗口左上角为原点的坐标。
*hWnd*
产生此鼠标事件的窗口的句柄(主窗口或任务栏窗口)。
*flag*
若干MouseEventFlag枚举常量的组合。
#### MouseEventFlag
| 枚举项 | 说明 |
| -------------- | -------------------------- |
| MF_TASKBAR_WND | 是否为任务栏窗口的鼠标事件 |
*返回值*
如果返回1,则主程序认为插件已经对此鼠标事件作出了全部的响应,主程序将不会再对此鼠标事件做额外的响应。
例如当type为MT_RCLICKED时,如果程序返回0,则会弹出主程序提供的右键菜单;而返回1时,主程序不会再做任何处理。
## 示例代码 ## 示例代码
### CPluginDemo类(继承自ITMPlugin接口) ### CPluginDemo类(继承自ITMPlugin接口)
......
Clone repository

TrafficMonitor Wiki 导航

首页

  • 主窗口 | Main Window
  • 任务栏窗口
  • 右键菜单
  • 选项设置
    • 主窗口设置
    • 任务栏窗口设置
    • 常规设置
  • 硬件监控功能
  • 选择监控的网络连接
  • 更换皮肤功能
    • 皮肤制作教程
  • 通知区图标
  • 历史流量统计
  • 配置和数据文件
  • 插件开发指南 | Plugin Development Guide

更新日志 - Update Log

常见问题 - Frequently Asked Questions

已知问题