VC Super strong Imitation QQ automatic telescopic window

Source: Internet
Author: User
Tags bool

Summary:

One day in the CSDN forum to see someone post asked QQ automatic telescopic window is how to achieve, I also want to know, so to Baidu a search, the result is not much, come and go are the few, download those demo run, find the effect and QQ difference is very big, so decided to do a do-it-yourself, The requirement is to imitate this function almost perfectly. As a result of something, texture can not see out, so the article is not a screenshot, want to see the effect of directly running the source code demo bar.

First, observe

The most important step before imitation is observation, after half a day of tinkering with the QQ and groping, summed up the following characteristics:

1, the window starts to glue, detects is the mouse coordinates and the desktop boundary distance, specially, sticks in the following time, detects is with the taskbar distance;

2, when moving up the window, the window boundaries will never exceed the top edge of the desktop;

3, the window is a topmost style;

4, when the window glued to the top, left or right and display, you move the mouse to the top, the cursor changes the size of the window icon, and simply the window top coordinates set to 0 is not;

5, adhesion in the following time, when in a moving state, then the bottom of the window is aligned with the top edge of the taskbar, but from hidden to display, the bottom of the window is aligned with the bottom of the screen;

6, hidden after the exposed line may be a border, but certainly does not contain the client region;

7, on the response to the mouse to enter and move out of the window, is definitely not wm_mousemove, Wm_mouseleave. Proof: You and its slow speed contact with the hidden state of the QQ border, you will find almost "hair-trigger", you and its slow speed to move out of the display status of QQ, you will find that its contraction is not "hair-trigger", but from the edge of 10 pixels or so. And Wm_mousemove,wm_mouseleave, only in the entry, move out of the client area to respond, obviously and QQ different, in fact, from the 6th also can know;

8, adhesion on both sides of the time, the height will be adjusted to the desktop edge to the task bar under the edge of the distance;

9. In the "Show window content while dragging" mode (desktop properties-appearance-effect), adhesion on both sides of the drag out; if the height before the contraction than the smaller then back to the original height, when not the "Drag display window Content" mode, the grating will revert to the original height, but the left button, height is the height of the adjustment after the contraction , at first I thought it was a bug, but when I wrote this problem, I found that these two patterns could affect the meaning of wm_moving parameters;

10, adhesion on both sides when you set the taskbar automatically hidden, the QQ window will automatically adjust height full screen height;

11, window display or hide is not an instant, this point in the 9th mentioned two modes, will be different;

12, the task bar does not show QQ window;

Second, write code

After the observation, we began to write.

First create a new MFC program based on the dialog box, named Qqhidewnd, in the dialog box properties of the Styles page border to resizing, you can also entended styles window hook on the tool, For this I have been dynamically modified in the program.

Add the following member functions to the QQHideWndDlg.h header file:

protected:
//修正移动时窗口的大小
void FixMoving(UINT fwSide, LPRECT pRect);
//从收缩状态显示窗口
void DoShow();
//从显示状态收缩窗口
void DoHide();
//重载函数,只是为了方便调用,实际调用CWnd的SetWindowPos(…)
BOOL SetWindowPos(const CWnd* pWndInsertAfter,LPCRECT pCRect, UINT nFlags = SWP_SHOWWINDOW);
      

Continue adding member variables:

private::
BOOL m_isSizeChanged;//窗口大小是否改变了
BOOL m_isSetTimer;//是否设置了检测鼠标的Timer
INTm_oldWndHeight;//旧的窗口宽度
INTm_taskBarHeight;//任务栏高度
INTm_edgeHeight;//边缘高度
INTm_edgeWidth;//边缘宽度
INTm_hideMode;//隐藏模式
BOOL m_hsFinished;//隐藏或显示过程是否完成
BOOL m_hiding;//该参数只有在!m_hsFinished才有效
//真:正在隐藏,假:正在显示

To increase the message response, note that there are some messages you can only see by setting the Filter for message in the lower right corner to window.

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.