Drawing of special-shaped windows in Qt (winevent processing wm_nchittest messages)

Source: Internet
Author: User

What is discussed here is the implementation on the Windows platform.
In QT to draw the special-shaped window, as long as set windowflag for Customizewindowhint, and then combined with setmask () can make a variety of grotesque window. Relatively troublesome is the processing of window dragging and zooming.
In the Windows SDK and MFC is relatively easy, as long as the processing of wm_nchittest, the corresponding test values can be returned. Fortunately, QT also provides a way to directly process each platform message, and in Windows you only need to overload the WinEvent method.

The sample code is given below:

//include <windows.h>BOOLMydialog::winevent (msg* MSG,Long*result) {    Const intCaptionHeight = -; Const intFramewidth =6; if(Msg->message! = wm_nchittest)return false; Qpoint POS=Mapfromglobal (qcursor::p OS ()); intW =width (); inth =height (); if(Qrect (Framewidth, CaptionHeight, W-framewidth-framewidth, h-captionheight-framewidth). Contains (POS)) {*result =htclient; }    Else if(Qrect (0,0, W, CaptionHeight). Contains (POS)) {*result =htcaption; }    Else if(Qrect (0, CaptionHeight, Framewidth, h-captionheight-framewidth). Contains (POS)) {*result =Htleft; }    Else if(Qrect (W-framewidth, CaptionHeight, Framewidth, h-captionheight-framewidth). Contains (POS)) {*result =Htright; }     Else if(Qrect (Framewidth, H-framewidth, w-framewidth-framewidth, Framewidth). Contains (POS)) {*result =Htbottom; }     Else if(Qrect (0, H-framewidth, Framewidth, Framewidth). Contains (POS)) {*result =Htbottomleft; }    Else if(Qrect (W-framewidth, Hframewidth, Framewidth, Framewidth). Contains (POS)) {*result =Htbottomright; }        return true;}

Reference: http://www.cppblog.com/eXile/archive/2007/12/09/38084.html

Drawing of special-shaped windows in Qt (winevent processing wm_nchittest messages)

Related Article

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.