コード例 #1
0
/*********************************************************************
*
*       WinMain
*/
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  RECT RectStatus, RectMain;
  DWORD ThreadID;
  MSG   Msg;
  HWND  hWndMain, hWndStatus;
  INITCOMMONCONTROLSEX InitComCTRLEx;
  /* Ensure that the common control DLL is loaded. */
  InitCommonControlsEx(&InitComCTRLEx);
  /* Register window class */
  _RegisterClass(hInstance);
  /* Make sure the driver configuration is done */
  SIM_GUI_Enable();
  /* Create main window */
  hWndMain = CreateWindow("GUIApplication", "Application window",
                          WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE, 
                          0, 0, 
                          320 + GetSystemMetrics(SM_CXSIZEFRAME) * 2, 
                          240 + GetSystemMetrics(SM_CYSIZEFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION), 
                          NULL, NULL, hInstance, NULL);
  /* Create status window */
  hWndStatus = CreateWindow(STATUSCLASSNAME, "Ready window",
                            WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
                            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                            hWndMain, NULL, hInstance, NULL);
  /* Adjust size of main window */
  GetWindowRect(hWndStatus, &RectStatus);
  GetWindowRect(hWndMain,   &RectMain);
  SetWindowPos(hWndMain, 0, 
               RectMain.left, 
               RectMain.top, 
               RectMain.right, 
               RectMain.bottom + (RectStatus.bottom - RectStatus.top), 
               SWP_NOZORDER);
  SetWindowPos(hWndStatus, 0, 
               RectStatus.left, 
               RectStatus.top  + (RectStatus.bottom - RectStatus.top), 
               RectStatus.right, 
               RectStatus.bottom + (RectStatus.bottom - RectStatus.top), 
               SWP_NOZORDER);
  _SetParts(hWndStatus);
  /* Initialize the GUI simulation and create a LCD window */
  SIM_GUI_Init(hInstance, hWndMain, lpCmdLine, "GUI Simulation");
  SIM_GUI_CreateLCDWindow(hWndMain, 0, 0, 320, 240, 0);
  /* Create a thread which executes the code to be simulated */
  CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)_Thread, NULL, 0, &ThreadID);
  /* Main message loop */
  while (GetMessage(&Msg, NULL, 0, 0)) {
    TranslateMessage(&Msg);
    DispatchMessage(&Msg);
  }
  SIM_GUI_Exit();
}
コード例 #2
0
ファイル: gui.c プロジェクト: ctliu3/TicTacToe
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,
                    int cmdShow) {

    static TCHAR szAppName[] = TEXT("SampleSRS");
    
    if (!_RegisterClass(szAppName)) {
        return 1;
    }

    if (!_CreateWindow(szAppName, cmdShow)) {
        return 1;
    }

    init_log();

    return MessageLoop();
}
コード例 #3
0
ファイル: WinMain.c プロジェクト: maojxsir/upnp
/*********************************************************************
*
*       WinMain
*
*       --- GENERIC - No modification required for application ---
*
* Function description
*   Start of the windows program.
*   Does the following:
*   - Creates the main window
*   - Loads accelerator table
*   - Performs application specific initialization (--> _InitApp)
*   - Executes the message loop.
*/
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	MSG    Msg;
	HACCEL hAccelTable;
  HWND   hWndMain;
  BITMAP BmpDevice;
  DWORD  ThreadID;
  /* Init global data */
  _hInst = hInstance;
  /* Register main window class */
	_RegisterClass();
  /* Load bitmap */
  _hBmpDevice = (HBITMAP)LoadImage(_hInst, (LPCTSTR) IDB_DEVICE, IMAGE_BITMAP,  0, 0, 0);
  _hMenuPopup = LoadMenu(_hInst, (LPCSTR)IDC_CONTEXTMENU);
  _hMenuPopup = GetSubMenu(_hMenuPopup, 0);
  /* Create main window */
  GetObject(_hBmpDevice, sizeof(BmpDevice), &BmpDevice);
  hWndMain = CreateWindowEx(WS_EX_TOPMOST, _sWindowClass, "embOS Simulation", WS_SYSMENU | WS_CLIPCHILDREN | WS_POPUP | WS_VISIBLE,
                                  10, 20, BmpDevice.bmWidth, BmpDevice.bmHeight, NULL, NULL, _hInst, NULL);
  if (!hWndMain) {
    return 1;   /* Error */
  }
  /* Show main window */
  ShowWindow(hWndMain, nCmdShow);
  /* Load accelerator table */
	hAccelTable = LoadAccelerators(_hInst, (LPCTSTR)IDC_WINMAIN);
	/* application initialization: */
  CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Thread, NULL, 0, &ThreadID);
  /* main message loop */
  if (SIM_Init(hWndMain) == 0) {
    while (GetMessage(&Msg, NULL, 0, 0)) {
      if (!TranslateAccelerator(Msg.hwnd, hAccelTable, &Msg)) {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
      }
    }
  }
	return 0;
}