Wtl Implementation of AppBar

Source: Internet
Author: User
About docking window Article There are a lot of things, basically speaking about the master Program Docking in the small window of the internal toolbar. Code Is generally complicated. Desktop docking is rare. In fact, since Windows 95, Win32 API provides a function called shappbarmessage, which is used to implement the function equivalent to Windows Task Bar. That is, you can dock the screen on any side and exclude yourself from the desktop space. When other application windows are maximized, the task bar space is not occupied. At the same time, it can be set to automatically hide to allow all desktop spaces. Such a window is called An appbar.

Programs such as QQ can be docked on one side of the window or automatically hidden, but it seems that there are still many gaps with AppBar behavior. This article provides an implementation of the standard AppBar.

Using the shappbarmessage function to implement An appbar is not difficult. This article describes almost all the implementation details, but the example provided is SDK-style code, which has little practical value. However, the SDK documentation is a good supplement, and many questions that are not clearly stated in the SDK are explained in the article.

Another problem is that the shappbarmessage function does not provide the functions that I think should be implemented. For example, the support for dragging, for example, the function of hiding and appearing an automatic hidden window must be implemented with additional code. The main work done by the shappbarmessage function seems to be dividing the screen so that other windows do not occupy the AppBar space. Of course, it is enough to achieve this. After all, other functions can be implemented without the shappbarmessage function, and I don't know how to implement this screen division function.

The desire to write a reusable AppBar base class immediately appeared in my mind. Due to its ultra-low coupling, wtl has become an inevitable choice. The template class cappbar <t> is the result of the work. This class is not only a simple encapsulation of the shappbarmessage function, but also provides the function to dock or exit from the screen by dragging, and provides automatic hiding.

Cappbar can be used for any pop-up window class directly or indirectly inherited from cwindowimpl. The method is simple:
1. inherit from cappbar as a parent class
2. Use chain_msg_map to pass the message to cappbar
3. Call the initappbar function when creating a window. The parameter is optional.
In this way, the window has the AppBar function, and you can drag it to the edge of the screen.
Of course, you can call dockappbar to dock or detach, or call setautohide to change the automatically hidden settings.
If special operations are required when the dock status changes, you can reload the ondockingchanged function.

Basically, the code is very simple, just like other wtl classes. We hope that the next version of wtl can include it.

Download the example Program

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.