Make your Software interface more beautiful (3)

Source: Internet
Author: User

To achieve a satisfactory style of the unified software interface is really difficult, like the user mentioned MessageBox, FileDialog, FontDialog, Directory selection dialog box, such as MFC internal and even the System DLL dialog box, to make it difficult to face. Some people say that hook technology can be, hook technology can be, hook can be said to be all-pervasive, but the use of hooks is not satisfactory, from the current use of most of the technology of the skin-changing software, it can prove this point. Today we are going to discuss another technique to achieve FileDialog's face, which is called the replacement window process method (Note: I fabricate).

Window procedure functions are available in most windows, and it handles every event in the window (including child windows). The replacement window process method is better than the hook technology who is weak is very obvious, because the same hook can only intercept an event, processing is quite time-consuming, hook also has its advantages, but it is not to be discussed in this article. Here first let everyone see the real, please look at the following figure:

One, principle explanation:

The window procedure to replace the dialog box uses this function SetWindowLong () its prototype is as follows:

LONG SetWindowLong(HWND hWnd, int nIndex , long dwLongNewProc)
hWnd为指定窗口的句柄,
nIndex 为 GWL_WNDPROC时才可设定新的窗口过程
dwLongNewProc 为指定新的窗口过程函数地址

The back value is a long value, which is the old window procedure function address.

If you want to replace a window's window procedure function, you first have to think about the handle to its window, and of course the window process.

Second, CFileDialog file dialog box interface design

A. Cmyfiledialog from CFileDialog derived classes;

B. Add protected-type virtual member functions: Oninitdone ();

This letter is actually CFileDialog a virtual function, it is called after the file dialog box is created, it leaves us an entrance, because some overloaded reality replaces its window process function;

C. Add member functions Mywindowprocnew ()

static LRESULT CALLBACK WindowProcNew(HWND hwnd,
                   UINT message,
                   WPARAM wParam,
                   LPARAM lParam);

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.