After explaining the message allocation mechanism, let's begin by introducing the Winx window class. In order to have a comparative effect, I decided to start with the "SW System" window Class I wrote earlier. After you understand the Windows class of the SW system, let's look at what happened to the design of the window class in Winx 6 years later. This is also my personal change in the concept of the window class.
1, SW system of "hello,world!" Program
#define Uses_SApp
#include <sw.h>
// SW系统中,你需要记住头文件只有
,它是SW系统总控文件。
// 你只需要告诉它,你用了什么,它可以为你检测需要的头文件并包含它们。
// 例如,这里我们用了SApp类,故有 #define Uses_SApp 一句。
class SHelloApp : public SApp
{
public:
void OnDraw(SHDC dc);
};
void SHelloApp::OnDraw(SHDC dc)
{
dc.TextOut(1, 1, _T(“Hello, World!”));
}
// SW系统没有封装WinMain函数,这应该是一个好消息吧?
// 你不必对主函数是main()而非是WinMain太过关心。它只是为了与DOS
// 习惯兼容以及书写的方便而实现的宏而已。
int main()
{
return Desktop.Execute(new SHelloApp);
// Desktop就是Windows系统桌面,它是一个特殊的窗口对象。
// 特别注意,SW系统中App类是一个窗口!
}
2, SW System of class system diagram