ABOUT.C
4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*-----------------------------------------------------------------------------
This is a part of the Microsoft Source Code Samples.
Copyright (C) 1995 Microsoft Corporation.
All rights reserved.
This source code is only intended as a supplement to
Microsoft Development Tools and/or WinHelp documentation.
See these sources for detailed information regarding the
Microsoft samples programs.
MODULE: About.c
PURPOSE: Implement the About dialog box for the program.
FUNCTIONS:
CmdAbout - 创建About对话框以响应菜单选择
AboutDlgProc - 处理关于对话框的消息
InitAboutDlg - 初始化about对话框控件
-----------------------------------------------------------------------------*/
#include <windows.h>
#include "mttty.h"
/*
仅在此文件中调用的函数原型
*/
BOOL CALLBACK AboutDlgProc( HWND, UINT, WPARAM, LPARAM );
UINT InitAboutDlg( HWND );
/*-----------------------------------------------------------------------------
FUNCTION: CmdAbout( HWND )
参数:
hwnd -窗口的所有者
创建模态About对话框
-----------------------------------------------------------------------------*/
BOOL CmdAbout(HWND hwnd)
{
DialogBox(ghInst, MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
return 0;
}
/*-----------------------------------------------------------------------------
FUNCTION: InitAboutDlg( HWND )
初始化modal About对话框
PARMATETERS:
hDlg - Dialog window handle
设置图标动画计时器和版本信息。
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
UINT InitAboutDlg(HWND hDlg)
{
UINT uTimer;
char * szFormat = "Microsoft Windows %s\r\nVersion %d.%d\r\nBuild %d ";
char szVersion[256];
/*
create timer and set initial icon id
*/
uTimer = SetTimer(hDlg, 1, 100, NULL);
if (uTimer == 0)
ErrorReporter("SetTimer");
wsprintf(szVersion, szFormat,
gOSV.dwPlatformId == VER_PLATFORM_WIN32_NT ? "NT" : "95",
gOSV.dwMajorVersion,
gOSV.dwMinorVersion,
LOWORD( gOSV.dwBuildNumber ) );
if (strlen(gOSV.szCSDVersion))
strcat(szVersion, gOSV.szCSDVersion);
SetDlgItemText(hDlg, IDC_OSVERSIONINFO, szVersion);
return uTimer;
}
/*-----------------------------------------------------------------------------
FUNCTION: AboutDlgProc(HWND, UINT, WPARAM, LPARAM)
关于对话框的对话程序
PARAMETERS:
hdlg 对话框窗口句柄
uMessage 窗口消息
wparam 消息参数(取决于消息值)
lparam 消息参数(取决于消息值)
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
BOOL CALLBACK AboutDlgProc(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
static UINT uTimer;
static WORD wCurrentIconId;
switch(uMessage)
{
case WM_INITDIALOG:
uTimer = InitAboutDlg(hdlg);
wCurrentIconId = IDI_APPICON;
break;
case WM_TIMER:
/*
当计时器停止,然后改变到下一个图标
*/
{
HICON hIcon;
switch(wCurrentIconId)
{
case IDI_APPICON: wCurrentIconId = IDI_APPICON2; break;
case IDI_APPICON2: wCurrentIconId = IDI_APPICON3; break;
case IDI_APPICON3: wCurrentIconId = IDI_APPICON4; break;
case IDI_APPICON4: wCurrentIconId = IDI_APPICON; break;
}
hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(wCurrentIconId));
SendMessage(GetDlgItem(hdlg, IDC_PICTURE), STM_SETICON, (WPARAM) hIcon, 0);
}
break;
case WM_COMMAND:
if (LOWORD(wparam) == IDOK) {
KillTimer(hdlg, uTimer);
EndDialog(hdlg, TRUE);
return TRUE;
}
break;
}
return FALSE;
}