コード例 #1
0
ファイル: DIALOG_NestedModal.c プロジェクト: caicry/uFrame
/*********************************************************************
*
*       _cbDialogSelect
*/
static void _cbDialogSelect(WM_MESSAGE* pMsg) {
  WM_HWIN hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    _InitDialogSelect(hWin);
    WM_SetFocus(WM_GetDialogItem(hWin, GUI_ID_OK));
    break;
  case WM_NOTIFY_PARENT:
    if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) {
      int Id = WM_GetId(pMsg->hWinSrc);
      switch (Id) {
      case GUI_ID_OK:
        if (_GetVehicle(hWin) == 0) {
          _MessageBox("You have to select a vehicle!", "ERROR");
          WM_MakeModal(hWin);
          WM_SetFocus(hWin);
          break;
        }
      case GUI_ID_CANCEL:
        GUI_EndDialog(pMsg->hWin, 0);
        break;
      }
    }
    break;
  default:
    WM_DefaultProc(pMsg);
  }
}
コード例 #2
0
ファイル: Echo1.c プロジェクト: agb861/ddd
/*********************************************************************
*
*       _SendReceive1
*
*/
static int _SendReceive1(unsigned DeviceId, unsigned char DataTx) {
  unsigned char DataRx;
  int r;

  r = USBBULK_WriteReadEx(DeviceId, &DataTx, 1, &DataRx, 1);
  if (r < 1) {
    _MessageBox("Could not write to device");
    return 1;                      // Error
  }
  if (DataRx != (DataTx + 1)) {
    _MessageBox("Wrong data read");
    return 1;                      // Error
  }
  printf(".");
  return 0;
}
コード例 #3
0
ファイル: Echo1.c プロジェクト: agb861/ddd
/*********************************************************************
*
*       _Echo1
*
*/
static int _Echo1(unsigned DeviceId) {
  int NumBytes2Send;
  int i;
  int r;
  char ac[100];

  r = 0;
  if (USBBULK_OpenEx(DeviceId) == NULL) {
    _MessageBox("Unable to connect to USB BULK device");
    return 1;
  }
  _ShowDriverInfo();
  USBBULK_SetTimeoutEx(DeviceId, 3600 * 1000);
  printf("Enter the number of bytes to be send to the echo client: ");
  ac[0] = 96;
  _cgets(ac);
  NumBytes2Send = atoi(&ac[2]);
  for (i = 0; i < NumBytes2Send; i++) {
    char DataTx;

    DataTx = i % 255;
    if (_SendReceive1(DeviceId, DataTx)) {
      r = 1;
      break;
    }
  }
  if (r == 0) {
    printf ("\n%d bytes successfully transferred.", NumBytes2Send);
  }
  USBBULK_CloseEx(DeviceId);
  return r;
}
コード例 #4
0
ファイル: HIDEcho1.c プロジェクト: agb861/ddd
/*********************************************************************
*
*       _SendReceive1
*
*/
static int _SendReceive(unsigned DeviceId, U8 * pDataTx, unsigned NumBytes2Send, U8 * pDataRx, unsigned NumBytes2Receive) {
  int r;

  r = USBHID_Write(DeviceId, pDataTx, NumBytes2Send);
  USBHID_Read(DeviceId, pDataRx, NumBytes2Receive);
  if (r < 1) {
    _MessageBox("Could not write to device");
    return 1;                      // Error
  }
  if (*pDataRx != (*pDataTx + 1)) {
    _MessageBox("Wrong data read");
    return 1;                      // Error
  }
  printf(".");
  return 0;
}
コード例 #5
0
ファイル: HIDEcho1.c プロジェクト: agb861/ddd
/*********************************************************************
*
*       _Echo1
*
*/
static int _Echo1(unsigned DeviceId) {
  int      i;
  int      r;
  int      NumEchoes;
  char     ac[100];
  unsigned InputReportLength;
  unsigned OutputReportLength;
  U8     * pDataRx;
  U8     * pDataTx;

  r = 0;
  if (USBHID_Open(DeviceId) != 0) {
    _MessageBox("Unable to connect to USB HID device");
    return 1;
  }
  //
  //  Retrieve report sizes
  // 
  InputReportLength  = USBHID_GetInputReportSize(DeviceId);
  OutputReportLength = USBHID_GetOutputReportSize(DeviceId);
  //
  // Alloc memeory for in/out report
  pDataTx = (U8 *)calloc(OutputReportLength, sizeof(U8));
  pDataRx = (U8 *)calloc(InputReportLength,  sizeof(U8));
  if ((pDataRx == NULL) || (pDataTx == NULL)) {
    printf("No memory available to create buffer for sending/receiving data\n");
    r = 1;
    goto End;
  }
  printf("Enter the number of echoes to be sent to the echo client: ");
  ac[0] = 96;
  _cgets(ac);
  NumEchoes = atoi(&ac[2]);
  for (i = 0; i < NumEchoes; i++) {

    *pDataTx = i % 255;
    if (_SendReceive(DeviceId, pDataTx, OutputReportLength, pDataRx, InputReportLength)) {
      r = 1;
      break;
    }
  }
  if (r == 0) {
    printf ("\n%d echoes successfully transferred.", NumEchoes);
  }
End:
  free(pDataTx);
  free(pDataRx);
  USBHID_Close(DeviceId);
  return r;
}
コード例 #6
0
ファイル: gmsgbox.cpp プロジェクト: miro-kostadinov/tmos
int MessageBox(const char* Text, const char* Caption, unsigned int Style, unsigned int def_button)
{
	GMsgBox* box = new GMsgBox;
	unsigned int res = 0;
	if(box)
	{
		box->displays = 1;
		box->type = Style;
		box->body =  Text;
		box->title = Caption;
		box->default_button = def_button;
		res = box->DoModal();
		delete box;
	}
	else
		res = _MessageBox(Text, Caption, Style, def_button);
	return res;
}
コード例 #7
0
ファイル: Window_1.c プロジェクト: fangchuan/AR_2
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
    WM_HWIN          hItem;
    int              NCode;
    int              Id;
    WM_HWIN         hNumPad;
    u8              Mb_Val;

    switch (pMsg->MsgId) {
    case WM_INIT_DIALOG:
        //
        //Initialization of Window
        //
        hItem = pMsg->hWin;
        WINDOW_SetBkColor(hItem, GUI_LIGHTBLUE);
        //
        // Initialization of 'Button'
        //
        GUI_UC_SetEncodeUTF8();
        GUI_SetFont(&GUI_FontSongTi16);
        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_BACK);
        BUTTON_SetFont(hItem,&GUI_FontSongTi12);
        BUTTON_SetText(hItem, _StringHZ[2]);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ENTER);
        BUTTON_SetFont(hItem,&GUI_FontSongTi12);
        BUTTON_SetText(hItem, _StringHZ[3]);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_NEW);
        BUTTON_SetFont(hItem,&GUI_FontSongTi16);
        BUTTON_SetText(hItem, _StringHZ[0]);

        hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OPEN);
        BUTTON_SetFont(hItem,&GUI_FontSongTi16);
        BUTTON_SetText(hItem, _StringHZ[1]);
        //
        // Initialization of 'Header'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_1);
        HEADER_AddItem(hItem, 80, "LeCoder", 14);
        //
        //Initialize EDIT0
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0);
        MULTIEDIT_SetText(hItem, "");     //清空EDIT内容
        MULTIEDIT_SetFocussable(hItem,1); //设为捕捉光标焦点
        MULTIEDIT_SetAutoScrollV(hItem,1);//自动竖直滑块
        MULTIEDIT_SetAutoScrollH(hItem,1);//自动水平滑块
        MULTIEDIT_SetWrapWord(hItem);     //自动换行
        MULTIEDIT_SetFocussable(hItem, 1);
        WM_SetFocus(hItem);
        break;
    case WM_PAINT:
        GUI_SetColor(GUI_RED);
        GUI_SetFont(&GUI_FontSongTi12);
        GUI_DispStringAt(_StringHZ[4], 100, 25);
        break;
    case WM_NOTIFY_PARENT:
        Id    = WM_GetId(pMsg->hWinSrc);
        NCode = pMsg->Data.v;
        switch(Id) {

        case ID_BUTTON_BACK: // Notifications sent by 'Button'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                Key_Value = WINDOW_TOP;
                break;
            }
            break;
        case ID_BUTTON_ENTER: // Notifications sent by 'ENTER'
        case ID_BUTTON_NEW: // Notifications sent by 'New'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                //get the program name in the edit
                hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0);
                MULTIEDIT_GetText(hItem,program_name,sizeof(program_name));
                //warning the situation of empty program name
                if(strcmp(program_name, "") == 0)
                {
                    _MessageBox(_StringHZ[4],_StringHZ[5], &Mb_Val);
                }
                else
                {
                    CreateWindow_1_1();
                }
                break;
            }
            break;
        case ID_BUTTON_OPEN: // Notifications sent by 'Open'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                CreateWindow_TreeView();
                break;
            }
            break;
        case ID_HEADER_1: // Notifications sent by 'Header'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                break;
            case WM_NOTIFICATION_MOVED_OUT:
                break;
            }
            break;
        case ID_MULTIEDIT_0: // Notifications sent by 'Edit1'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
                break;
            case WM_NOTIFICATION_RELEASED:
                hNumPad = Create_NumPad(pMsg->hWin);
                WM_MakeModal(hNumPad);
                GUI_ExecCreatedDialog(hNumPad);
                break;
            case WM_NOTIFICATION_VALUE_CHANGED:
                break;
            }
            break;
        }
        break;
    default:
        WM_DefaultProc(pMsg);
        break;
    }
}
コード例 #8
0
ファイル: Main.cpp プロジェクト: rafdp/MeteoProject
int WINAPI WinMain (HINSTANCE hInstance,
					HINSTANCE legacy,
					LPSTR lpCmdLine,
					int nCmdShow)
{
	__EXPN__ = new ExceptionData_t (20, "ExceptionErrors.txt");
	srand (static_cast<UINT>(time (nullptr)));

	

	try
	{
		WindowClass window (int (SCREEN_WIDTH * 0.98f), int (SCREEN_HEIGHT * 0.9f));
		AllocConsole ();
		FILE* file = nullptr;
		freopen_s (&file, "CONOUT$", "w", stdout);

		Direct3DProcessor d3dProc (&window);
		d3dProc.ApplyBlendState (d3dProc.AddBlendState (true));

		//d3dProc.ApplyRasterizerState (d3dProc.AddRasterizerState (false, false, true));

		//XMMATRIX world = XMMatrixTranslation (0.0f, 0.0f, 0.0f);
		CamInfo_t camInfo = { { BASE_X, BASE_Y, BASE_Z, 1.0f }, {}, 0.01f , 0.0f};
		Direct3DCamera cam (&window,
							camInfo.pos.x, camInfo.pos.y, camInfo.pos.z,
							0.0f, -1.0f, 1.0f,
							0.0, 1.0f, 0.0f,
							FOV, 0.5f);

		XMStoreFloat4(&camInfo.dir, cam.GetDir());

		ConstantBufferIndex_t camBuf = d3dProc.RegisterConstantBuffer (&camInfo,
																	   sizeof (camInfo),
																	   1);
		d3dProc.UpdateConstantBuffer (camBuf);

		MeteoObject meteo ("Data/COSMOMESH", "Data/Fronts", "Data/H", &camInfo.step, 0.01f, &d3dProc, &cam);
		cam.Update ();

		meteo.RunPolygonalBuilding();
		//SetForegroundWindow (window.hwnd ());


		printf("Processing\n");
		d3dProc.ProcessObjects ();


		MSG msg = {};
		bool rotate = true;
		bool wasPressedSpace = false;
		uint64_t ticksOld = 0;
		uint64_t ticksNew = GetTickCount64 ();
		char ticksN = 0;

		printf("Drawing\n");
		
		int hour = 0;
		while (true)
		{
			if (PeekMessage (&msg, nullptr, 0, 0, PM_REMOVE))
			{
				TranslateMessage (&msg);
				DispatchMessage (&msg);

				if (msg.message == WM_QUIT) break;
			}
			// SCENE PROCESSING

			/*if (rotate) meteo.Rotate (0.01f);
			if (GetAsyncKeyState (VK_SPACE) & 0x8000)
			{
				if (!wasPressedSpace)
				{
					rotate = !rotate;
					wasPressedSpace = true;
				}
			}
			else wasPressedSpace = false;*/
			if (GetAsyncKeyState('J') & 0x8000)
			{
				while (GetAsyncKeyState('J'));
				camInfo.noise = 2.0f - camInfo.noise;
			}

			ProcessCam (&cam, &camInfo);

			meteo.PreDraw ();

			cam.Update ();
			cam.StorePos (camInfo.pos);
			d3dProc.UpdateConstantBuffer (camBuf);

			d3dProc.SendCBToGS (camBuf);
			d3dProc.SendCBToPS (camBuf);
			d3dProc.ProcessDrawing (&cam, true);
			d3dProc.Present ();
			if (ticksN >= 10)
			{
				ticksN = 0;
				ticksOld = ticksNew;
				ticksNew = GetTickCount64();

				printf ("%.2f fps %f step noise %s          \r", 10000.0f/(ticksNew - ticksOld), camInfo.step, camInfo.noise > 1.0f ? "ON" : "OFF");

				/*if (10000.0f / (ticksNew - ticksOld) - TARGET_FPS > 10.0f)
					 camInfo.step -= 0.0005f;
				else 
				if (10000.0f / (ticksNew - ticksOld) - TARGET_FPS < -10.0f)
					camInfo.step += 0.0005f;
				if (camInfo.step < 0.0f) camInfo.step = 0.0001f;*/
				
			}
			ticksN++;
			//_getch();
			//break;
		}
		FreeConsole ();
	}
	catch (ExceptionHandler_t& ex)
	{
		_MessageBox ("Exception occurred\nCheck \"ExceptionErrors.txt\"");
		ex.WriteLog (__EXPN__);
		system ("start ExceptionErrors.txt");
	}
	catch (std::exception err)
	{
		_MessageBox ("Exception occurred: %s\n", err.what ());
	}
	catch (...)
	{
		_MessageBox ("Exception occurred\n");
	}

	delete __EXPN__;


	return 0;
}