www.pudn.com > awlogin.rar > awlogin.cpp


#include  
CComModule			_Module; 
#include  
#include 	 
#pragma comment(lib,"atl") 
#include "awlogin.h" 
 
 
TCHAR				szMsg[128],szTitle[16],CurrentDir[261]; 
 
HWND				hwnd,hwndINFOSEC,hwndINFOGRO,hwndOK,hwndCONFIG, 
					hwndCANCEL,hwndCANCELMIN,hwndSEC,hwndGRO; 
 
HINSTANCE			hInstance; 
 
COLORREF			backcolor = RGB(255,255,255), 
					textcolor = RGB(0,0,0), 
					currentcolor = RGB(0,0,0); 
 
HFONT				currentfont; 
 
HDC					hdc,hdcmemok; 
 
HBITMAP				hBitmap; 
 
LOGBRUSH			logbrush; 
HBRUSH				hbrush; 
 
CAxWindow			WinContainer; 
IWebBrowser2*		WebBrowser; 
VARIANT				varMyURL; 
 
int APIENTRY WinMain(HINSTANCE hInstance, 
                     HINSTANCE hPrevInstance, 
                     LPSTR     lpCmdLine, 
                     int       nCmdShow) 
{ 
//初始化程序环境 
	LoadString(hInstance, IDS_PROGRAM_QUIT, szMsg, sizeof(szMsg)); 
	LoadString(hInstance, IDS_PROGRAM_TITLE, szTitle, sizeof(szTitle)); 
	GetCurrentDirectory(MAX_PATH,CurrentDir); 
	strcat(CurrentDir,"\\"); 
	strcat(CurrentDir,FILENAME); 
WNDCLASS     wndclass ; 
	CoInitialize(NULL); 
	AtlAxWinInit(); 
//窗口类 
     MSG          msg ; 
      
     wndclass.style         = CS_HREDRAW | CS_VREDRAW ; 
     wndclass.lpfnWndProc   = WndProc ; 
     wndclass.cbClsExtra    = 0 ; 
     wndclass.cbWndExtra    = 0 ; 
     wndclass.hInstance     = hInstance ; 
     wndclass.hIcon         = LoadIcon((HINSTANCE)hInstance, MAKEINTRESOURCE(IDI_MIR)) ; 
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ; 
     wndclass.hbrBackground = CreatePatternBrush(LoadBitmap (hInstance, MAKEINTRESOURCE(IDB_FORM))); 
     wndclass.lpszMenuName  = NULL ; 
     wndclass.lpszClassName = szTitle ; 
      
     if (!RegisterClass (&wndclass)) 
     { 
          MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
                      szTitle, MB_ICONERROR) ; 
          return 0 ; 
     } 
      
     hwnd = CreateWindow (szTitle,  
							szTitle,  
							WS_POPUP|WS_SYSMENU,  
							(GetSystemMetrics(SM_CXSCREEN)-365)/2, 
							(GetSystemMetrics(SM_CYSCREEN)-398)/2, 
							365, 
							398, 
							NULL,  
							NULL, 
							hInstance, 
							NULL) ; 
 
     ShowWindow (hwnd, 1) ; 
     UpdateWindow (hwnd) ; 
 
	 //加载WEBBROWSER控件 
		RECT				rc; 
		rc.top = 44; 
		rc.left = 35; 
		rc.bottom = 222; 
		rc.right = 331; 
		WinContainer.Create(hwnd, rc, LPCTSTR("Microsoft.IExplorer.6"),WS_CHILD|WS_VISIBLE|WS_VSCROLL );//create a browser control 
		WinContainer.QueryControl( __uuidof(IWebBrowser2), (void**)&WebBrowser); 
		VariantInit(&varMyURL); 
		varMyURL.vt = VT_BSTR; 
	#ifndef UNICODE 
		{ 
			wchar_t  *buffer; 
			DWORD  size; 
			size = MultiByteToWideChar(CP_ACP, 0, "www.awgame.com/swf/awgame.swf", -1, 0, 0); 
			if (!(buffer = (wchar_t *)GlobalAlloc(GMEM_FIXED, sizeof(wchar_t) * size))) return FALSE; 
			MultiByteToWideChar(CP_ACP, 0, "www.awgame.com/swf/awgame.swf", -1, buffer, size); 
			varMyURL.bstrVal = SysAllocString(buffer); 
			GlobalFree(buffer); 
		} 
	#else 
		varMyURL.bstrVal = SysAllocString("www.awgame.com/swf/awgame.swf"); 
	#endif 
		WebBrowser->Navigate2(&varMyURL, 0, 0, 0, 0); 
		VariantClear(&varMyURL); 
		WebBrowser->Release(); 
 
     while (GetMessage (&msg, NULL, 0, 0)) 
     { 
          TranslateMessage (&msg) ; 
          DispatchMessage (&msg) ; 
     } 
	 CoUninitialize(); 
     return msg.wParam ; 
}