The application of object-oriented technology in SDK

Source: Internet
Author: User
Tags win32

This time, write this article, or repeat my two writing style, (data structure article "Old song again, use SDK to implement Maze algorithm", Algorithm, "Old song again, using the SDK to achieve Gobang"), and now this is the object-oriented technology, of course, the same old song revisited! However, we are using object-oriented technology to achieve the development of Windows SDK, for just beginning to learn the Win32 SDK Vckbase friends, you can certainly benefit from this!

This time, I will use object-oriented technology to implement the Windows window encapsulation!

When you start to write the SDK program, you need to write repetitive code, register the window class (Registerwindow), create a window (CreateWindow), enter the message loop, and then constantly add message handlers based on the message type! The solution is copy. and Paste, but also have a lot of inconvenience, for example, I do not want this window to use this class name, I do not want this window to handle this message, ah, this message processing and forgot to add, really, add to where, code dense ... When the framework (MFC,OWL,VCL,WTL,QT ...) appear, this is to get rid of these trouble things, at that time, I know the framework, do not want to go back to the development of the SDK!

Having a framework does not mean that you do not need SDK programming. The framework encapsulates these basic, repetitive developments with object-oriented technology (and provides developers with more convenience, faster, and stronger development), so this time we're going to use an object-oriented approach to the SDK encapsulation, of course, is to demonstrate simple encapsulation and common applications, so that beginners Win32 SDK developers to the use of object-oriented technology has a understanding, OK, we started!

The first step, we want to encapsulate what, to find the encapsulated Object! (Create Class)

The second step is to determine the characteristics of the packaging objects, features! Property

The third step, determine the behavior characteristics of the object, what action! Method

The basic object of the Win32 SDK is the window, so this time we are sure to encapsulate a basic window class, the second step, the characteristics of the window class (this difficult, the need for it) this demo program is a window program, so this program is characterized by a handle (program HINSTANCE, HWND), required for the presence of the window (Wndcls, class name ...), and the last, of course, is the function of the window to process various messages (when needed, the virtual function appears here)

Well, first look at the classes we have designed according to these three steps!

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.