示例#1
0
文件: dt.c 项目: FlorianPO/simgrid
double Reduce(Arr *a,int w){
  double retv=0.0;
  if(timer_on){
    timer_clear(w);
    timer_start(w);
  }
  retv=(int)(w*CheckVal(a));/* The casting needed for node  
                               and array dependent verifcation */
  if(timer_on){
    timer_stop(w);
    fprintf(stderr,"** Reduce time in node %d = %f\n",(w-1),timer_read(w));
  }
  return retv;
}
示例#2
0
/********************************************************************

  Declaration: Function reacts to button click and set value to an
               appropriate textbox in gui.
  Call:  OnTimeONPlus ()
  Input: none
  Returns: none
  24.03.2007 Initial coding / YS  
  
*********************************************************************/
void GUIForm::OnTimeOFFMinus() 
{
	double nVal = 0;	
	QString str;
  
	str = ui.IDC_TimeOff->text();
    nVal = str.toDouble();
	nVal = nVal-0.5;
	
	if (1 == CheckVal(nVal))
	{
	 str.sprintf("%0.2f", nVal);
	 ui.IDC_TimeOff->setText(str);
	}
	
	// Send message to EVE:
    if(m_vent)
    {    
      // m_vent->setTimeOFFVal(1, 0);
    }
}
示例#3
0
INT_PTR CALLBACK SetParams(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	hVal = GetDlgItem(hDlg,IDC_EDIT1);
	char Val[255] = {'0'};
	char* buf = new char[255];
	int val = CheckVal();
	switch (message)
	{
	case WM_INITDIALOG:
			
		buf = _itoa(val,buf,10);
		SetWindowText(hVal,buf);
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
		{
			EndDialog(hDlg, LOWORD(wParam));
			return (INT_PTR)TRUE;
		}

		//Обработчик нажатия кнопки Set Val
		if (LOWORD(wParam) == IDC_BT_SETVAL && HIWORD(wParam) == BN_CLICKED)
		{
			//Получаем значение из окна
			GetWindowText(hVal,Val,255);
			val = atoi(Val);
			//и устанавливаем его в параметр реестра
			if(SetVal(val) != NULL)
				MessageBox(NULL,"Succes",NULL,MB_OK);	
		}
		break;
	}
	return (INT_PTR)FALSE;
}
示例#4
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	int val = 0;
	char buf[255];
	RECT rect;
	char* text = " Runs left";
	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case ID_PARAMS_SETPARAMS:			
			DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, SetParams);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		
		GetClientRect(hWnd, &rect);
		val = CheckVal();
		
		
		_itoa(val,buf,10);
		strncat_s(buf,_countof(buf),text,_countof(buf)-strlen(buf));
		DrawText(hdc, buf, -1, &rect,
			DT_SINGLELINE | DT_CENTER | DT_VCENTER );

		EndPaint(hWnd, &ps);
		break;
	case WM_CREATE:
		//Проверяем сколько осталось попыток запуска программы
		val = CheckVal();
		if(val > 0)
			//Устанавливаем на 1 попытку меньше
			SetVal(--val);
		//Если попыток не осталось
		else
		{
			//Выводим сообщение
			MessageBox(NULL,"Value is 0",NULL,MB_OK);	
			//и не даем программе запуститься - уничтожаем окно программы
			DestroyWindow(hWnd);
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}