⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windows.cpp

📁 2002年
💻 CPP
字号:
#ifdef WIN32

#include "client.h"
#include "resource.h"
#include "clientparam.h"

HINSTANCE hInst;
TEXTMETRIC  tm ;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

HWND hWND;				//Handle of Windows

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{	


/*      analyze commandline      */
	int MaxString = 128;
	int argc = 0, is_spaceregion = 1, scount;
	char** argv = new char*[MaxString];
	argv[argc] = new char[MaxString];
	strcpy(argv[argc],"win");
	char* lpstr = lpCmdLine;
	while(*lpstr != 0){
		if (is_spaceregion){
			if (*lpstr != ' '){
				argc++;
				argv[argc] = new char[MaxString];
				argv[argc][0] = *lpstr;
				scount = 1;
				is_spaceregion = 0;
			}
		}
		else{
			if(*lpstr == ' '){
				argv[argc][scount] = 0;
				is_spaceregion = 1;
			}
			else{
				argv[argc][scount] = *lpstr;
				scount ++;
			}
		}
		lpstr++;	
	}
	if (*lpCmdLine != NULL){
		argv[argc][scount] = 0;
		argc ++;
	}

	GetOptions(argc,argv); // Get Options from commandline
	int i;
	for(i=0; i<argc; i++) delete argv[i];
	delete argv;
/*************************************/

	char* szAppName = ClientParam::appname;
	HWND        hwnd ;
	MSG         msg ;
	WNDCLASSEX  wndclass ;
	hInst=hInstance;
	wndclass.cbSize        = sizeof (wndclass) ;
	wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
	wndclass.lpfnWndProc   = WndProc ;
	wndclass.cbClsExtra    = 0 ;
	wndclass.cbWndExtra    = 0 ;
	wndclass.hInstance     = hInstance ;
	wndclass.hIcon         = LoadIcon(hInstance, (LPCTSTR)IDI_ICON);
	wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
	wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
	wndclass.lpszMenuName  = NULL ;
	wndclass.lpszClassName = szAppName;
	wndclass.hIconSm       = LoadIcon(hInstance, (LPCTSTR)IDI_ICON);
	RegisterClassEx (&wndclass) ;

	hwnd = CreateWindow (szAppName,szAppName,
						  WS_OVERLAPPED | WS_SYSMENU | WS_BORDER | WS_MINIMIZEBOX,
						  CW_USEDEFAULT, CW_USEDEFAULT,
						  CW_USEDEFAULT, CW_USEDEFAULT,
						  NULL, NULL, hInstance, NULL) ;
	ShowWindow (hwnd, SW_MINIMIZE);
	UpdateWindow (hwnd) ;

	HDC hdc = GetDC (hwnd);
	GetTextMetrics (hdc, &tm);
	ReleaseDC(hwnd, hdc);

	hWND = hwnd;

	/* Here is the interface of the Application */
#ifndef _OffClient
	if (!InitInstance()){		
		destruction();
		PostQuitMessage(0);
	}
#else
	if (!InitInstance_E()){
		destruction_E();
		PostQuitMessage(0);
	}
#endif

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

	return msg.wParam ;
}

/*    scrollable output       */

int tlines;
int str_begin;
/************* for display  **************/
extern char error[CP_MaxLines][8096];
extern int current;
extern int lines;

//Client Window Refresh
void Refresh(HDC hdc){
	if (current == -1) return;
	tlines = lines;
	str_begin = 0;
	if (lines == ClientParam::MaxLines) 
		str_begin = (current + 1) % ClientParam::MaxLines;
	int i;
	for(i=0; i<tlines; i++){
		TextOut(hdc, 0, i*tm.tmHeight, error[(str_begin+i)%ClientParam::MaxLines], ClientParam::MaxRows);
	}
}

/****************************************************************/
//Client Window Event Handling Thread
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message) 
	{
		case WM_COMMAND:
			break;
		case TEXT_OUT:
			hdc=GetDC(hWnd);
			Refresh(hdc);
			ReleaseDC(hWnd,hdc);
			break;
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &ps);
			SendMessage(hWnd,TEXT_OUT,0,0);
			RECT rt;
			GetClientRect(hWnd, &rt);
			EndPaint(hWnd, &ps);
			break;
		case WM_DESTROY:
#ifndef _OffClient
			destruction();
#else
			destruction_E();
#endif
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -