`

sysmets.h

vc 
阅读更多
/*-----------------------------------------------
SYSMETS.H -- System metrics display structure
-----------------------------------------------*/
#include <tchar.h>
#include<windows.h>
//#include "stdafx.h"
#define NUMLINES ((int) (sizeof sysmetrics / sizeof sysmetrics [0]))

struct
{
	int     iIndex;
	TCHAR * szLabel;
	TCHAR * szDesc;
}
sysmetrics[] =
{
	SM_CXSCREEN, TEXT("SM_CXSCREEN"),
	TEXT("Screen width in pixels"),
	SM_CYSCREEN, TEXT("SM_CYSCREEN"),
	TEXT("Screen height in pixels"),
	SM_CXVSCROLL, TEXT("SM_CXVSCROLL"),
	TEXT("Vertical scroll width"),
	SM_CYHSCROLL, TEXT("SM_CYHSCROLL"),
	TEXT("Horizontal scroll height"),
	SM_CYCAPTION, TEXT("SM_CYCAPTION"),
	TEXT("Caption bar height"),
	SM_CXBORDER, TEXT("SM_CXBORDER"),
	TEXT("Window border width"),
	SM_CYBORDER, TEXT("SM_CYBORDER"),
	TEXT("Window border height"),
	SM_CXFIXEDFRAME, TEXT("SM_CXFIXEDFRAME"),
	TEXT("Dialog window frame width"),
	SM_CYFIXEDFRAME, TEXT("SM_CYFIXEDFRAME"),
	TEXT("Dialog window frame height"),
	SM_CYVTHUMB, TEXT("SM_CYVTHUMB"),
	TEXT("Vertical scroll thumb height"),
	SM_CXHTHUMB, TEXT("SM_CXHTHUMB"),
	TEXT("Horizontal scroll thumb width"),
	SM_CXICON, TEXT("SM_CXICON"),
	TEXT("Icon width"),
	SM_CYICON, TEXT("SM_CYICON"),
	TEXT("Icon height"),
	SM_CXCURSOR, TEXT("SM_CXCURSOR"),
	TEXT("Cursor width"),
	SM_CYCURSOR, TEXT("SM_CYCURSOR"),
	TEXT("Cursor height"),
	SM_CYMENU, TEXT("SM_CYMENU"),
	TEXT("Menu bar height"),
	SM_CXFULLSCREEN, TEXT("SM_CXFULLSCREEN"),
	TEXT("Full screen client area width"),
	SM_CYFULLSCREEN, TEXT("SM_CYFULLSCREEN"),
	TEXT("Full screen client area height"),
	SM_CYKANJIWINDOW, TEXT("SM_CYKANJIWINDOW"),
	TEXT("Kanji window height"),
	SM_MOUSEPRESENT, TEXT("SM_MOUSEPRESENT"),
	TEXT("Mouse present flag"),
	SM_CYVSCROLL, TEXT("SM_CYVSCROLL"),
	TEXT("Vertical scroll arrow height"),
	SM_CXHSCROLL, TEXT("SM_CXHSCROLL"),
	TEXT("Horizontal scroll arrow width"),
	SM_DEBUG, TEXT("SM_DEBUG"),
	TEXT("Debug version flag"),
	SM_SWAPBUTTON, TEXT("SM_SWAPBUTTON"),
	TEXT("Mouse buttons swapped flag"),
	SM_CXMIN, TEXT("SM_CXMIN"),
	TEXT("Minimum window width"),
	SM_CYMIN, TEXT("SM_CYMIN"),
	TEXT("Minimum window height"),
	SM_CXSIZE, TEXT("SM_CXSIZE"),
	TEXT("Min/Max/Close button width"),
	SM_CYSIZE, TEXT("SM_CYSIZE"),
	TEXT("Min/Max/Close button height"),
	SM_CXSIZEFRAME, TEXT("SM_CXSIZEFRAME"),
	TEXT("Window sizing frame width"),
	SM_CYSIZEFRAME, TEXT("SM_CYSIZEFRAME"),
	TEXT("Window sizing frame height"),
	SM_CXMINTRACK, TEXT("SM_CXMINTRACK"),
	TEXT("Minimum window tracking width"),
	SM_CYMINTRACK, TEXT("SM_CYMINTRACK"),
	TEXT("Minimum window tracking height"),
	SM_CXDOUBLECLK, TEXT("SM_CXDOUBLECLK"),
	TEXT("Double click x tolerance"),
	SM_CYDOUBLECLK, TEXT("SM_CYDOUBLECLK"),
	TEXT("Double click y tolerance"),
	SM_CXICONSPACING, TEXT("SM_CXICONSPACING"),
	TEXT("Horizontal icon spacing"),
	SM_CYICONSPACING, TEXT("SM_CYICONSPACING"),
	TEXT("Vertical icon spacing"),
	SM_MENUDROPALIGNMENT, TEXT("SM_MENUDROPALIGNMENT"),
	TEXT("Left or right menu drop"),
	SM_PENWINDOWS, TEXT("SM_PENWINDOWS"),
	TEXT("Pen extensions installed"),
	SM_DBCSENABLED, TEXT("SM_DBCSENABLED"),
	TEXT("Double-Byte Char Set enabled"),
	SM_CMOUSEBUTTONS, TEXT("SM_CMOUSEBUTTONS"),
	TEXT("Number of mouse buttons"),
	SM_SECURE, TEXT("SM_SECURE"),
	TEXT("Security present flag"),
	SM_CXEDGE, TEXT("SM_CXEDGE"),
	TEXT("3-D border width"),
	SM_CYEDGE, TEXT("SM_CYEDGE"),
	TEXT("3-D border height"),
	SM_CXMINSPACING, TEXT("SM_CXMINSPACING"),
	TEXT("Minimized window spacing width"),
	SM_CYMINSPACING, TEXT("SM_CYMINSPACING"),
	TEXT("Minimized window spacing height"),
	SM_CXSMICON, TEXT("SM_CXSMICON"),
	TEXT("Small icon width"),
	SM_CYSMICON, TEXT("SM_CYSMICON"),
	TEXT("Small icon height"),
	SM_CYSMCAPTION, TEXT("SM_CYSMCAPTION"),
	TEXT("Small caption height"),
	SM_CXSMSIZE, TEXT("SM_CXSMSIZE"),
	TEXT("Small caption button width"),
	SM_CYSMSIZE, TEXT("SM_CYSMSIZE"),
	TEXT("Small caption button height"),
	SM_CXMENUSIZE, TEXT("SM_CXMENUSIZE"),
	TEXT("Menu bar button width"),
	SM_CYMENUSIZE, TEXT("SM_CYMENUSIZE"),
	TEXT("Menu bar button height"),
	SM_ARRANGE, TEXT("SM_ARRANGE"),
	TEXT("How minimized windows arranged"),
	SM_CXMINIMIZED, TEXT("SM_CXMINIMIZED"),
	TEXT("Minimized window width"),
	SM_CYMINIMIZED, TEXT("SM_CYMINIMIZED"),
	TEXT("Minimized window height"),
	SM_CXMAXTRACK, TEXT("SM_CXMAXTRACK"),
	TEXT("Maximum draggable width"),
	SM_CYMAXTRACK, TEXT("SM_CYMAXTRACK"),
	TEXT("Maximum draggable height"),
	SM_CXMAXIMIZED, TEXT("SM_CXMAXIMIZED"),
	TEXT("Width of maximized window"),
	SM_CYMAXIMIZED, TEXT("SM_CYMAXIMIZED"),
	TEXT("Height of maximized window"),
	SM_NETWORK, TEXT("SM_NETWORK"),
	TEXT("Network present flag"),
	SM_CLEANBOOT, TEXT("SM_CLEANBOOT"),
	TEXT("How system was booted"),
	SM_CXDRAG, TEXT("SM_CXDRAG"),
	TEXT("Avoid drag x tolerance"),
	SM_CYDRAG, TEXT("SM_CYDRAG"),
	TEXT("Avoid drag y tolerance"),
	SM_SHOWSOUNDS, TEXT("SM_SHOWSOUNDS"),
	TEXT("Present sounds visually"),
	SM_CXMENUCHECK, TEXT("SM_CXMENUCHECK"),
	TEXT("Menu check-mark width"),
	SM_CYMENUCHECK, TEXT("SM_CYMENUCHECK"),
	TEXT("Menu check-mark height"),
	SM_SLOWMACHINE, TEXT("SM_SLOWMACHINE"),
	TEXT("Slow processor flag"),
	SM_MIDEASTENABLED, TEXT("SM_MIDEASTENABLED"),
	TEXT("Hebrew and Arabic enabled flag"),
	/* SM_MOUSEWHEELPRESENT,    TEXT ("SM_MOUSEWHEELPRESENT"),
	TEXT ("Mouse wheel present flag"),
	SM_XVIRTUALSCREEN,       TEXT ("SM_XVIRTUALSCREEN"),
	TEXT ("Virtual screen x origin"),
	SM_YVIRTUALSCREEN,       TEXT ("SM_YVIRTUALSCREEN"),
	TEXT ("Virtual screen y origin"),
	SM_CXVIRTUALSCREEN,      TEXT ("SM_CXVIRTUALSCREEN"),
	TEXT ("Virtual screen width"),
	SM_CYVIRTUALSCREEN,      TEXT ("SM_CYVIRTUALSCREEN"),
	TEXT ("Virtual screen height"),
	SM_CMONITORS,            TEXT ("SM_CMONITORS"),
	TEXT ("Number of monitors"),
	SM_SAMEDISPLAYFORMAT,    TEXT ("SM_SAMEDISPLAYFORMAT"),
	TEXT ("Same color format flag")*/
};



 

#include<windows.h>
#include"sysmets.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	static TCHAR szAppName [] = TEXT("SYSMETS1");
	HWND hwnd;
	MSG msg;
	WNDCLASS wndclass;

	wndclass.cbClsExtra = 0;
	wndclass.cbWndExtra = 0;
	wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
	wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hInstance = hInstance;
	wndclass.lpfnWndProc = WndProc;
	wndclass.lpszClassName = szAppName;
	wndclass.lpszMenuName = NULL;
	wndclass.style = CS_VREDRAW | CS_HREDRAW;

	if (!RegisterClass(&wndclass))
	{
		MessageBox(NULL, TEXT("Error!!"), TEXT("sysmets1"), MB_ICONERROR);
		return 0;
	}

	hwnd = CreateWindow(szAppName, TEXT("Sysmets1"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT
		, NULL, NULL, hInstance, NULL);

	ShowWindow(hwnd, nShowCmd);
	UpdateWindow(hwnd);

	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	static int cxChar, cyChar, cxCaps;
	HDC hdc;
	int i;
	TCHAR szBuffer[10];
	TEXTMETRIC tm;

	switch (message)
	{
	case WM_CREATE:
		hdc = GetDC(hwnd);

		GetTextMetrics(hdc, &tm);
		cxChar = tm.tmAveCharWidth;
		cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2)*cxChar / 2;
		cyChar = tm.tmHeight + tm.tmExternalLeading;

		ReleaseDC(hwnd, hdc);
		return 0;
	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);

		for (i = 0; i < NUMLINES; i++)
		{
			TextOut(hdc, 0, cyChar*i, sysmetrics[i].szLabel, lstrlen(sysmetrics[i].szLabel));
			TextOut(hdc, 22 * cxCaps, cyChar*i, sysmetrics[i].szDesc, lstrlen(sysmetrics[i].szDesc));
			SetTextAlign(hdc, TA_RIGHT | TA_TOP);
			TextOut(hdc, 22 * cxCaps + 40 * cxChar, cyChar*i, szBuffer, wsprintf(szBuffer, TEXT("%5d"), GetSystemMetrics(sysmetrics[i].iIndex)));
			SetTextAlign(hdc, TA_LEFT | TA_TOP);
		}
		EndPaint(hwnd, &ps);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, message, wParam, lParam);
}

 

分享到:
评论

相关推荐

    sysmets.h 系统所有的参数识别字

    在操作系统和软件开发中,`sysmets.h` 文件通常是一个包含系统度量或系统指标定义的头文件。这个文件中的“系统所有的参数识别字”指的是用于标识和查询系统状态或特性的特定常量或枚举类型。这些识别字允许程序员以...

    SysMets1.zip_zip

    5. SysMets.h:这是一个头文件,很可能包含了C语言中的函数声明和其他预处理指令,可能与SysMets1.c文件紧密关联。 6. SysMets1.mak:这可能是一个Makefile的变体,用于自动化编译过程,通过指定的命令构建项目。 7....

    SysMets4.rar_SYSMETS4

    标题中的"SysMets4.rar_SYSMETS4"暗示我们关注的是一个名为"SysMets4"的软件或系统组件,可能是一个系统管理工具或者一个专门处理滚动条功能的库。"rar"后缀表明这是一个压缩文件,通常用于存储多个相关文件。...

    SysMets1.rar_System Metrics

    《SysMets1.rar——系统度量的C++与MFC实现》 在信息技术领域,系统度量(System Metrics)是指获取操作系统的关键信息,如内存使用情况、CPU占用率、磁盘空间等,这些数据对于系统监控、性能优化以及问题排查至关...

    SysMets1.rar_优化大师

    标题“SysMets1.rar_优化大师”暗示我们讨论的主题是一款名为“SysMets1”的系统优化工具,可能类似于知名的Windows优化大师。Windows优化大师是一款针对Microsoft Windows操作系统设计的综合性系统维护软件,它包含...

    SysMets2.rar_C语言_PV6

    标题 "SysMets2.rar_C语言_PV6" 暗示了这是一个关于C语言编程的项目,可能涉及文件操作和某种特定的编程规范或框架,PV6。在这个项目中,开发者使用C语言来实现一个功能,即在Windows环境下读取文本文件并将其内容...

    SysMets+水平竖直滚动条+功能键

    本文将详细解析"SysMets+水平竖直滚动条+功能键"这一主题,涵盖Windows API、滚动条控件以及功能键的应用。 首先,Windows API是微软提供的用于开发Windows应用程序的函数库,它包含了丰富的函数和结构,使得程序员...

    Windows程序设计读书笔记(合集)

    4. **sysmets.bas**:根据命名推测,这可能是一个处理系统元数据的模块,可能包含了与操作系统交互的函数或过程。 5. **sysmets.jpg**:这是一张图片文件,可能是程序的图标或者是系统元数据相关的示意图。 6. **...

    Windows程序设计 SysMets(源代码).rar

    免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,...

    windows程序设计第四章sysmets3详细解释

    这张图片详细解释《Windows程序设计(第5版珍藏版)》第四章sysymets3,让你彻底理解!你绝对能看懂!!醍醐灌顶!!!!!!

    Windows程序设计 SysMets4(源代码).rar

    免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,...

    Windows程序设计第五版代码_part01.rar

    《Windows程序设计第五版》是一本深入探讨Windows操作系统下程序开发的经典教材,涵盖了从基本的API调用到复杂的系统交互的全面知识。该书的代码部分被分成了四个压缩包,其中"Windows程序设计第五版代码_part01.rar...

    Windows 程序设计(第5版)(上、下册)--详细书签版

    4.3.3 在sysmets中添加滚动功能 4.3.4 绘图程序的组 4.4 建立更好的滚动 4.4.l 滚动条信息函数 4.4.2 滚动范围 4.4.3 新sysmets 4.4. 4 不用鼠标怎么办 第五章 图形基础 5. 1 gdi的结构 5.1. ...

    windows 程序设计中文版

    4.4.3 新的SYSMETS 4.4.4 可我不想用鼠标 第5章 绘图基础 5.1 GDI的结构 5.1.1 GDI原理 5.1.2 GDI函数调用 5.1.3 GDI的基本图形 5.1.4 其他 5.2 设备环境 5.2.1 获取设备环境句柄 5.2.2 获取设备环境的信息 5.2.3 ...

    Windows API学习之滚动条系列函数演示程序

    在提供的压缩包文件"SYSMETS1"中,可能包含了一个或多个示例程序,演示了如何使用上述API函数来实现滚动条功能。通过分析和运行这些示例,开发者可以更直观地理解Windows API滚动条操作的工作原理,从而在自己的项目...

Global site tag (gtag.js) - Google Analytics