/*++ BUILD Version: 0001 Increment this if a change has global effects
Copyright (c) 2004-2004, 902 Corporation
必须在资源文件里指定class,并把style和caption去掉
//STYLE WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
//CAPTION "Dialog"
CLASS "custom"
对话框的尺寸是实际的两倍(150D == 300W)
Module Name:
main.cpp
Abstract:
create a costom window shape module
Author:
Nescafe(Gu Shengyuan, 20025685)
Modify:
Nescafe(Gu Shengyuan, 20025685)
2004.5.12
Data:
2004.5.2
--*/
#undef WINVER
#define WINVER 0X500
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include "SkinMagicLib.h"
#include "resource.h"
using namespace std;
#pragma comment(lib, "detours.lib")
#pragma comment(lib, "SkinMagicLib.lib")
#pragma comment(lib, "comctl32.lib")
// main callback function
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK AbtProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK AskProc(HWND, UINT, WPARAM, LPARAM);
// unopened api
BOOL Run(HWND hWnd, HICON hIcon, LPWSTR lpstrCmd,
LPWSTR lpstrName, LPWSTR lpstrCue, UINT flag);
BOOL Restart(HWND hWnd, LPCTSTR lpstrName, UINT flag);
DWORD GetWindowsVersion();
// Shutdown the special computer
BOOL Shutdown(char *szName, char *szMessage,
int iTimeOut = 0, BOOL bForce = TRUE, BOOL bShutdown = TRUE);
BOOL ShutdownNT(BOOL shutdown = TRUE);
// golbal variable
TCHAR szAppName[] = TEXT ("unopened") ;
TCHAR szTitle[] = TEXT ("Nescafe's System Dialog") ;
HINSTANCE hInstance;
HWND hWnd;
// winmain
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
WNDCLASSEX wndclass ;
HWND hwnd ;
MSG msg ;
// initialize the global variable
hInstance = hInst ;
// clear the wndclass
memset(&wndclass, 0, sizeof(WNDCLASSEX));
wndclass.cbSize = sizeof(WNDCLASSEX);
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = DLGWINDOWEXTRA ;//note!
wndclass.hInstance = hInstance ;
wndclass.hIcon = NULL ;
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_MENU + 1);
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
wndclass.hIconSm = NULL ;
if (!RegisterClassEx (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
// 参数lpDialogFunc必须是NULL,这样就指定WndProc为它的默认参数了
hwnd = CreateDialog (hInstance, LPSTR(IDD_DIALOG_MAIN), 0, NULL) ;
hWnd = hwnd;
if (!hwnd)
{
MessageBox (NULL, TEXT ("HANDLE create failed!"),szAppName, MB_ICONERROR) ;
return 0 ;
}
// //////////////////////////////////////////////////////////////////////////
// if( 0 == InitSkinMagicLib( hInstance, NULL, NULL, NULL ) )
// {
// cout << "InitSkinMagicLib\n" << endl;
// }
//
// if( 0 == LoadSkinFromResource( hInstance, "SKIN" ,"SKIN") )
// {
// cout << "LoadSkinFromResource\n" << endl;
// }
//
// //////////////////////////////////////////////////////////////////////////
// if( 0 == SetWindowSkin( hWnd, "MainFrame" ))
// {
// cout << "SetWindowSkin\n" << endl;
// }
//
// if( 0 == SetDialogSkin( "Dialog" ) )
// {
// cout << "SetDialogSkin\n" << endl;
// }
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
int main()
{
WinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW);
return 0;
}
LRESULT CALLBACK WndProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc = NULL;
PAINTSTRUCT ps;
static int cxClient, cyClient;
static HWND hComHour, hComMinu;
switch(uMsg)
{
case WM_CREATE:
{
// set the dialog-base window's title
SetWindowText(hWin, szTitle);
// get the window size
RECT rcWnd;
GetWindowRect(hWin, &rcWnd);
// move the window to the screen center
SetWindowPos(hWin, HWND_TOPMOST,
(GetSystemMetrics(SM_CXSCREEN) - rcWnd.right)/2,
(GetSystemMetrics(SM_CYSCREEN) - rcWnd.bottom)/2,
rcWnd.right, rcWnd.bottom, SWP_SHOWWINDOW);
// Handle of the two combo-box
hComHour = CreateWindow("COMBOBOX", NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP |
/*CBS_DROPDOWN | CBS_HASSTRINGS |*/ CBS_DISABLENOSCROLL | CBS_DROPDOWNLIST,
15, 38, 48, 100,
hWin, NULL, hInstance, NULL);
hComMinu = CreateWindow("COMBOBOX", NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP |
/*CBS_DROPDOWN | CBS_HASSTRINGS |*/ CBS_DISABLENOSCROLL | CBS_DROPDOWNLIST,
15, 88, 48, 100,
hWin, NULL, hInstance, NULL);
char szBuffer[8] = "";
for(int i = 0; i <= 23; i++)
{
sprintf(szBuffer, "%02d", i);
SendMessage(HWND(hComHour), CB_ADDSTRING, 0, LPARAM(szBuffer));
}
for( i = 0; i <= 59; i++)
{
sprintf(szBuffer, "%02d", i);
SendMessage(HWND(hComMinu), CB_ADDSTRING, 0, LPARAM(szBuffer));
}
}
break;
case WM_SIZE:
{
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
}
break;
case WM_PAINT:
{
hdc = BeginPaint(hWin, &ps);
EndPaint(hWin, &ps);
}
break;
case WM_COMMAND:
{
switch(wParam)
{
case IDC_BT_RUN:
{
WCHAR szMessage[] = L"Please Input your Program, "
L"Filter, Document or Internet Resource, Windows will open it!";
Run(hWin, NULL, L"ss", L"Run", szMessage, 0x02);
}
break;
case IDC_BT_RESTAR:
{
int iReturn = DialogBox(hInstance, LPSTR(IDD_DIALOG_ASK), hWin, DLGPROC(AskProc));
if(iReturn)
ShutdownNT(TRUE);
}
break;
case IDC_BT_SHUTDOWN:
{
char szMessage[] = "WINDOWS将要关机,请做好保存工作!";
// Get current item
int index = 0;
char szBuffer[8] = "";
index = SendMessage(hComHour, CB_GETCURSEL, 0, 0);
SendMessage(hComHour, CB_GETLBTEXT, index, (LPARAM)szBuffer);
int hour = atoi(szBuffer);
cout << hour << endl;
index = 0;
index = SendMessage(hComMinu, CB_GETCURSEL, 0, 0);
SendMessage(hComMinu, CB_GETLBTEXT, index, (LPARAM)szBuffer);
int minu = atoi(szBuffer);
cout << minu << endl;
tm time;
_getsystime(&time);
int c_hour = time.tm_hour;
int c_minu = time.tm_min;
int TimeOut = (hour * 3600 + minu * 60) - (c_hour * 3600 + c_minu * 60);
TimeOut = (TimeOut > 0) ? TimeOut : 0;
cout << TimeOut << endl;
Shutdown(NULL, szMessage, TimeOut, TRUE, TRUE);
}
break;
case IDC_BT_CANCEL:
{
AbortSystemShutdown(NULL);
}
break;
case IDC_CLOSE:
{
SendMessage(hWin, WM_CLOSE, 0, 0);
}
break;
case IDC_ABOUT:
{
DialogBox(hInstance, LPSTR(IDD_DIALOG_ABOUT), hWin, DLGPROC(AbtProc));
}
break;
}
break;
}
break;
case WM_LBUTTONDOWN:
{
// MAKE OUR WINDOW THINK THAT THE USER MOVES THE CAPTION_BAR
SendMessage(hWin, WM_NCLBUTTONDOWN, HTCAPTION, lParam);
}
break;
case WM_DESTROY:
{
PostQuitMessage(NULL);
}
break;
default:
break;
}
return DefWindowProc(hWin, uMsg, wParam, lParam);
}
LRESULT CALLBACK AbtProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_INITDIALOG:
{
}
return TRUE;
case WM_PAINT:
{
hdc = BeginPaint(hDlg, &ps);
// Blt a bitmap, and cover the bitmap on the face of dialog
HBIT
林当时
- 粉丝: 114
- 资源: 1万+
最新资源
- 基于微信小程序校园外卖系统-数据库课程设计全部资料+详细文档+高分项目.zip
- 基于图书馆系统,swing界面,基本数据库操作全部资料+详细文档+高分项目.zip
- 基于图书管理系统(数据库课程设计,原生PHP+Bootstrap+MySQL)全部资料+详细文档+高分项目.zip
- 基于学生信息管理系统 JAVA Mysql 数据库课程设计 简单界面全部资料+详细文档+高分项目.zip
- 基于学生教务信息管理系统:SQL SERVER数据库课程设计全部资料+详细文档+高分项目.zip
- 2024中国数字化年会演讲(脱敏)PPT汇总(9份).zip
- Java+Swing+Mysql实现图书管理系统.zip
- 充电桩通讯协议 CAN标准帧
- 2024年数据治理产业图谱3.0(高清大图).pdf
- Java+Swing+Mysql实现学生信息管理系统.zip
- 吊篮式油菜移栽机sw16可编辑全套技术资料100%好用.zip
- C3传奇3引擎+版本全套 免费分享
- 123swwdqdsqwdqd
- 钢筋滚丝机sw18可编辑全套技术资料100%好用.zip
- 滚筒线体及托盘下料设备sw17全套技术资料100%好用.zip
- 基于java+ssm+mysql的鲜花商城系统开题报告.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈