热情软件屋

 

不规则窗口随鼠标移动而移动


编号:QA003781
建立日期: 2001年1月17日 最后修改日期:2001年1月18日
所属类别:

小杨:
    操作系统:win98
    编程工具:visual C++6.0
    问题:位图区域窗口的移动问题:我想使位图窗口(不规则窗口)随鼠标移动而移动。不是模仿标题栏的那种即移动时不带虚框。要详细点。多多谢了。
    水平: 中级

回答:

    你的区域不应包含标准窗口的标题区,这样用户的鼠标点击只会被Form_Click之类的可编程事件句柄收到,然后你在里面写移动代码就行了,大至是这样的(使用了一些API,不要说你不懂:-):
    
    private mBegin as POINTAPI
    private mBeginRect as RECT
    private mCurrent as POINTAPI
    private mCurrentRect as RECT
    private mMoving as boolean
    
    private sub Form_MouseDown(...)
     if Button = 1 then
     GetCursorPos(mBegin)
     GetWindowRect(me.hWnd, mBeginRect)
     GetWindowRect(me.hWnd, mCurrentRect)
     mMoving = true
     end if
    end sub
    
    private sub Form_MouseMove(...)
     if mMoving then
     GetCursorPos(mCurrent)
     mCurrentRect.left = mBeginRect.left + mCurrent.x - mBegin.x
     mCurrentRect.top = mBeginRect.top + mCurrent.y - mBegin.y
     SetWindowPos(me.hwnd,...)
     end if
    end sub
    
    private sub Form_MouseUp(...)
     mMoving = false
    end sub
    
    青青玉的意见:
    用VB:
     have a better:
     Dim Mix
     Dim Miy
     MouseDown()
     Mix=X
     Miy=Y
     MouseMove()
     if Button=1 then
     me.Move me.left+X-Mix me.top+Y-Miy
    简单的很。
    可用VC我想代码没错呀可是就是不行。有代码吗?

此问题由Yh回答。

 
把这个问题推荐给朋友
   
   
您的意见类别
您的名字
您的电子邮件
您的建议(请尽可能详细)
 
 

版权所有 1997-2008 热情软件屋
如果您有任何建议和意见, 请给我发个电子邮件 askpro@china-askpro.com
Web Designed by ZebraStudio