炫彩界面库论坛

 找回密码
 加入我们

QQ登录

只需一步,快速开始

查看: 4914|回复: 2

[提问] 元素拖拽时会闪烁如何解决?

[复制链接]

该用户从未签到

发表于 2018-4-3 10:55:55 | 显示全部楼层 |阅读模式
20炫彩币
  1. #Include <class_xc>
  2. #NoEnv
  3. #SingleInstance Force
  4. SetWorkingDir %A_ScriptDir%
  5. SetBatchLines -1

  6. xc.XInitXCGUI()
  7. xc.XC_EnableDebugFile(False)

  8. m_hWindow := xc.XWnd_Create(0, 0, 400, 400, "炫彩界面库窗口")

  9. hEle := xc.XEle_Create(100, 100, 5, 200, m_hWindow)
  10.         xc.XEle_EnableBkTransparent(hEle, true)

  11.         hBKM := xc.XEle_GetBkManager(hEle)
  12.         xc.XBkM_AddInfo(hBKM, "{99:1.9.9;5:2(26)3(1,0,0,0)20(1)21(3)26(0)22(-16776961)23(255);98:16(0);}")

  13.         hCursor := DllCall("LoadCursor", "Uint", 0, "Int", 32644, "ptr")
  14.         xc.XEle_SetCursor(hEle, hCursor)

  15. global g_isLineEle := {}, g_lastEle
  16. g_isLineEle[hEle] := true

  17. xc.XWnd_RegEventC1(m_hWindow, WM_MOUSEMOVE := 0x200, "OnWndMouseMove")
  18. xc.XWnd_RegEventC1(m_hWindow, WM_LBUTTONDOWN := 0x201, "OnWndLButtonDown")
  19. xc.XWnd_RegEventC1(m_hWindow, WM_LBUTTONUP := 0x202, "OnWndLButtonUp")

  20. xc.XWnd_AdjustLayout(m_hWindow)
  21. xc.XWnd_ShowWindow(m_hWindow)

  22. xc.XRunXCGUI()
  23. xc.XExitXCGUI()
  24. Return

  25. OnWndMouseMove(hWindow, nFlags, point, pbHandled) {
  26.         if !g_lastEle
  27.                 Return

  28.         diffX := NumGet(point+0, "Int") - g_lastEle.X
  29.         diffY := NumGet(point+4, "Int") - g_lastEle.Y
  30.        
  31.         ; 计算新的坐标
  32.         rc := g_lastEle.rect
  33.         newLeft   := rc.left + diffX
  34.         newTop    := rc.top + diffY
  35.         newRight  := newLeft + rc.w
  36.         newBottom := newTop + rc.h

  37.         ; 设置新的坐标
  38.         VarSetCapacity(pRect, 16, 0)
  39.         NumPut(newLeft  , pRect, 0, "Int")
  40.         NumPut(newTop   , pRect, 4, "Int")
  41.         NumPut(newRight , pRect, 8, "Int")
  42.         NumPut(newBottom, pRect, 12, "Int")
  43.         xc.XEle_SetRect(g_lastEle.hEle, &pRect, True)
  44. }

  45. OnWndLButtonDown(hWindow, nFlags, point) {
  46.         hEle := xc.XWnd_HitChildEle(hWindow, point)
  47.         if !g_isLineEle[hEle]
  48.                 return g_lastEle := ""

  49.         g_lastEle := { hEle : hEle
  50.                      , X    : NumGet(point+0, "Int")
  51.                      , Y    : NumGet(point+4, "Int") }

  52.         xc.XEle_GetRect(hEle, pRect)
  53.         g_lastEle.rect := { left   : NumGet(pRect, 0 , "Int")
  54.                           , top    : NumGet(pRect, 4 , "Int")
  55.                           , right  : NumGet(pRect, 8 , "Int")
  56.                           , bottom : NumGet(pRect, 12, "Int")
  57.                           , w      : NumGet(pRect, 8 , "Int") - NumGet(pRect, 0, "Int")
  58.                           , h      : NumGet(pRect, 12, "Int") - NumGet(pRect, 4, "Int") }
  59. }

  60. OnWndLButtonUp(hWindow, nFlags, point) {
  61.         if g_lastEle {
  62.                 g_lastEle := ""
  63.         }
  64. }
复制代码


想做一个九宫格辅助工具,需要拖动四条线条。按照我上面的代码写,拖动速度稍微快一点,元素就会闪烁。但是我把元素的宽度从 5 改成 55,闪烁情况又会消失。

该用户从未签到

发表于 2018-4-12 14:37:21 | 显示全部楼层
这个论坛人气不足啊,貌似要……
回复

使用道具 举报

该用户从未签到

发表于 2019-4-9 23:16:00 | 显示全部楼层
路过,发几张美女图片


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|Archiver|手机版|小黑屋|炫彩界面库 ( 鄂ICP备2023014763号-1 )

GMT+8, 2024-4-16 15:03 , Processed in 0.064076 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表