📄 在屏幕顶端显示电量和内存用量(页 1) - 手机软件开发 - windows mobile开发 - 数字论坛 - powered by discuz! archiver.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0045)http://www.diclife.com/archiver/?tid-325.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>在屏幕顶端显示电量和内存用量(页 1) - 手机软件开发 - Windows Mobile开发 - 数字论坛 - Powered by Discuz! Archiver</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="Discuz!,Board,Comsenz,forums,bulletin board," name=keywords>
<META
content="[size=12px]这段代码出处忘了,就是在屏幕顶端显示电量和内存用量/ mybatt.cpp : Defines the entry point for the application.//#include "
name=description Archiver? Discuz! - 数字论坛 ... HINSTANCE WinMain( WINAPI
stdafx.h?int>
<META content="MSHTML 6.00.2900.3157" name=GENERATOR>
<META content="Discuz! Team & Comsenz UI Team" name=author>
<META content="2001-2007 Comsenz Inc." name=copyright><LINK
href="在屏幕顶端显示电量和内存用量(页 1) - 手机软件开发 - Windows Mobile开发 - 数字论坛 - Powered by Discuz! Archiver.files/style_1.css"
type=text/css rel=stylesheet>
<STYLE type=text/css></STYLE>
</HEAD>
<BODY class=archiver>
<DIV class=archiver_banner><A href="http://www.tang300.com/" target=_blank><IMG
alt=唐300
src="在屏幕顶端显示电量和内存用量(页 1) - 手机软件开发 - Windows Mobile开发 - 数字论坛 - Powered by Discuz! Archiver.files/tang300.jpg"
vspace=5 border=0></A> </DIV>
<DIV class=wrap>
<DIV id=nav><A href="http://www.diclife.com/archiver/">数字论坛</A> » <A
href="http://www.diclife.com/archiver/?fid-19.html">手机软件开发</A> <B>»</B> <A
href="http://www.diclife.com/archiver/?fid-14.html">Windows Mobile开发</A> »
在屏幕顶端显示电量和内存用量</DIV>
<H1><A href="http://www.diclife.com/viewthread.php?tid=325"
target=_blank>查看完整版本: 在屏幕顶端显示电量和内存用量</A></H1>
<DIV class=archiver_post>
<P><CITE>leo</CITE> 2007-3-21 00:01</P>
<DIV class=archiver_postbody>
<H2>在屏幕顶端显示电量和内存用量</H2>[size=12px]这段代码出处忘了,就是在屏幕顶端显示电量和内存用量<BR><BR>/ mybatt.cpp
: Defines the entry point for the application.<BR>//<BR><BR>#include
"stdafx.h"<BR><BR>int WINAPI WinMain( HINSTANCE hInstance,
<BR> HINSTANCE
hPrevInstance, <BR>
LPTSTR lpCmdLine, <BR>
int nCmdShow) <BR>{
<BR> // TODO: Place code here. <BR>
SYSTEM_POWER_STATUS_EX pst; <BR> int i,cx,dx,ex,top,c;
<BR> HDC hdc = ::GetDC(NULL); <BR> <BR>
HPEN pe,pb,po,pm; <BR><BR> pe =
CreatePen(PS_SOLID,2,RGB(50,200,50)); <BR> pm =
CreatePen(PS_SOLID,2,RGB(250,150,50)); <BR> pb =
CreatePen(PS_SOLID,2,RGB(80,80,80)); <BR> i=30; <BR> top
= 1; <BR> c=0; <BR><BR> <BR> while(1)
<BR> { <BR> <BR>
i++; <BR> if(i>15){ <BR>
i=0; <BR>
GetSystemPowerStatusEx(&pst,true); <BR>
if (pst.ACLineStatus==1) <BR>
{ <BR>
pst.BatteryLifePercent=c; <BR>
c+=25;if(c>100)c=0; <BR>
} <BR> cx =
GetSystemMetrics(SM_CXSCREEN) / 2; <BR> dx
= (int)(cx * pst.BatteryLifePercent / 100.0); <BR><BR>
STORE_INFORMATION ss; <BR>
GetStoreInformation(&ss); <BR>
<BR> MEMORYSTATUS ms; <BR>
GlobalMemoryStatus(&ms); <BR>
<BR>
float mfree; <BR> mfree =
1.0f/(ss.dwStoreSize+ms.dwTotalPhys)*(ss.dwFreeSize+ms.dwAvailPhys) ;//+
ms.dwMemoryLoad) / 2; <BR> <BR>
ex = (int)(cx * mfree); <BR>
<BR><BR> } <BR>
<BR><BR> MoveToEx(hdc,0,top,NULL);
<BR><BR> po = (HPEN)SelectObject(hdc,pe); <BR>
LineTo(hdc,dx,top); <BR><BR>
SelectObject(hdc,pb); <BR> LineTo(hdc,cx,top);
<BR><BR> SelectObject(hdc,pm); <BR>
LineTo(hdc,ex +cx,top); <BR><BR>
SelectObject(hdc,pb); <BR> LineTo(hdc,cx*2,top);
<BR><BR><BR> SelectObject(hdc,po); <BR>
Sleep(100); <BR> } <BR><BR>
DeleteObject(pe); <BR> DeleteObject(pm); <BR>
DeleteObject(pb); <BR><BR> ::ReleaseDC(NULL, hdc); <BR>
return 0; <BR>}[/size]</DIV></DIV>
<DIV class=archiver_pages>页: <STRONG>[1]</STRONG> </DIV>
<DIV class=archiver_fullversion>查看完整版本: <STRONG><A
href="http://www.diclife.com/viewthread.php?tid=325"
target=_blank>在屏幕顶端显示电量和内存用量</A></STRONG></DIV></DIV>
<P id=copyright>Powered by <STRONG><A href="http://www.discuz.net/"
target=_blank>Discuz! Archiver</A></STRONG> <EM>6.0.0</EM> © 2001-2006 <A
href="http://www.comsenz.com/" target=_blank>Comsenz
Inc.</A><BR><BR></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -