用VC++ api函数给媳妇写了一个2010司法考试倒计时源码
来源:互联网 发布:mac app store 更新 编辑:程序博客网 时间:2024/05/01 04:38
整个源码是在系统自建hello程序的基础上修改来的。
// tesf.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include <Afxwin.h>
#include <stdlib.h>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
CTime wnow;
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
long sifatima();
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESF);
// wnow=CTime::GetCurrentTime();
// unsigned t1=(unsigned)((60-wnow.GetSecond())*1000);
SetTimer(NULL,1,100,NULL);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SMALL);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "szWindowClass";
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow("szWindowClass", szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, 400, 300, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
//SetTimer(hWnd,NULL,t1,NULL);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING],szST[MAX_LOADSTRING];
RECT rt,rt1,rt2,rt3;
int sifat=(int)sifatima();
CString sstr;
sstr.Format("距离司法考试还剩下%d天,请抓紧时间应考",sifat);
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
LoadString(hInst, IDS_STIM, szST, MAX_LOADSTRING);
CString csr;
// szHello=szHello+jili;
switch (message)
{
case WM_CREATE:
SetTimer(hWnd,1,10000,NULL);
break;
case WM_TIMER:
KillTimer(hWnd,1);
InvalidateRect(hWnd,NULL,TRUE);
UpdateWindow(hWnd);
break;
case WM_PAINT:
wnow=CTime::GetCurrentTime();
csr.Format("现在是%4d年%2d月%2d日%2d点%2d分",wnow.GetYear(),wnow.GetMonth(),wnow.GetDay(),wnow.GetHour(),wnow.GetMinute());
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
GetClientRect(hWnd, &rt);
rt1=rt;
rt2=rt;
rt3=rt;
rt1.top=rt.top+30;
rt2.top=rt1.top+30;
rt3.top=rt2.top+30;
DrawText(hdc, csr, strlen(csr), &rt, DT_CENTER);
DrawText(hdc, szST, strlen(szST), &rt1, DT_CENTER);
DrawText(hdc, szHello, strlen(szHello), &rt2, DT_CENTER);
DrawText(hdc, sstr, strlen(sstr), &rt3, DT_CENTER);
EndPaint(hWnd, &ps);
SetTimer(hWnd,1,1000,NULL);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
long sifatima()
{
CTime now=CTime::GetCurrentTime();
CTime sifa(2010,9,11,9,0,0,-1);
CTimeSpan difs;
time_t tnow,tsifa,tdif;
long diffl;
tnow=now.GetTime();
tsifa=sifa.GetTime();
tdif=tsifa-tnow;
difs=CTimeSpan(tdif);
diffl=difs.GetDays();
return diffl;
}
- 用VC++ api函数给媳妇写了一个2010司法考试倒计时源码
- 一个男人为他媳妇写的,看了特感动!
- 一个男人为他媳妇写的,看了特感动!
- 司法考试起航了
- 用VC写了一个bmp图片压缩小程序
- NSTimer写一个倒计时
- 写了一个通用的查询Sql的函数 ----VC新手
- 写了一个很简单API串口编程的源代码,调试通过,希望给需要的人有所帮助
- 一个倒计时的小程序,模拟了leftPad函数
- ~~给儿子找媳妇
- 给媳妇看
- 用VS2010写了一个串口示例程序(使用API写的)----lindabell@欧海
- 一个设定打印走向的函数,别人写的,借花献佛,同时没找哪个API是函数用的,都复制下来了
- 用VC写DLL给PB调用
- 用Python写了一个postgresql函数,感觉很爽
- 用js写了一个判断矩形相交的函数
- 使用js写一个倒计时
- 给用C++写的dll写一个接口函数供C#使用
- BOSS
- 语义web与本体经典论文
- 删除页码和从第三页开始有页码
- Linux 学习笔记3: 重装 及 安装chrome
- Word插入目录
- 用VC++ api函数给媳妇写了一个2010司法考试倒计时源码
- u盘插入时会自动打开所有文件夹
- 【原创】Android中ImageButton自定义按钮的按下效果的代码实现方法,附网上2种经典解决方法。
- 本体的构建工具!
- 悲痛
- 科研经验
- java中HashCode的使用
- d3d实现一个旋转的三菱椎
- cidaemon.exe是什么进程及如何关闭cidaemon.exe进程