示例#1
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevhInstance, LPSTR lpCmdLime, int nCmdShow)
{

	LPCSTR ClassName = _T("MainWindowClass");
	LPCSTR WindowTitle = _T("Hello");

	hInst = hInstance;

	if (RegisterWindowsClass(hInstance, WndProc, ClassName))
	{
		return 1;
	}

	HWND hWnd = CreateWindow(
		ClassName,
		WindowTitle,
		WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL,
		CW_USEDEFAULT,
		0,
		CW_USEDEFAULT,
		0,
		NULL,
		NULL,
		hInstance,
		NULL
		);

	if (!hWnd)
	{
		MessageBox(NULL,
			_T("Call to CreateWindow failed!"),
			_T("Win32 Guided Tour"),
			NULL);

		return 1;
	}

	ShowWindow(hWnd, nCmdShow);

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

  return (int) msg.wParam;
}
示例#2
0
文件: main.c 项目: ozgend/hive
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
					PSTR szCmdLine, int iCmdShow)
	{
		HWND		 hwnd ;
		MSG			 msg ;
		WNDCLASSEX	 wndclass ;
		BioAPI_RETURN bioReturn;
		BioAPI_VERSION bioVersion;
		BioAPI_BSP_SCHEMA * BspSchemaArray;
		BioAPI_BSP_SCHEMA * CurrSchema;
		int index;
		uint32 ArraySize, ElementsNeeded, NumElementsReturned, i;

		RegisterWindowsClass(hInstance, &wndclass);

		bioVersion.Major = BioAPI_MAJOR;
		bioVersion.Minor = BioAPI_MINOR;
		bioReturn = BioAPI_Init(&bioVersion, 0, NULL, 0, NULL);
		if(BioAPI_OK != bioReturn)
			{
				if(BioAPIERR_H_FRAMEWORK_INCOMPATIBLE_VERSION == bioReturn)
					{
						MessageBox(GetActiveWindow(),
							TEXT("This application is not compatible with the installed version of the BioAPI"),
								TEXT("BioAPI Error"),
									MB_OK | MB_ICONSTOP);
					}
				else
					{
						PrintErrorCode(bioReturn);
					}
				return 0;

			}
		gModuleHandle = 0;
		hwnd = CreateDialog (hInstance, szAppName, 0, NULL) ;

		ShowWindow (hwnd, iCmdShow) ;

		EnumChildWindows(hwnd, EnumChildProc, IDC_USERID);
		hUserId = g_hWnd;
		EnumChildWindows(hwnd, EnumChildProc, IDC_BIOTECH);
		hEnumTech = g_hWnd;
		EnumChildWindows(hwnd, EnumChildProc, IDC_CURRENTHBT);
		hCurrHbt = g_hWnd;

		bioReturn = BioAPI_EnumModules(NULL,
									0,
									&ElementsNeeded,
									&NumElementsReturned);

		if(bioReturn != BioAPI_OK)
			{
				PrintErrorCode(bioReturn);
				return 0;
			}
		ArraySize = ElementsNeeded;
		BspSchemaArray = (BioAPI_BSP_SCHEMA *)malloc(ElementsNeeded * sizeof(BioAPI_BSP_SCHEMA));
		if(BspSchemaArray == NULL)
		{
			MessageBox(GetActiveWindow(), TEXT("Unable to allocate BSP list"),
									TEXT("BioAPI Sample"), MB_OK);
			return 0;
		}
		bioReturn = BioAPI_EnumModules(BspSchemaArray,
									ArraySize,
									&ElementsNeeded,
									&NumElementsReturned);
		if(bioReturn != BioAPI_OK)
			{
				PrintErrorCode(bioReturn);
				free(BspSchemaArray);
				return 0;
			}
		CurrSchema = BspSchemaArray;
		for(i = 0; i < NumElementsReturned; i ++)
			{
				index = SendMessage(hEnumTech, CB_ADDSTRING, (WPARAM)0, (LPARAM)(CurrSchema->Description));
				SendMessage(hEnumTech, CB_SETITEMDATA, (WPARAM)index, (LPARAM)CurrSchema);
				CurrSchema ++;
			}

		 while (GetMessage (&msg, NULL, 0, 0))
			{
				TranslateMessage (&msg) ;
				DispatchMessage (&msg) ;
			}
		 free(BspSchemaArray);
		 BioAPI_Terminate();
		 return msg.wParam ;
	}