void COutputTabView::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult) { //CAIPIEditView notification modified message g_bNotificationModified = false; NM_LISTVIEW* pNMListView = (NM_LISTVIEW*) pNMHDR; int nSelected = pNMListView->iItem; CString strItemLine = m_listCtrl2.GetItemText(nSelected, 1); CString strItemPos = m_listCtrl2.GetItemText(nSelected, 2); CString strFilePath = m_listCtrl2.GetItemText(nSelected, 4); int iLine = _ttoi(strItemLine); unsigned int iPos = _ttoi(strItemPos); if ( pNMListView->uNewState & LVIS_SELECTED) { if( strFilePath != _T(" - ") ) { CAIPIApp* pApp = (CAIPIApp*)AfxGetApp(); BOOL alreadyOpen = pApp->SetDocumentView(strFilePath); //if document is not already open then open it if( alreadyOpen == FALSE ) { pApp->m_pAIPIEditorDocTemplate->OpenDocumentFile(strFilePath); if( pApp == NULL ) { CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd(); pMainFrame->m_wndOutputTabView.AddMsg1(_T("ERROR: The file (") + strFilePath + _T(") could not be linked. Check if the file is not corrupted.")); return; } } else { //MessageBox(strItem); CMDIFrameWnd* pFrame = (CMDIFrameWnd*)::AfxGetApp()->m_pMainWnd; CMDIChildWnd* pChild = (CMDIChildWnd*) pFrame->MDIGetActive(); CScintillaView* pView = (CScintillaView*) pChild->GetActiveView(); ASSERT(pView); CScintillaCtrl& rCtrl = pView->GetCtrl(); // Reset Scintilla Markers rCtrl.MarkerDeleteAll(0); // Initilaize error markers rCtrl.MarkerDefine(0, SC_MARK_SHORTARROW); rCtrl.MarkerSetFore(0, RGB( 0, 0, 255 )); rCtrl.MarkerSetBack(0, RGB( 0, 0, 255 )); // Set error marker to proper line rCtrl.GotoLine(iLine -1 ); rCtrl.MarkerAdd((iLine - 1), 0); //Set the cursor position in the GUI rCtrl.SetFocus(); rCtrl.SetSel(iPos, iPos + 1); } } } *pResult; Beep(iPos, 100); g_bNotificationModified = true; }
void COutputTabView::OnItemchangedList3(NMHDR* pNMHDR, LRESULT* pResult) { //AfxMessageBox(_T("hola")); //CAIPIEditView notification modified message g_bNotificationModified = false; NM_LISTVIEW* pNMListView = (NM_LISTVIEW*) pNMHDR; int nSelected = pNMListView->iItem; CString strItemLine = m_listCtrl3.GetItemText(nSelected, 1); CString strItemPos = m_listCtrl3.GetItemText(nSelected, 2); CString strFilePath = m_listCtrl3.GetItemText(nSelected, 3); CString strFileName = m_listCtrl3.GetItemText(nSelected, 4); CString strPathName = strFilePath + strFileName; int iLine = _ttoi(strItemLine); long iPos = _ttoi(strItemPos); int len = m_strFindText.GetLength(); if ( pNMListView->uNewState & LVIS_SELECTED) { if( strFileName != _T(" - ") ) { CAIPIApp* pApp = (CAIPIApp*)AfxGetApp(); BOOL alreadyOpen = pApp->SetDocumentView(strPathName); //if document is not already open then open it if( alreadyOpen == FALSE ) { CString strExt = strPathName.Right(3); if( strExt == _T("knw") || strExt == _T("txt") ) { CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd(); pMainFrame->m_wndOutputTabView.AddMsg1(_T("The file (") + strFileName + _T(") was opened.")); } else if ( strExt == _T("ssn") || strExt == _T("rtf") ) { CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd(); pMainFrame->m_wndOutputTabView.AddMsg1(_T("WARNING: Aipi session file found (.ipi). The file (") + strFileName + _T(") do not belong to Aipi knowlegde files. Check the path and the name of the file.")); } else if( strExt == _T("csv") || _T("idt") || _T("tre") ) { CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd(); pMainFrame->m_wndOutputTabView.AddMsg1(_T("WARNING: Aipi tree file (.adt). The file (") + strFileName + _T(") do not belong to Aipi knowledge files. Check the path and the name of the file.")); } else { CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd(); pMainFrame->m_wndOutputTabView.AddMsg1(_T("WARNING: The file (") + strFileName + _T(") do not belong to Aipi knowledge files. Check the path and the name of the file.")); } pApp->m_pAIPIEditorDocTemplate->OpenDocumentFile(strPathName); if( pApp == NULL ) { CMainFrame* pMainFrame = (CMainFrame*)::AfxGetMainWnd(); pMainFrame->m_wndOutputTabView.AddMsg1(_T("ERROR: The file (") + strFileName + _T(") could not be linked. Check if the file is not corrupted.")); return; } } else { CMDIFrameWnd* pFrame = (CMDIFrameWnd*)::AfxGetApp()->m_pMainWnd; CMDIChildWnd* pChild = (CMDIChildWnd*) pFrame->MDIGetActive(); CScintillaView* pView = (CScintillaView*) pChild->GetActiveView(); ASSERT(pView); CScintillaCtrl& rCtrl = pView->GetCtrl(); // Reset Scintilla Markers rCtrl.MarkerDeleteAll(0); // Initilaize error markers rCtrl.MarkerDefine(0, SC_MARK_SHORTARROW); rCtrl.MarkerSetFore(0, RGB( 0, 0, 255 )); rCtrl.MarkerSetBack(0, RGB( 0, 0, 255 )); // Set error marker to proper line rCtrl.GotoLine(iLine -1 ); rCtrl.MarkerAdd((iLine - 1), 0); //Set the cursor position in the GUI rCtrl.SetFocus(); rCtrl.SetSel(iPos - len, iPos); //int n = pApp->CountOpenDocuments(); //int b = n; } } } *pResult; Beep(iPos, 100); g_bNotificationModified = true; }
ICRESULT SkeeBall::WiiMoteLoop(void*) { // let's load a couple of samples: wiimote_sample sine_sample, daisy_sample; // simple callback example (we use polling for almost everything here): remote.ChangedCallback = on_state_change; // notify us only when something related to the extension changes remote.CallbackTriggerFlags = (state_change_flags)( EXTENSION_CHANGED | MOTIONPLUS_CHANGED); reconnect: COORD pos = { 0, 6 }; SetConsoleCursorPosition(console, pos); // try to connect the first available wiimote in the system // (available means 'installed, and currently Bluetooth-connected'): COLWHITE; _tprintf(_T(" Looking for a Wiimote ")); static const TCHAR* wait_str[] = { _T(". "), _T(".. "), _T("...") }; unsigned count = 0; while(!remote.Connect(wiimote::FIRST_AVAILABLE)) { _tprintf(_T("\b\b\b\b%s "), wait_str[count%3]); count++; #ifdef USE_BEEPS_AND_DELAYS Beep(500, 30); Sleep(1000); #endif } wiimote = true; // connected - light all LEDs remote.SetLEDs(0x0f); BRIGHT_CYAN; _tprintf(_T("\b\b\b\b... connected!")); if(remote.IsBalanceBoard()) { BRIGHT_WHITE; _tprintf(_T(" (Balance Board)")); } #ifdef USE_BEEPS_AND_DELAYS Beep(1000, 300); Sleep(2000); #endif COORD cursor_pos = { 0, 6 }; // ask the wiimote to report everything (using the 'non-continous updates' // default mode - updates will be frequent anyway due to the acceleration/IR // values changing): // note1: you don't need to set a report type for Balance Board - the library // takes care of it (there is only one). // note2: for wiimotes, the report mode that includes the extension data // unfortunately only reports the 'BASIC' IR info (ie. no dot sizes) - // so let's choose the best mode based on the extension status (we also // toggle modes as needed in the callback above): if(!remote.IsBalanceBoard()) { if(remote.bExtension) remote.SetReportType(wiimote::IN_BUTTONS_ACCEL_IR_EXT); // no IR dots else remote.SetReportType(wiimote::IN_BUTTONS_ACCEL_IR); // IR dots } // (stuff for animations) DWORD last_rumble_time = timeGetTime(); // for rumble text animation DWORD last_led_time = timeGetTime(); // for led animation bool rumble_text = true; unsigned lit_led = 0; // display the wiimote state data until 'Home' is pressed: bool caliubrate_atrest_once = true; while(playing)// && !GetAsyncKeyState(VK_ESCAPE)) { // the wiimote state needs to be refreshed for each pass while(remote.RefreshState() == NO_CHANGE) Sleep(1); // // don't hog the CPU if nothing changed cursor_pos.Y = 8; SetConsoleCursorPosition(console, cursor_pos); // did we loose the connection? if(remote.ConnectionLost()) { BRIGHT_RED; _tprintf( _T(" *** connection lost! *** \n") BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE BLANK_LINE); Beep(100, 1000); Sleep(2000); COORD pos = { 0, 6 }; SetConsoleCursorPosition(console, pos); _tprintf(BLANK_LINE BLANK_LINE BLANK_LINE); goto reconnect; } // rumble if 'B' (trigger) is pressed remote.SetRumble(remote.Button.B()); // disable MotionPlus (if connected) to allow its own extension port // to work if(remote.Button.Minus()) remote.DisableMotionPlus(); // actions for buttons just pressed/released: static bool last_A = false, last_One = false, last_Two = false; #define ON_PRESS_RELEASE(button, pressed_action, released_action) \ { bool pressed = remote.Button.button(); \ if(pressed) \ { /* just pressed? */ \ if(!last_##button) pressed_action; \ } \ else if(last_##button) /* just released */ \ released_action; \ /* remember the current button state for next time */ \ last_##button = pressed; } // Battery level: CYAN; _tprintf(_T(" Battery: ")); // (the green/yellow colour ranges are rough guesses - my wiimote // with rechargeable battery pack fails at around 15%) (remote.bBatteryDrained )? BRIGHT_RED : (remote.BatteryPercent >= 30)? BRIGHT_GREEN : BRIGHT_YELLOW; _tprintf(_T("%3u%% "), remote.BatteryPercent); DWORD current_time = timeGetTime(); // LEDs: // animate them every second if((current_time - last_led_time) >= 1000) { remote.SetLEDs((BYTE)(1<<lit_led)); lit_led = (++lit_led) % 4; last_led_time = timeGetTime(); } CYAN; _tprintf(_T("LEDs: ")); COLWHITE; _tprintf(_T("[")); for(unsigned led=0; led<4; led++) { if(remote.LED.Lit(led)) { BRIGHT_CYAN; _tprintf(_T("*")); } else { COLWHITE ; _tprintf(_T("-"));//_T("%c"), '0'+led); } } // Rumble COLWHITE; _tprintf(_T("] ")); if(remote.bRumble) { BRIGHT_WHITE; _tprintf(rumble_text? _T(" RUMBLE") : _T("RUMBLE ")); // animate the text if((current_time - last_rumble_time) >= 110) { rumble_text = !rumble_text; last_rumble_time = current_time; } } else _tprintf(_T(" ")); // Output method: CYAN; _tprintf( _T(" using %s\n"), (remote.IsUsingHIDwrites()? _T("HID writes") : _T("WriteFile()"))); // Buttons: CYAN; _tprintf(_T("\n Buttons: ")); COLWHITE; _tprintf(_T("[")); for(unsigned bit=0; bit<16; bit++) { WORD mask = (WORD)(1 << bit); // skip unused bits if((wiimote_state::buttons::ALL & mask) == 0) continue; const TCHAR* button_name = wiimote::ButtonNameFromBit[bit]; bool pressed = ((remote.Button.Bits & mask) != 0); if(bit > 0) { CYAN; _tprintf(_T("|")); // seperator } if(pressed) { BRIGHT_WHITE; _tprintf(_T("%s") , button_name); } else { COLWHITE ; _tprintf(_T("%*s"), _tcslen(button_name), _T("")); } } COLWHITE; _tprintf(_T("]\n")); // Acceleration: CYAN ; _tprintf(_T(" Accel:")); remote.IsBalanceBoard()? RED : COLWHITE; _tprintf(_T(" X %+2.3f Y %+2.3f Z %+2.3f \n"), remote.Acceleration.X, remote.Acceleration.Y, remote.Acceleration.Z); // Orientation estimate (shown red if last valid update is aging): CYAN ; _tprintf(_T(" Orient:")); remote.IsBalanceBoard()? RED : COLWHITE; _tprintf(_T(" UpdateAge %3u "), remote.Acceleration.Orientation.UpdateAge); // show if the last orientation update is considered out-of-date // (using an arbitrary threshold) if(remote.Acceleration.Orientation.UpdateAge > 10) RED; _tprintf(_T("Pitch:%4ddeg Roll:%4ddeg \n") _T(" (X %+.3f Y %+.3f Z %+.3f) \n"), (int)remote.Acceleration.Orientation.Pitch, (int)remote.Acceleration.Orientation.Roll , remote.Acceleration.Orientation.X, remote.Acceleration.Orientation.Y, remote.Acceleration.Orientation.Z); // IR: CYAN ; _tprintf(_T(" IR:")); remote.IsBalanceBoard()? RED : COLWHITE; _tprintf(_T(" Mode %s "), ((remote.IR.Mode == wiimote_state::ir::OFF )? _T("OFF ") : (remote.IR.Mode == wiimote_state::ir::BASIC )? _T("BASIC") : (remote.IR.Mode == wiimote_state::ir::EXTENDED)? _T("EXT. ") : _T("FULL "))); // IR dot sizes are only reported in EXTENDED IR mode (FULL isn't supported yet) bool dot_sizes = (remote.IR.Mode == wiimote_state::ir::EXTENDED); for(unsigned index=0; index<4; index++) { wiimote_state::ir::dot &dot = remote.IR.Dot[index]; if(!remote.IsBalanceBoard()) COLWHITE; _tprintf(_T("%u: "), index); if(dot.bVisible) { COLWHITE; _tprintf(_T("Seen ")); } else { RED ; _tprintf(_T("Not seen ")); } _tprintf(_T("Size")); if(dot_sizes) _tprintf(_T("%3d "), dot.Size); else { RED; _tprintf(_T(" n/a")); if(dot.bVisible) COLWHITE; } _tprintf(_T(" X %.3f Y %.3f\n"), dot.X, dot.Y); if(index < 3) _tprintf(_T(" ")); } // Speaker: CYAN ; _tprintf(_T(" Speaker:")); remote.IsBalanceBoard()? RED : COLWHITE; _tprintf(_T(" %s | %s "), (remote.Speaker.bEnabled? _T("On ") : _T("Off")), (remote.Speaker.bMuted ? _T("Muted") : _T(" "))); if(!remote.Speaker.bEnabled || remote.Speaker.bMuted) RED; else//if(remote.IsPlayingAudio()) BRIGHT_WHITE; else COLWHITE; COLWHITE; _tprintf(_T("Frequency %4u Hz Volume 0x%02x\n"), wiimote::FreqLookup[remote.Speaker.Freq], remote.Speaker.Volume); // -- Extensions --: CYAN ; _tprintf(_T("__________\n Extnsn.: ")); switch(remote.ExtensionType) { case wiimote_state::NONE: { RED; _tprintf(_T("None \n")); _tprintf(BLANK_LINE BLANK_LINE BLANK_LINE); } break; case wiimote_state::PARTIALLY_INSERTED: { BRIGHT_RED; _tprintf(_T("Partially Inserted \n")); _tprintf(BLANK_LINE BLANK_LINE BLANK_LINE); } break; // -- Nunchuk -- case wiimote_state::NUNCHUK: { BRIGHT_WHITE; _tprintf(_T("Nunchuk ")); // Buttons: CYAN ; _tprintf(_T("Buttons: ")); COLWHITE; _tprintf(_T("[")); BRIGHT_WHITE; _tprintf(remote.Nunchuk.C? _T("C") : _T(" ")); CYAN ; _tprintf(_T("|")); BRIGHT_WHITE; _tprintf(remote.Nunchuk.Z? _T("Z") : _T(" ")); COLWHITE ; _tprintf(_T("] ")); // Joystick: CYAN ; _tprintf(_T("Joystick: ")); COLWHITE ; _tprintf(_T("X %+2.3f Y %+2.3f\n"), remote.Nunchuk.Joystick.X, remote.Nunchuk.Joystick.Y); // Acceleration: CYAN ; _tprintf(_T(" Accel:")); COLWHITE ; _tprintf(_T(" X %+2.3f Y %+2.3f Z %+2.3f \n"), remote.Nunchuk.Acceleration.X, remote.Nunchuk.Acceleration.Y, remote.Nunchuk.Acceleration.Z); // Orientation estimate (shown red if last valid update is aging): CYAN ; _tprintf(_T(" Orient:")); COLWHITE ; _tprintf(_T(" UpdateAge %3u "), remote.Nunchuk.Acceleration.Orientation.UpdateAge); // show if the last orientation update is aging if(remote.Nunchuk.Acceleration.Orientation.UpdateAge > 10) RED; _tprintf(_T("Pitch %4ddeg Roll %4ddeg \n") _T(" (X %+.2f Y %+.2f Z %+.2f) \n"), (int)remote.Nunchuk.Acceleration.Orientation.Pitch, (int)remote.Nunchuk.Acceleration.Orientation.Roll , remote.Nunchuk.Acceleration.Orientation.X, remote.Nunchuk.Acceleration.Orientation.Y, remote.Nunchuk.Acceleration.Orientation.Z); } break; // -- Classic Controller -- case wiimote_state::CLASSIC: case wiimote_state::GH3_GHWT_GUITAR: case wiimote_state::GHWT_DRUMS: { BRIGHT_WHITE; // the Guitar Hero controller is just a classic controller with // another ID if(remote.ExtensionType == wiimote_state::CLASSIC) _tprintf(_T("Classic Controller ")); else if(remote.ExtensionType == wiimote_state::GH3_GHWT_GUITAR) _tprintf(_T("GH3/GHWT Guitar ")); else _tprintf(_T("GHWT Drums ")); // L: Joystick/Trigger COLWHITE; _tprintf(_T("L: ")); CYAN ; _tprintf(_T("Joy ")); COLWHITE; _tprintf(_T("X %+2.3f Y %+2.3f "), remote.ClassicController.JoystickL.X, remote.ClassicController.JoystickL.Y); CYAN ; _tprintf(_T("Trig ")); COLWHITE; _tprintf(_T("%+2.3f\n"), remote.ClassicController.TriggerL); // R: Joystick/Trigger COLWHITE; _tprintf(_T(" R: ")); CYAN ; _tprintf(_T("Joy ")); COLWHITE; _tprintf(_T("X %+2.3f Y %+2.3f "), remote.ClassicController.JoystickR.X, remote.ClassicController.JoystickR.Y); CYAN ; _tprintf(_T("Trig ")); COLWHITE; _tprintf(_T("%+2.3f\n"), remote.ClassicController.TriggerR); // Buttons: CYAN; _tprintf(_T(" Buttons: ")); COLWHITE; _tprintf(_T("[")); for(unsigned bit=0; bit<16; bit++) { WORD mask = (WORD)(1 << bit); // skip unused bits if((wiimote_state::classic_controller::buttons::ALL & mask) == 0) continue; const TCHAR* button_name = wiimote::ClassicButtonNameFromBit[bit]; const TCHAR* seperator = (bit==0)? _T("") : _T("|"); bool pressed = ((remote.ClassicController.Button.Bits & mask) != 0); CYAN; _tprintf(seperator); if(pressed) { BRIGHT_WHITE; _tprintf(_T("%s") , button_name); } else { COLWHITE ; _tprintf(_T("%*s"), _tcslen(button_name), _T("")); } } COLWHITE; _tprintf(_T("]")); } break; case wiimote_state::BALANCE_BOARD: { BRIGHT_WHITE; _tprintf(_T("Balance Board")); // Weights: CYAN ; _tprintf(_T(" Weight: ")); COLWHITE; _tprintf(_T("TL ")); _tprintf(_T("%6.2f"), remote.BalanceBoard.Kg.TopL); CYAN ; _tprintf(_T(" kg")); COLWHITE; ; _tprintf(_T(" TR ")); _tprintf(_T("%6.2f"), remote.BalanceBoard.Kg.TopR); CYAN; _tprintf(_T(" kg\n")); COLWHITE; _tprintf(_T(" BL ")); _tprintf(_T("%6.2f"), remote.BalanceBoard.Kg.BottomL); CYAN; _tprintf(_T(" kg")); COLWHITE; _tprintf(_T(" BR ")); _tprintf(_T("%6.2f"), remote.BalanceBoard.Kg.BottomR); CYAN; _tprintf(_T(" kg \n")); COLWHITE; _tprintf(_T(" Total ")); _tprintf(_T("%6.2f"), remote.BalanceBoard.Kg.Total); CYAN; _tprintf(_T(" kg")); } break; case wiimote_state::MOTION_PLUS: { BRIGHT_WHITE; _tprintf(_T("Motion Plus")); CYAN ; _tprintf(_T(" Raw: ")); COLWHITE; _tprintf(_T("Yaw: %04hx ") , remote.MotionPlus.Raw.Yaw); COLWHITE; _tprintf(_T("Pitch: %04hx ") , remote.MotionPlus.Raw.Pitch); COLWHITE; _tprintf(_T("Roll: %04hx \n"), remote.MotionPlus.Raw.Roll); CYAN ; _tprintf(_T(" Float: ")); COLWHITE; _tprintf(_T(" %8.3fdeg") , remote.MotionPlus.Speed.Yaw); COLWHITE; _tprintf(_T(" %8.3fdeg") , remote.MotionPlus.Speed.Pitch); COLWHITE; _tprintf(_T(" %8.3fdeg\n") , remote.MotionPlus.Speed.Roll); _tprintf(BLANK_LINE BLANK_LINE); //Sleep(500); } break; } } // disconnect (auto-happens on wiimote destruction anyway, but let's play nice) remote.Disconnect(); Beep(1000, 200); return IC_OK; }
BOOL Progress::Update(INT32 CurrentCount,BOOL FreqEscChecks) { #if DEBUG_OUTPUT TRACE( _T("Progress::Update ActiveDisplays = %d CurrentCount = %d FinalCount=%d\n"),ActiveDisplays,CurrentCount, FinalCount); #endif // --- If no active progress display is on, then return immediately if (ActiveDisplays <= 0) { ActiveDisplays = 0; return(TRUE); } // --- If the job has been cancelled, then return FALSE to indicate user intervention if (JobCancelled) return(FALSE); // If FreqEscChecks is TRUE, ensure we check the escape key, no matter what percentage is displayed if (FreqEscChecks) { // Has the user cancelled the job via the Escape key? if (KeyPress::IsEscapePressed()) { JobCancelled = TRUE; Beep(); return(FALSE); } } // --- If the startup delay (if any) has not expired, we do nothing just yet if (JobDelayed && !StartTime.Elapsed(STARTDELAY)) return(TRUE); // --- Check that the parameter passed in was vaguely sensible ERROR3IF(CurrentCount < 0, "Progress::Update called with out of range parameter"); // --- If we haven't yet shown the hourglass cursor, do it now if (!HourglassShown) { #if DELAY_THREAD ThreadAlive = FALSE; // Stop the delay thread (if any) because it's not needed now #endif BeginBusyCursor(); HourglassShown = TRUE; } // --- Calculate the new percentage to display. This is limited to lie between // the last displayed percentage and 99 inclusive. INT32 NewPercent = CurrentPercent; if (FinalCount > 0) { NewPercent = (100 * CurrentCount) / FinalCount; if (NewPercent > 99) NewPercent = 99; if (NewPercent < CurrentPercent) NewPercent = CurrentPercent; } // --- Now, update the percentage display if it has changed, or if it is a while since // our last update. NOTE: Updates occur periodically for (a) checking the escape key state // occasionally, so we can be called often without a huge performance hit, and (b) to // update frames of our animated hourglass pointer. if (NewPercent > CurrentPercent) { // If FreqEscChecks is FALSE, we only check the escape key when the percentage increases if (!FreqEscChecks) { // Has the user cancelled the job via the Escape key? if (KeyPress::IsEscapePressed()) { JobCancelled = TRUE; Beep(); return(FALSE); } } // (Create if necessary) and update the progress bar, if it is needed if (DisplayBar && FinalCount > 0) { if (StatusLine::Get()) { StatusLine::Get()->ShowProgress(TRUE, &JobDescription); StatusLine::Get()->SetPercent(NewPercent); } } // Remember the last displayed percentage CurrentPercent = NewPercent; } return(TRUE); }
void Gripe(void) { Beep(); printf(bspace); }
long CADOUtil::RunCommand_ReturnLong(_bstr_t CmdText, CParamArray *ParamArray) { if(!CheckCurrentProcess()) throw ERR_NEW_PROCESS_DETECTED; DWORD dRet = 0; _ConnectionPtr pConn = NULL; _CommandPtr pComm = NULL; _ParameterPtr pPrm = NULL; ErrorPtr pErr = NULL; CParam* pr = NULL; _variant_t vIndex; _variant_t vValue; long ErrSQLState = 0; long ErrorCode = 0; _bstr_t bsEpmty; long count; //******************************************************************** //Connectin to Pool try { _bstr_t bstrConnString(szConnectionString); pConn.CreateInstance(__uuidof(Connection)); if(pConn == NULL) { throw(ErrorCode = ERR_UNABLE_CREATE_CONN); } pConn->ConnectionTimeout = 7; pConn->Open(bstrConnString, L"", L"", adConnectUnspecified); } catch(...) { Beep(2000,100); //m_ExternalLink.Add2Log(WL_ERROR_LEVEL1,"Unable set connection to SQL Error = Unknown"); ErrorCode = ERR_UNABLE_CREATE_CONN; } if(ErrorCode != 0) throw ErrorCode; //Execute Command try { pComm.CreateInstance(__uuidof(Command)); if(pComm == NULL) { throw(ErrorCode = ERR_UNABLE_CREATE_COMM); } pComm->ActiveConnection = pConn; pComm->CommandText = CmdText; if (ParamArray != NULL) { for (int i=0; i < ParamArray->GetSize(); i++) { pr = (*ParamArray)[i]; pPrm = pComm->CreateParameter(bsEpmty, pr->Type, pr->Direction, pr->Size, pr->Value); pComm->Parameters->Append(pPrm); } } pConn->Errors->Clear(); _variant_t vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR); _variant_t vtEmpty2(DISP_E_PARAMNOTFOUND, VT_ERROR); _RecordsetPtr reader = pComm->Execute(&vtEmpty, &vtEmpty2, adCmdText); int nFieldCount = reader->Fields->GetCount(); if(nFieldCount > 0) { dRet = (DWORD) reader->Fields->GetItem(_variant_t((long)0))->Value; } } catch(_com_error) { try { count = pConn->Errors->Count; if(count) { vIndex = _variant_t((LONG)0); pErr = pConn->Errors->GetItem(vIndex); ErrSQLState = atol((LPCSTR)pErr->SQLState); /* //m_ExternalLink.Add2Log(WL_ERROR_LEVEL3, "SQL (LONG) Error %d [Error #%d Description \"%s\" (Source: %s)" "(SQL State: %s)](NativeError: %s)", e.Error(), pErr->Number, (LPCSTR)pErr->Description, (LPCSTR)pErr->Source, (LPCSTR)pErr->SQLState, (LPCSTR)pErr->NativeError);*/ } pConn->Close(); if (pComm->ActiveConnection != NULL) { pComm->PutRefActiveConnection(NULL); } } catch(...) { ErrSQLState = 1; } } catch(long errorCode) { //m_ExternalLink.Add2Log(WL_ERROR_LEVEL3,"SQL (LONG) Error Unable Create Command object"); pConn->Close(); throw(errorCode); } catch(...) { //m_ExternalLink.Add2Log(WL_ERROR_LEVEL3,"SQL (LONG) Error Unknown"); ErrSQLState = 1; } if(ErrSQLState) { switch(ErrSQLState) { case 23000: //Violation of PRIMARY KEY constraint throw (ErrorCode = ERR_PRIMARY_KEY_CONSTRAINT); break; default: //Code throw (ErrorCode = ERR_SQL_UNKNOWN_PROBLEM); break; } } //---------------- //Close Connection pComm->PutRefActiveConnection(NULL); pConn->Close(); return dRet; }
void from_file(){ ///\fn void from_file() ///\brief Corectarea unui sir de caractere. /// ///Implementarea corectarii a unui sir de caractere citit din fisier. char fileName[100]; char buff[2255]; char *p; FILE * f_corected = fopen("from file corected.txt","w"); FILE * file; char ch[2],word[150],wordINIT[150]; ch[1]='\0'; List sim_words ; POINT curs, cursBack;// cursor position tryAgain: system("cls"); printf("\n\tPlease enter the name of the file (e.g. : file.txt): "); gets(fileName); if(fileName[strlen(fileName)-1]=='\n') fileName[strlen(fileName)-1]='\0'; if(strlen(fileName)<=2) goto tryAgain; file = fopen(fileName,"r"); if( file == NULL ){ printf("\n\t This file doesn't exist!"); Sleep(2000); goto tryAgain; } GotoXY(3,3); printf(" Here you will see all the informations you need about your text!"); GotoXY(3,9); printf("Your text:"); // complex flush fflush(stdin); while ((ch[0] = getchar()) != '\n' && ch[0] != EOF) continue; GotoXY(3,10);// typing while(1){ word[0]='\0'; ch[0]='\0'; if(kbhit()){ ch[0] = getch(); if(is_letter(ch[0]) == true){ strcat(word,ch ); printf("%c",ch[0]); } } save_curs(&curs); if(!fgets(ch,2,file)){ getchar(); fclose(f_corected); fclose(file); return; } //add a word while( is_letter(ch[0])==true ){ strcat(word,ch); printf("%c",ch[0]); if(GetAsyncKeyState( VK_ESCAPE )& 0x8000){ fclose(f_corected); return; } if(!fgets(ch,2,file)){ getchar(); fclose(f_corected); return; } } strcpy(wordINIT,word); strcpy(word,strlwr(word)); // if an word was typed if(word[0]>='A' && word[0]<='z' && strlen(word)>=2){ if(word[strlen(word)-1]<'A' || word[strlen(word)-1]>'z') word[strlen(word)-1]='\0'; // if the word is incorrect if(list_search(&dict_lex, strlwr(word))==NULL){ Beep(20,200); GotoXY(3,3); printf("The word \"%s\" is incorrect!",word); sim_words.head=NULL; sim_words.tail=NULL; find_sim_words(&sim_words, word, strlen(word), dict_lex.head, dict_lex.tail); if(sim_words.head==NULL){ ClearSelectAreea(); Beep(90,200); GotoXY(3,3); printf("The word \"%s\" is incorrect and there are no word like him!\n",word); Sleep(650); getchar(); } else{ Beep(70,200); List_Node * newTail = malloc(sizeof(List_Node)); newTail->word = malloc(sizeof(char)*strlen(wordINIT)+1); strcpy(newTail->word,wordINIT); list_insert(&sim_words,newTail); Select_correct_word(word, &sim_words); ClearSelectAreea(); GotoXY(3,3); printf("The correct word for \"%s\" is \"%s\"!",wordINIT,word); strcpy(wordINIT,word); free_list(&sim_words); } } else{ ClearSelectAreea(); GotoXY(3,3); printf("The word \"%s\" is correct!\n",word); } } ClearAfterPoint(curs); // back to the saved cursor GotoXY(curs.x, curs.y); // update the word to the cmd and go on printf("%s",wordINIT); printf("%c",ch[0]); fprintf(f_corected,"%s",wordINIT); fprintf(f_corected,"%c",ch[0]); Sleep(50); } getchar(); }
INT CommandChoice (LPTSTR param) { LPTSTR lpOptions; TCHAR Options[6]; LPTSTR lpText = NULL; BOOL bNoPrompt = FALSE; BOOL bCaseSensitive = FALSE; BOOL bTimeout = FALSE; INT nTimeout = 0; TCHAR cDefault = _T('\0'); INPUT_RECORD ir; LPTSTR p, np; LPTSTR *arg; INT argc; INT i; INT val; INT GCret; TCHAR Ch; DWORD amount,clk; LoadString(CMD_ModuleHandle, STRING_CHOICE_OPTION, Options, 4); lpOptions = Options; if (_tcsncmp (param, _T("/?"), 2) == 0) { ConOutResPaging(TRUE,STRING_CHOICE_HELP); return 0; } /* retrieve text */ p = param; while (TRUE) { if (*p == _T('\0')) break; if (*p != _T('/')) { lpText = p; break; } np = _tcschr (p, _T(' ')); if (!np) break; p = np + 1; } /* build parameter array */ arg = split (param, &argc, FALSE); /* evaluate arguments */ if (argc > 0) { for (i = 0; i < argc; i++) { if (_tcsnicmp (arg[i], _T("/c"), 2) == 0) { if (arg[i][2] == _T(':')) lpOptions = &arg[i][3]; else lpOptions = &arg[i][2]; if (_tcslen (lpOptions) == 0) { ConErrResPuts(STRING_CHOICE_ERROR); freep (arg); return 1; } } else if (_tcsnicmp (arg[i], _T("/n"), 2) == 0) { bNoPrompt = TRUE; } else if (_tcsnicmp (arg[i], _T("/s"), 2) == 0) { bCaseSensitive = TRUE; } else if (_tcsnicmp (arg[i], _T("/t"), 2) == 0) { LPTSTR s; if (arg[i][2] == _T(':')) { cDefault = arg[i][3]; s = &arg[i][4]; } else { cDefault = arg[i][2]; s = &arg[i][3]; } if (*s != _T(',')) { ConErrResPuts(STRING_CHOICE_ERROR_TXT); freep (arg); return 1; } s++; nTimeout = _ttoi(s); bTimeout = TRUE; } else if (arg[i][0] == _T('/')) { ConErrResPrintf(STRING_CHOICE_ERROR_OPTION, arg[i]); freep (arg); return 1; } } } /* print text */ if (lpText) ConOutPrintf (_T("%s"), lpText); /* print options */ if (bNoPrompt == FALSE) { ConOutPrintf (_T("[%c"), lpOptions[0]); for (i = 1; (unsigned)i < _tcslen (lpOptions); i++) ConOutPrintf (_T(",%c"), lpOptions[i]); ConOutPrintf (_T("]?")); } ConInFlush (); if(!bTimeout) { while (TRUE) { ConInKey (&ir); val = IsKeyInString (lpOptions, #ifdef _UNICODE ir.Event.KeyEvent.uChar.UnicodeChar, #else ir.Event.KeyEvent.uChar.AsciiChar, #endif bCaseSensitive); if (val >= 0) { ConOutPrintf (_T("%c\n"), lpOptions[val]); nErrorLevel = val + 1; break; } Beep (440, 50); } freep (arg); TRACE ("ErrorLevel: %d\n", nErrorLevel); return 0; } clk = GetTickCount (); amount = nTimeout*1000; loop: GCret = GetCharacterTimeout (&Ch, amount - (GetTickCount () - clk)); switch (GCret) { case GC_TIMEOUT: TRACE ("GC_TIMEOUT\n"); TRACE ("elapsed %d msecs\n", GetTickCount () - clk); break; case GC_NOKEY: TRACE ("GC_NOKEY\n"); TRACE ("elapsed %d msecs\n", GetTickCount () - clk); goto loop; case GC_KEYREAD: TRACE ("GC_KEYREAD\n"); TRACE ("elapsed %d msecs\n", GetTickCount () - clk); TRACE ("read %c", Ch); if ((val=IsKeyInString(lpOptions,Ch,bCaseSensitive))==-1) { Beep (440, 50); goto loop; } cDefault=Ch; break; } TRACE ("exiting wait loop after %d msecs\n", GetTickCount () - clk); val = IsKeyInString (lpOptions, cDefault, bCaseSensitive); ConOutPrintf (_T("%c\n"), lpOptions[val]); nErrorLevel = val + 1; freep (arg); TRACE ("ErrorLevel: %d\n", nErrorLevel); return 0; }
//--------------------------------------------------------------------------- void __fastcall TForm1::BewegingstimerTimer(TObject *Sender) { //Neerzetten met double buffering: //achtergrond ImageCanvas->Picture=BackgroundImage->Picture; //musica Beep(random(500),500); //staff laten bewegen als barman if (b==0) { StaffImage->Left=StaffImage->Left+random(50)-25; if (StaffImage->Left<600) StaffImage->Left=600; if (StaffImage->Left>700) StaffImage->Left=700; ImageCanvas->Canvas->Draw(StaffImage->Left,StaffImage->Top,StaffImage->Picture->Graphic); ImageCanvas->Canvas->Draw(ItemImage->Left,ItemImage->Top,ItemImage->Picture->Graphic); } else //het dwijlorkest { switch (dwijlorkest) { case 0: ImageCanvas->Canvas->Draw(524,100,OrkestImage1->Picture->Graphic); dwijlorkest=1; break; case 1: ImageCanvas->Canvas->Draw(525,100,OrkestImage2->Picture->Graphic); dwijlorkest=0; break; } } //dienblad: ImageCanvas->Canvas->Draw(10,140,ArrowImage->Picture->Graphic); ImageCanvas->Canvas->Draw(8,80,DienbladImage->Picture->Graphic); for (int t=0; t<aantalglazen+1; t++) { switch (t) { case 0: break; case 1: ImageCanvas->Canvas->Draw(48,80,GlasImage->Picture->Graphic); break; case 2: ImageCanvas->Canvas->Draw(63,82,GlasImage->Picture->Graphic); break; case 3: ImageCanvas->Canvas->Draw(28,84,GlasImage->Picture->Graphic); break; case 4: ImageCanvas->Canvas->Draw(14,94,GlasImage->Picture->Graphic); break; case 5: ImageCanvas->Canvas->Draw(30,94,GlasImage->Picture->Graphic); break; case 6: ImageCanvas->Canvas->Draw(47,89,GlasImage->Picture->Graphic); break; case 7: ImageCanvas->Canvas->Draw(61,90,GlasImage->Picture->Graphic); break; case 8: ImageCanvas->Canvas->Draw(56,96,GlasImage->Picture->Graphic); break; case 9: ImageCanvas->Canvas->Draw(88,88,GlasImage->Picture->Graphic); break; case 10: ImageCanvas->Canvas->Draw(90,95,GlasImage->Picture->Graphic); break; case 11: ImageCanvas->Canvas->Draw(74,95,GlasImage->Picture->Graphic); break; } } //de glazen vullen: if(random(3)==1) c[random(10)][1]=1; //kans 1op30; //de glazen tekenen als de bar er is: if (b==0) { for (int we=0; we<10; we++) { switch (c[we][1]) { case 0: break; case 1: ImageCanvas->Canvas->Draw(c[we][0],360,GlasImage->Picture->Graphic); break; } } }//end glazenifstatement //Linker Aliens for (int we=0; we<12; we++) //waar tekent hij ze? { switch (a[we][2+b]) //wat doen ze? +b=voor veld 2 { case 0: //leeg break; case 1: //geen glas -snik- ImageCanvas->Canvas->Draw(a[we][0],a[we][1],L0Image->Picture->Graphic); break; case 2: //wel glas, al dan niet drinken switch (random(2)) { case 0: ImageCanvas->Canvas->Draw(a[we][0],a[we][1],L2Image->Picture->Graphic); break; case 1: ImageCanvas->Canvas->Draw(a[we][0],a[we][1],L1Image->Picture->Graphic); break; } break; } } //Rechter Aliens for (int we=12; we<24; we++) //waar tekent hij ze? { switch (a[we][2+b]) //wat doen ze? //b voor veld 2 { case 0: //leeg break; case 1: //geen glas -snik- ImageCanvas->Canvas->Draw(a[we][0],a[we][1],R0Image->Picture->Graphic); break; case 2: //wel glas, al dan niet drinken switch (random(2)) { case 0: ImageCanvas->Canvas->Draw(a[we][0],a[we][1],R2Image->Picture->Graphic); break; case 1: ImageCanvas->Canvas->Draw(a[we][0],a[we][1],R1Image->Picture->Graphic); break; } break; } } //de muur: ImageCanvas->Canvas->Draw(673,124,WallImage->Picture->Graphic); //klaar Form1->Canvas->Draw(0,0,ImageCanvas->Picture->Graphic); }
/* export_cb : Export Callback Export to file the entry highlighted in the browser. */ void export_cb(FL_OBJECT *a, long l) { Int4 index; int RetVal; unsigned char *pImgBuf; short Width; short Height; const char *format; RetVal = fl_get_browser(wad_brow); if ( RetVal == 1 ) /* first line is the legend */ return; index = LinearMap[RetVal]; switch (pEntryTag[index]) { case TAG_MUS : GenFileName(pDirEnt[index].name, ".mus", TmpNameStr); RetVal = Gen_MUS_File(WADfp, pDirEnt[index], TmpNameStr); break; case TAG_SFX : GenFileName(pDirEnt[index].name, ".wav", TmpNameStr); RetVal = Gen_WAV_File(WADfp, pDirEnt[index], TmpNameStr); break; case TAG_FLAT : case TAG_FULL : case TAG_IMG : pImgBuf = ParseImgBlock(pDirEnt[index], pEntryTag[index], &Width, &Height, NULL, NULL, WADfp); if (pImgBuf == NULL) { RetVal = 4; break; } format = fl_get_choice_text( exp_img_fmt_cho ); if ( !strcmp(format, PCX_STR ) ) { /* pcx */ GenFileName(pDirEnt[index].name, ".pcx", TmpNameStr); RetVal = PCX_WriteImage(pDirEnt[index], WADfp, Width, Height, pImgBuf, 1, TmpNameStr); } else { /* xpm */ char **xpm; GenFileName(pDirEnt[index].name, ".xpm", TmpNameStr); /* don't just redraw, we don't know what's in the xpm: */ xpm = CreateXpmImage( pImgBuf, Width, Height, 0, NULL ); if ( xpm && CreateXpmFile( xpm, TmpNameStr ) ) RetVal = 0; else RetVal = 666; /* why not? */ } break; case TAG_HIRES: GenFileName(pDirEnt[index].name, ".pcx", TmpNameStr); RetVal = PCX_WriteImage(pDirEnt[index], WADfp, 640, 480, pBitMap, 4, TmpNameStr); break; default: RetVal = 1; break; } if (RetVal != 0) { Beep(); Message("error generating external file \"%s\" (%d)\n", TmpNameStr, RetVal); } else Message("External file \"%s\" created OK\n", TmpNameStr); }
void CWipeFree::OnDmWipe() { LVITEM lvitem; int nSel; int i; YG_PARTITION_INFO *pTargetParInfo = NULL; CWipeProc WipeProcDlg; BOOL bSel = FALSE; CString cstr,csCaption; TCHAR szCurDir[MAX_PATH]; TCHAR szDir[32]; UpdateData(TRUE); g_bBeepOff = m_BeepOff.GetCheck(); nSel = m_SelMothed.GetCurSel (); g_nWipeMothed = nSel; csCaption.LoadString (IDS_DM_ERROR); lvitem.mask = LVIF_IMAGE; lvitem.iSubItem = 0; for(i = 0; i < m_WipeParList.GetItemCount (); i++) { lvitem.iItem = i; m_WipeParList.GetItem(&lvitem); if(lvitem.iImage == IMG_LIST_SELECT) { pTargetParInfo = (YG_PARTITION_INFO*)m_WipeParList.GetItemData (i); g_pTargetParInfo = pTargetParInfo; bSel = TRUE; break; } } if(bSel) { if(g_pTargetParInfo->DriveLetter == _T('*')) { cstr.LoadString (IDS_Q_FORMAT_PARTITION); csCaption.LoadString (IDS_DM_INFO); MessageBox(cstr,csCaption,MB_OK); return ; } ZeroMemory(szDir, 32 * sizeof(TCHAR)); _tcscpy(szDir,_T("C:\\")); szDir[0] = g_pTargetParInfo->DriveLetter; GetCurrentDirectory(MAX_PATH,szCurDir); if(!SetCurrentDirectory(szDir)) { cstr.LoadString (IDS_Q_FORMAT_PARTITION); csCaption.LoadString (IDS_DM_INFO); MessageBox(cstr,csCaption,MB_OK); return ; } SetCurrentDirectory(szCurDir); cstr.Format (IDS_CONFIRM_WIPE_FREE,g_pTargetParInfo->DriveLetter); csCaption.LoadString (IDS_DM_CONFIRM_CAPTITION); if(IDYES == MessageBox (cstr,csCaption,MB_YESNO)) { WipeProcDlg.m_DriveLetter = g_pTargetParInfo->DriveLetter; if (!g_bBeepOff) Beep(1000,100); WipeProcDlg.DoModal (); } } }
int main(int argc, void **argv) { char *pszdir; char *pszWadName; char *pszScriptName; char szBuf[1024]; HANDLE hFile, hScriptFile; WIN32_FIND_DATA FindData; BOOL fWrite; BOOL fContinue = TRUE; DWORD dwWritten; printf("makels Copyright (c) 1998 Valve L.L.C., %s\n", __DATE__ ); pszdir = (char *)argv[1]; if ((argc != 4) || (pszdir[0] == '/') || (pszdir[0] == '-')) { PrintUsage((char *)argv[0]); exit(1); } pszdir = (char *)malloc(strlen((char *)argv[1]) + 7); strcpy(pszdir, (char *)argv[1]); strcat(pszdir, "\\*.bmp"); pszWadName = (char *)malloc(strlen((char *)argv[2]) + 5); strcpy(pszWadName, (char *)argv[2]); strcat(pszWadName, ".WAD"); pszScriptName = (char *)malloc(strlen((char *)argv[3])); strcpy(pszScriptName, (char *)argv[3]); hScriptFile = CreateFile(pszScriptName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hScriptFile == INVALID_HANDLE_VALUE) { printf("\n---------- ERROR ------------------\n"); printf(" Could not open the script file: %s\n", pszScriptName); Beep(800,500); exit(EXIT_FAILURE); } sprintf(szBuf, "$DEST \"%s\"\r\n\r\n", pszWadName); fWrite = WriteFile(hScriptFile, szBuf, strlen(szBuf), &dwWritten, NULL); if (!fWrite || (dwWritten != strlen(szBuf))) { write_error: printf("\n---------- ERROR ------------------\n"); printf(" Could not write to the script file: %s\n", pszScriptName); Beep(800,500); CloseHandle(hScriptFile); exit(EXIT_FAILURE); } hFile = FindFirstFile(pszdir, &FindData); if (hFile != INVALID_HANDLE_VALUE) { while (fContinue) { if (!(FindData.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN))) { char szShort[MAX_PATH]; // ignore N_ and F_ files strcpy(szShort, FindData.cFileName); strupr(szShort); if ((szShort[1] == '_') && ((szShort[0] == 'N') || (szShort[0] == 'F'))) { printf("Skipping %s.\n", FindData.cFileName); } else { if ( nFiles >= nMaxFiles ) { nMaxFiles += 1000; ppszFiles = (char **)realloc( ppszFiles, nMaxFiles * sizeof(*ppszFiles) ); if ( !ppszFiles ) { printf("\n---------- ERROR ------------------\n"); printf(" Could not realloc more filename pointer storage\n"); Beep(800,500); exit(EXIT_FAILURE); } } ppszFiles[nFiles++] = strdup( szShort ); } } fContinue = FindNextFile(hFile, &FindData); } } if (nFiles > 0) { qsort( ppszFiles, nFiles, sizeof(char*), string_comparator ); for( int i = 0; i < nFiles; i++ ) { char *p; char szShort[MAX_PATH]; char szFull[MAX_PATH]; strcpy(szShort, pszdir); p = strchr(szShort, '*'); *p = '\0'; strcat(szShort, ppszFiles[i]); GetFullPathName(szShort, MAX_PATH, szFull, NULL); sprintf(szBuf, "$loadbmp \"%s\"\r\n", szFull); fWrite = WriteFile(hScriptFile, szBuf, strlen(szBuf), &dwWritten, NULL); if (!fWrite || (dwWritten != strlen(szBuf))) goto write_error; p = strchr(ppszFiles[i], '.'); *p = '\0'; sprintf(szBuf, "%s miptex -1 -1 -1 -1\r\n\r\n", ppszFiles[i]); fWrite = WriteFile(hScriptFile, szBuf, strlen(szBuf), &dwWritten, NULL); if (!fWrite || (dwWritten != strlen(szBuf))) goto write_error; free( ppszFiles[i] ); } } printf("Processed %d files specified by %s\n", nFiles, pszdir ); CloseHandle(hScriptFile); free(pszdir); exit(0); return 0; }
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static struct { int nota; int lugar; //int largo; }notas[NOTA_MAX]; static int largo=100; static int pos=0; switch (message) /* handle the messages */ { case WM_KEYDOWN: if(pos<NOTA_MAX-1) switch(wParam) { case 96: Beep(SIg, largo); notas[pos].nota=SIg; notas[pos].lugar=72; pos++; break; case 97: Beep(DO, largo); notas[pos].nota=DO; notas[pos].lugar=66; pos++; break; case 98: Beep(RE, largo); notas[pos].nota=RE; notas[pos].lugar=60; pos++; break; case 99: Beep(MI, largo); notas[pos].nota=MI; notas[pos].lugar=54; pos++; break; case 100: Beep(FA, largo); notas[pos].nota=FA; notas[pos].lugar=48; pos++; break; case 101: Beep(SOL, largo); notas[pos].nota=SOL; notas[pos].lugar=42; pos++; break; case 102: Beep(LA, largo); notas[pos].nota=LA; notas[pos].lugar=36; pos++; break; case 103: Beep(SI, largo); notas[pos].nota=SI; notas[pos].lugar=30; pos++; break; case 104: Beep(DOa, largo); notas[pos].nota=DOa; notas[pos].lugar=24; pos++; break; case 105: Beep(REa, largo); notas[pos].nota=REa; notas[pos].lugar=18; pos++; break; } //MessageBox(0,0,0,0); //UpdateWindow(hwnd); break; case WM_PAINT: PAINTSTRUCT ps; HDC hDC; hDC = BeginPaint(hwnd, &ps); for(int i=0;i<pos;i++) Ellipse(hDC, 25+i*15, notas[i].lugar, 37+i*15, notas[i].lugar+12); hacerlinea(hDC, 0, 12, 625, 12); hacerlinea(hDC, 0, 24, 625, 24); hacerlinea(hDC, 0, 36, 625, 36); hacerlinea(hDC, 0, 48, 625, 48); hacerlinea(hDC, 0, 60, 625, 60); hacerlinea(hDC, 10, 10, 10, 62); EndPaint(hwnd, &ps); break; case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }
void BL_Bootloader(void) { S191_FileStatus fileStatus; DisableInterrupts; #if PL_HAS_HW_SOUNDER Beep(1); #endif #if PL_BOOTLOADER_LCD if (JM_ELE_GetVal()!=0) { /* JM_ELE switch is off: the JM128 is controlling the LCD */ LCD1_Init(); LCD1_Clear(); } PrintLCDText(0, "Bootloader mode: waiting for S19 file..."); #endif BLUSB1_InitUSB(); fileStatus = S191_FILE_STATUS_NOT_STARTED; for(;;) { BLUSB1_PollAndProcessUSB(&fileStatus); /* Poll USB device for any input device */ if(fileStatus==S191_FILE_STATUS_READING) { #if PL_BOOTLOADER_LCD PrintLCDText(1, "Loading S19 file..."); #endif BL_flashErased = FALSE; BLUSB1_ReadAndProcessS19(&fileStatus); switch(fileStatus) { case S191_FILE_STATUS_FINISHED: #if PL_BOOTLOADER_LCD PrintLCDText(2, "Loading successful!\nYou can reset the board now."); #endif #if PL_HAS_HW_SOUNDER Beep(1); #endif break; case S191_FILE_ERASE_FAILED: #if PL_BOOTLOADER_LCD PrintLCDText(2, "*** Flash erase error! ***"); #endif #if PL_HAS_HW_SOUNDER Beep(4); #endif break; case S191_FILE_FLASH_FAILED: #if PL_BOOTLOADER_LCD PrintLCDText(2, "*** Flash programming error! ***"); #endif #if PL_HAS_HW_SOUNDER Beep(6); #endif break; default: #if PL_BOOTLOADER_LCD PrintLCDText(2, "*** Error processing file! ***"); #endif #if PL_HAS_HW_SOUNDER Beep(8); #endif break; } /* switch */ } /* if */ } /* for */ }
void live_input(){ ///\fn void live_input() ///\brief Corectare in timp real. /// ///Implementarea corectarii in timp real ale cuvintelor introduse de la tastatura. FILE * f_corected = fopen("live_input f_corected.txt","w"); FILE * f_inserted = fopen("live_input f_inserted.txt","w"); char ch[2],word[50],wordINIT[50]; ch[1]='\0'; List sim_words ; POINT curs, cursBack;// cursor position ClearSelectAreea(); GotoXY(3,3); printf(" Here you will see all the informations you need about your text "); GotoXY(3,9); printf("Your text:"); // complex flush fflush(stdin); while ((ch[0] = getchar()) != '\n' && ch[0] != EOF) continue; GotoXY(3,10);// typing while(1){ word[0]='\0'; ch[0]='\0'; save_curs(&curs); //add a word while( is_letter(ch[0])==true ){ if(kbhit()){ ch[0] = getch(); if(is_letter(ch[0]) == true){ strcat(word,ch); printf("%c",ch[0]); } } if(GetAsyncKeyState( VK_BACK )& 0x8000){ if( strlen(word) != 0){ save_curs(&cursBack); GotoXY( cursBack.x-1, cursBack.y); printf(" "); word[strlen(word)-1]='\0'; GotoXY(curs.x,curs.y); printf("%s",word); GotoXY(cursBack.x-1, cursBack.y); Sleep(100); } } if(GetAsyncKeyState( VK_ESCAPE )& 0x8000){ return; fclose(f_inserted); fclose(f_corected); } if(GetAsyncKeyState( VK_RETURN )& 0x8000) break; } strcpy(wordINIT,word); strcpy(word,strlwr(word)); // if an word was typed if(word[0]>='A' && word[0]<='z' && strlen(word)>=2){ if(word[strlen(word)-1]<'A' || word[strlen(word)-1]>'z') word[strlen(word)-1]='\0'; fprintf(f_inserted,"%s",word); fprintf(f_inserted,"%c",ch[0]); // if the word is incorrect if(list_search(&dict_lex, word)==NULL){ Beep(20,200); find_sim_words(&sim_words, word, strlen(word), dict_lex.head, dict_lex.tail); if(sim_words.head==NULL){ ClearSelectAreea(); Beep(90,200); ClearSelectAreea(); GotoXY(3,3); printf("The word \"%s\" is incorrect and there are no word like him!\n",word); Sleep(650); getchar(); } else{ Beep(70,200); List_Node * newTail = malloc(sizeof(List_Node)); newTail->word = malloc(sizeof(char)*strlen(wordINIT)+1); strcpy(newTail->word,wordINIT); list_insert(&sim_words,newTail); Select_correct_word(word, &sim_words); ClearSelectAreea(); GotoXY(3,3); printf("The correct word for \"%s\" is \"%s\"!",wordINIT,word); free_list(&sim_words); strcpy(wordINIT,word); } } else{ ClearSelectAreea(); GotoXY(3,3); printf("The word \"%s\" is correct!\n",word); } } ClearAfterPoint(curs); // back to the saved cursor GotoXY(curs.x, curs.y); // update the word to the cmd and go on printf("%s",wordINIT); printf("%c",ch[0]); fprintf(f_corected,"%s",wordINIT); fprintf(f_corected,"%c",ch[0]); Sleep(50); } }
/* * This function sets the information inside the file selector. */ void setCDKFselect (CDKFSELECT *fselect, char *directory, chtype fieldAttrib, chtype filler, chtype highlight, char *dirAttribute, char *fileAttribute, char *linkAttribute, char *sockAttribute, boolean Box GCC_UNUSED) { /* Declare local variables. */ CDKSCROLL *fscroll = fselect->scrollField; CDKENTRY *fentry = fselect->entryField; char *tempDir = 0; char *mesg[10], newDirectory[2000], temp[100]; int ret; /* Keep the info sent to us. */ fselect->fieldAttribute = fieldAttrib; fselect->fillerCharacter = filler; fselect->highlight = highlight; strcpy (newDirectory, directory); /* Set the attributes of the entry field/scrolling list. */ setCDKEntryFillerChar (fentry, filler); setCDKScrollHighlight (fscroll, highlight); /* Only do the directory stuff if the directory is not null. */ if (directory != 0) { /* Try to expand the directory if it starts with a ~ */ if (directory[0] == '~') { tempDir = expandFilename (directory); if (tempDir != 0) { strcpy (newDirectory, tempDir); freeChar (tempDir); } } /* Change directories. */ ret = chdir (newDirectory); if (ret != 0) { /* Beep at them. */ Beep(); /* Couldn't get into the directory, pop up a little message. */ sprintf (temp, "<C>Could not change into %s", newDirectory); mesg[0] = copyChar (temp); #ifdef HAVE_STRERROR sprintf (temp, "<C></U>%s", strerror(errno)); mesg[1] = copyChar (temp); #else sprintf (temp, "<C></U>Unknown reason."); mesg[1] = copyChar (temp); #endif mesg[2] = " "; mesg[3] = "<C>Press Any Key To Continue."; /* Pop Up a message. */ popupLabel (ScreenOf(fselect), mesg, 4); /* Clean up some memory. */ freeCharList (mesg, 4); /* Get out of here. */ eraseCDKFselect (fselect); drawCDKFselect (fselect, ObjOf(fselect)->box); return; } } /* * If the information coming in is the same as the information * that is already there, there is no need to destroy it. */ if (fselect->pwd != directory) { setPWD(fselect); } if (fselect->fileAttribute != fileAttribute) { /* Remove the old pointer and set the new value. */ freeChar (fselect->fileAttribute); fselect->fileAttribute = copyChar (fileAttribute); } if (fselect->dirAttribute != dirAttribute) { /* Remove the old pointer and set the new value. */ freeChar (fselect->dirAttribute); fselect->dirAttribute = copyChar (dirAttribute); } if (fselect->linkAttribute != linkAttribute) { /* Remove the old pointer and set the new value. */ freeChar (fselect->linkAttribute); fselect->linkAttribute = copyChar (linkAttribute); } if (fselect->sockAttribute != sockAttribute) { /* Remove the old pointer and set the new value. */ freeChar (fselect->sockAttribute); fselect->sockAttribute = copyChar (sockAttribute); } /* Set the contents of the entry field. */ setCDKEntryValue (fentry, fselect->pwd); drawCDKEntry (fentry, ObjOf(fentry)->box); /* Get the directory contents. */ if (setCDKFselectDirContents (fselect) == 0) { Beep(); return; } /* Set the values in the scrolling list. */ setCDKScrollItems (fscroll, fselect->dirContents, fselect->fileCounter, FALSE); }
void one_word(){ ///\fn void one_word() ///\brief Corectarea un cuvant introdus. /// ///Implementarea corectarii a unui cuvant introdus de la tastatura. char word[50]; // cuvantul care va fi verificat List sim_words ; // lista cuvintelor asemanatoare cu cuvantul citit // golirea bufferului fflush(stdin); char ch; while ((ch = getchar()) != '\n' && ch != EOF) continue; system("cls"); printf("\n\t\tOne word function: \n\n"); while( 1 ){ //repeat while ESC isn't pressed tryAgain: system("cls"); printf("\n\tPlease enter the word: "); gets(word); if(word[strlen(word)-1]=='\n') word[strlen(word)-1]='\0'; if(strlen(word)<=2) goto tryAgain; // if the word is incorrect if(list_search(&dict_lex, word)==NULL){ Beep(20,200); find_sim_words(&sim_words, word, strlen(word), dict_lex.head, dict_lex.tail); if(sim_words.head==NULL){ ClearSelectAreea(); Beep(90,200); GotoXY(3,3); printf("The word \"%s\" is incorrect and there are no word like him!\n",word); getchar(); return; } else{ Beep(70,200); List_Node * newTail = malloc(sizeof(List_Node)); newTail->word = malloc(sizeof(char)*strlen(word)+1); strcpy(newTail->word,word); list_insert(&sim_words,newTail); Select_correct_word(word, &sim_words); free_list(&sim_words); return; } } else{ ClearSelectAreea(); GotoXY(3,3); printf("The word \"%s\" is correct!\n",word); return; } } }
void key_SetAddresses(void) { static uchar ibCan; if (bKey == bKEY_ENTER) { if (enKeyboard == KBD_ENTER) { enKeyboard = KBD_INPUT1; Number(); ShowHi(szAddresses); } else if (enKeyboard == KBD_INPUT1) { enKeyboard = KBD_POSTENTER; ibCan = 0; Show(ibCan); } else if (enKeyboard == KBD_POSTINPUT1) { if ((ibCan = GetCharLo(10,11) - 1) < bCANALS) { enKeyboard = KBD_POSTENTER; Show(ibCan); } else Beep(); } else if (enKeyboard == KBD_POSTENTER) { if (++ibCan >= bCANALS) ibCan = 0; Show(ibCan); } else if (enKeyboard == KBD_POSTINPUT3) { ulong dw; if ((dw = GetLongLo(8,15)) <= 100000000) { enKeyboard = KBD_POSTENTER; ibRecordCan = ibCan; AddSysRecordReprogram(EVE_EDIT_ADDRESS20); mpdwAddress2[ibCan] = dw; SaveCache(&chAddress2); AddSysRecordReprogram(EVE_EDIT_ADDRESS21); if (++ibCan >= bCANALS) ibCan = 0; Show(ibCan); } else Beep(); } else Beep(); } else if (bKey == bKEY_POINT) { if (enKeyboard == KBD_POSTENTER) { if (ibCan > 0) ibCan--; else ibCan = bCANALS-1; Show(ibCan); } else if (enKeyboard == KBD_POSTINPUT2) { ulong dw; if ((dw = GetLongHi(8,15)) <= 100000000) { enKeyboard = KBD_INPUT3; sprintf(szLo+8,szMaskAddresses); ibRecordCan = ibCan; AddSysRecordReprogram(EVE_EDIT_ADDRESS10); mpdwAddress1[ibCan] = dw; SaveCache(&chAddress1); AddSysRecordReprogram(EVE_EDIT_ADDRESS11); } else Beep(); } else Beep(); } else if (bKey < 10) { if (enKeyboard == KBD_POSTENTER) { if ((enGlobal == GLB_PROGRAM) || (enGlobal == GLB_REPROGRAM)) { enKeyboard = KBD_INPUT2; sprintf(szHi+8,szMaskAddresses); sprintf(szLo+8,szNullAddresses); } else Beep(); } if ((enKeyboard == KBD_INPUT1) || (enKeyboard == KBD_POSTINPUT1)) { enKeyboard = KBD_POSTINPUT1; ShiftLo(10,11); } else if ((enKeyboard == KBD_INPUT2) || (enKeyboard == KBD_POSTINPUT2)) { enKeyboard = KBD_POSTINPUT2; ShiftHi(8,15); } else if ((enKeyboard == KBD_INPUT3) || (enKeyboard == KBD_POSTINPUT3)) { enKeyboard = KBD_POSTINPUT3; ShiftLo(8,15); } else Beep(); } else Beep(); }
void Metak::zvuk_metka() { Beep(5000,10); }
void CADOUtil::RunSP_ReturnRS(_bstr_t SP_Name, _RecordsetPtr& out_pRs, CParamArray *ParamArray) { if(!CheckCurrentProcess()) throw ERR_NEW_PROCESS_DETECTED; _ConnectionPtr pConn = NULL; _ParameterPtr pPrm = NULL; _ParameterPtr pprm = NULL; ErrorPtr pErr = NULL; _CommandPtr pComm = NULL; CParam* pr = NULL; LONG ErrSQLState = 0; LONG count = 0; LONG ErrorCode = 0; _variant_t vIndex; _bstr_t bsEmpty; //******************************************************************** //Connectin to Pool try { _bstr_t bstrConnString(szConnectionString); pConn.CreateInstance(__uuidof(Connection)); if(pConn == NULL) { throw(ErrorCode = ERR_UNABLE_CREATE_CONN); } pConn->ConnectionTimeout = 7; pConn->Open(bstrConnString, L"", L"", adConnectUnspecified); } catch(...) { Beep(2000, 100); //m_ExternalLink.Add2Log(WL_ERROR_LEVEL1,"Unable set connection to SQL Error = Unknown"); ErrorCode = ERR_UNABLE_CREATE_CONN; } if(ErrorCode) throw ErrorCode; //******************************************************************* //Execut command try { pComm.CreateInstance(__uuidof(Command)); if(pComm == NULL) { throw(ErrorCode = ERR_UNABLE_CREATE_COMM); } out_pRs.CreateInstance(__uuidof(Recordset)); if(out_pRs == NULL) { throw(ErrorCode = ERR_UNABLE_CREATE_RECSET); } pComm->ActiveConnection = pConn; pComm->CommandText = SP_Name; pComm->CommandType = adCmdStoredProc; if(ParamArray != NULL) { DWORD Count = ParamArray->GetSize(); for (DWORD i=0; i < Count; i++) { pr = (*ParamArray)[i]; pprm = pComm->CreateParameter(bsEmpty, pr->Type, pr->Direction, pr->Size, pr->Value); pComm->Parameters->Append(pprm); } } out_pRs->CursorLocation = adUseClient; out_pRs->Open(_variant_t((IDispatch *)pComm, true), vtMissing, adOpenForwardOnly, adLockReadOnly, NULL); out_pRs->PutRefActiveConnection(NULL); pConn->Close(); return; } //Handle Execut error catch(_com_error) { try { count = pConn->Errors->Count; if(count) { vIndex = _variant_t((LONG)0); pErr = pConn->Errors->GetItem(vIndex); ErrSQLState = atol((LPCSTR)pErr->SQLState); /* //m_ExternalLink.Add2Log(WL_ERROR_LEVEL3, "SQL (RS) Error %d [Error #%d Description \"%s\" (Source: %s)" "(SQL State: %s)](NativeError: %s)", e.Error(), pErr->Number, (LPCSTR)pErr->Description, (LPCSTR)pErr->Source, (LPCSTR)pErr->SQLState, (LPCSTR)pErr->NativeError);*/ } pConn->Close(); if (pComm->ActiveConnection != NULL) { pComm->PutRefActiveConnection(NULL); } } catch(...) { ErrSQLState = 1; } } catch(long errorCode) { //m_ExternalLink.Add2Log(WL_ERROR_LEVEL3,"SQL (RS) Error Unable Create Command object"); pConn->Close(); throw(errorCode); } catch(...) { //m_ExternalLink.Add2Log(WL_ERROR_LEVEL3,"SQL (RS) Error Unknown"); ErrSQLState = 1; } if(ErrSQLState) { switch(ErrSQLState) { case 23000: //Violation of PRIMARY KEY constraint throw (ErrorCode = ERR_PRIMARY_KEY_CONSTRAINT); break; default: //Code throw (ErrorCode = ERR_SQL_UNKNOWN_PROBLEM); break; } } }
void __fastcall TForm1::Button4Click(TObject *Sender) { Beep(Edit4->Text.ToInt(),200); }
void gdk_display_beep (GdkDisplay *display) { g_return_if_fail (display == gdk_display_get_default()); Beep(1000, 50); }
boolean Plugin_017(byte function, struct NodoEventStruct *event, char *string) { boolean success=false; int x; switch(function) { case PLUGIN_INIT: { for(x=0;x<WIRED_PORTS;x++) pinMode(PIN_WIRED_OUT_1+x,INPUT); // definieer Arduino pin's voor Wired-Out } case PLUGIN_EVENT_IN: { if(event->Type == NODO_TYPE_EVENT && event->Command == EVENT_USEREVENT && event->Par1 == 255 && event->Par2 == 255) { switch(event->Port) { case VALUE_SOURCE_IR: bitWrite(HW_Config,HW_IR_TX,true); break; case VALUE_SOURCE_RF: bitWrite(HW_Config,HW_RF_TX,true); break; } } } case PLUGIN_ONCE_A_SECOND: { if(Active) { switch(HWSecCounter++) { case 1: HWSendTestEvent(VALUE_SOURCE_RF); break; case 5: HWSendTestEvent(VALUE_SOURCE_IR); break; case 7: HWSendTestEvent(VALUE_SOURCE_I2C); break; case 8: { CheckWiredLines(); ShowTestResults(); if(HW_ConfigCheck) { if(HW_Config==HW_ConfigCheck) { for(x=0;x<=4;x++) { Beep(2500,25); delay(100); } Serial.println(F("NodoTest: HWConfig is correct!")); } else { Beep(500,1000); Serial.println(F("NodoTest: HWConfig is NOT correct!")); } } Active=false; } } } break; } case PLUGIN_COMMAND: { Beep(1000,250); Settings.TransmitIR=VALUE_ON; Settings.TransmitRF=VALUE_ON; Settings.RawSignalReceive=VALUE_OFF; HWSecCounter=0; for(x=0;x<WIRED_PORTS;x++) { Settings.WiredInputPullUp[x]=VALUE_ON; pinMode(A0+PIN_WIRED_IN_1+x,INPUT_PULLUP); } HW_ConfigCheck=event->Par2; Active=true; Serial.println(F("NodoTest: Running...(please wait a few seconds)\n")); Beep(1000,50); success=true; break; } #if NODO_MEGA // alleen relevant voor een Nodo Mega want de Small heeft geen MMI! case PLUGIN_MMI_IN: { char *TempStr=(char*)malloc(INPUT_COMMAND_SIZE); if(GetArgv(string,TempStr,1)) { if(strcasecmp(TempStr,PLUGIN_NAME)==0) { event->Type = NODO_TYPE_PLUGIN_COMMAND; event->Command = PLUGIN_ID; // nummer van dit plugin if(GetArgv(string,TempStr,2)) event->Par2 = str2int(TempStr); success=true; } } free(TempStr); break; } case PLUGIN_MMI_OUT: { strcpy(string,PLUGIN_NAME); // Commando strcat(string," "); strcat(string,int2str(event->Par2)); break; } #endif //MMI } return success; }
void checklala(int i,int j,int *arr[3][3],int player,int *arr2[9][8],int *a) { if(player==shortcut2(i,arr))// player 2 1 a zete parbena & player 1 2 te zete parbena. { i=i-1; if(i>8||i<0) { printf("Error..! You have range between 1 to 9\n"); Beep(250,250); } else if(i==4) { if(j==arr2[i][0]||j==arr2[i][1]||j==arr2[i][2]||j==arr2[i][3]||j==arr2[i][4]||j==arr2[i][5]||j==arr2[i][6]||j==arr2[i][7]) { if(shortcut2(j,arr)==0) { move(arr,i+1,j,player); printf("A=%d\n",++*a); } else { printf("Error\n"); Beep(250,250); } } else { printf("Error\n"); Beep(250,250); } } else { if(j==arr2[i][0]||j==arr2[i][1]||j==arr2[i][2]) { if(shortcut2(j,arr)==0) { move(arr,i+1,j,player); printf("A=%d\n",++*a); } else { printf("Error\n"); Beep(250,250); } } else { printf("Error\n"); Beep(250,250); } } } system("cls"); }
/********************************************************************* * _beep (MSVCRT.@) */ void CDECL MSVCRT__beep( unsigned int freq, unsigned int duration) { TRACE(":Freq %d, Duration %d\n",freq,duration); Beep(freq, duration); }
/****************************************************************************** 函数名称:print_work_note_history 功能描述:打印日结算历史票据 参数名称:输入/输出? 类型 描述 输入 返 回 值: 作 者 :于福勇 日 期:2004-09-02 修改历史: 日期 修改人 修改描述 ------ --------- ------------- ******************************************************************************/ void print_work_note_his (INT8U * rec) { uchar ucRet; INT8U RecBuff[70]; INT8U strbuff[50]; INT8U time[7+2]; _BANLANCE_IN_HAND * prec = (_BANLANCE_IN_HAND *)rec; EA_vCls(); EA_vDisplay(1, " 日结帐单打印 ");//(int qx, int qy, char * ceStr, int xyFlag) EA_vDisplay(2, " 请等待... ");//(int qx, int qy, char * ceStr, int xyFlag) SleepMs(1500); memset(RecBuff, 0, sizeof(RecBuff)); ///打印头 (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)"日结帐单历史记录\r\n"); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)"------------------------------\r\n"); //消费次数 sprintf((void *)strbuff, "加油次数:%6d次\r\n", prec->consume_cnt); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)strbuff); //消费金额 sprintf((void *)strbuff, "加油体积:%6.2f元\r\n", (float)(prec->consume_amt)/100); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)strbuff); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)"------------------------------\r\n"); //上班时间 memcpy(time, (INT8U*)&prec->work_datetime, 7); htoa(RecBuff, time, 7); sprintf((void *)strbuff, "上班时间:%s\r\n", RecBuff); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)strbuff); //下班时间 memcpy(time, (INT8U*)&prec->down_datetime,7); htoa(RecBuff, time, 7); sprintf((void *)strbuff, "下班时间:%s\r\n",RecBuff); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)strbuff); //分行符号 strcpy((void *)strbuff, "---------------------------------- \r\r\r"); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)strbuff); //设备编号 htoa(RecBuff+4, &prec->equ_id[0], 3); sprintf((void *)strbuff, "设备编号:%s\r\n", RecBuff); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)strbuff); //商户号 htoa(RecBuff, &prec->acnt_id[0], 2); sprintf((void *)strbuff, "站点号:%s\r\n", RecBuff); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)strbuff); //操作员号 htoa(RecBuff, &prec->oper_id[0], 2); sprintf((void *)strbuff, "加油员工号:%s\r\n", RecBuff); (void)EA_ucLinePrinter(hDprinterHandle, 0, (char *)strbuff); // 打印最后调用换页命令 ucRet = EA_ucLinePrinter(hDprinterHandle, 0, "\f"); if ( ucRet == EM_SUCCESS ) { EA_vDisplay(2, "本次打印结束!"); Beep(1000); EA_uiInkeyMs(2000); } }
void Console::Beep(void) const { // 800/200 is what .NET uses by default use the same values Beep(800, 200); }
// need to copy from s to Buf VOID AddToBuffer(LPCTSTR s) { if (FormatChanged) { if (NowFormat.BackColor != BufFormat.BackColor || NowFormat.ForeColor != BufFormat.ForeColor || NowFormat.Bold != BufFormat.Bold || NowFormat.Underline != BufFormat.Underline || NowFormat.Italic != BufFormat.Italic ) { FlushBuffer(TRUE); BufFormat = NowFormat; } FormatChanged = FALSE; } if (InEscBuf) { for (; *s != 0; s++) { if (*s == TEXT('m')) { Format f = NowFormat; if (ParseEscapeCode(&f)) { FormatChanged = TRUE; NowFormat = f; } InEscBuf = FALSE; AddToBuffer(s+1); return; } else if ((*s >= TEXT('0') && *s <= TEXT('9')) || (*s == TEXT(';')) || (*s == TEXT('['))) { EscBuf[EscBufPos++] = *s; EscBufPos = min(EscBufPos, MAX_ESC_BUFSIZE); } else { InEscBuf = FALSE; AddToBuffer(EscBuf); break; } } } for (; *s != TEXT('\0'); s++) { if (*s == TEXT('\b')) { if (BufPos == 0) { OutputPos--; } else BufPos--; } else if (*s == TEXT('\07')) { Beep( 750, 150 ); } else if (*s == TEXT('\033')) { InEscBuf = TRUE; EscBufPos = 0; AddToBuffer(s+1); return; } else { if (BufLen >= BufSize) FlushBuffer(TRUE); Buf[BufPos++] = *s; BufLen = max(BufLen, BufPos); } } EnsureTimer(); }
/***************************************************************** 函数原型:main() 功能描述:主函数 参数描述: 返回值: 无 作 者: 许岩/刘及华 日 期: 2012-11-24 修改历史: 日期 修改人 修改描述 ------ --------- ------------- *****************************************************************/ int main(void) { INT8U ret = 0; char mainflag = 1; INT8S buf[30]; uchar uckey; uint uikey; BUS_TIME ltime; (void)EA_ucSetStopFlag( EM_DISABLE_STOP ); //不允许系统进入睡眠状态; reboot: ret = System_Init(); //系统初始化,包括PSAM,参数表,GPRS初始化 if( ret != ok ) { lcddisperr("系统初始化失败!"); goto reboot; } Beep(1000); for ( ;; ) { Get_Time(<ime); sprintf((void *)buf, " %02X%02X-%02X-%02X %02X:%02X", ltime.century, ltime.year, ltime.month, ltime.day, ltime.hour, ltime.minute); // EA_vTextOut(0, 0, EM_key_FONT8X16, 0, 1, 1, (char *)buf); EA_vDisplay(3, (void *)buf); if( mainflag == 1 ) { DisplayWelcomeMenu(); mainflag = 0; } uckey = EA_ucKBHit(); if(uckey == EM_key_HIT) //有按键 { uikey = EA_uiInkey(0); //读取按键键值 switch ( uikey ) { case EM_key_EXIT: //关机 { mainflag = 1; goto shutdown; break; } case EM_key_F3: { Login(); //登录界面 mainflag = 1; break; } case EM_key_F1: { Parm_Setting(); //参数配置 mainflag = 1; break; } case EM_key_1: { GPRS_TEST(); //无线连接测试 mainflag = 1; break; } case EM_key_F2: { // QUERY_NOTE_RECORD(); Gprs_Upload_data(); //数据上传 mainflag = 1; break; } default: break; } } } shutdown: Power_Down(); }
void gopherLoop(){ //initialize variables ------------------------------------------------------------------------------------------------------------------ int leftX; int leftY; //int rightx; //disabled to avoid 'unused' compiler warning //int righty; float addXLeft; float addYLeft; //float addXRight; //float addYRight; int deadZone = 3000; //X and Y minimum, below this is ignored since all controllers have some stick to them int scrollDeadZone = 7000; // Right thumbstick should be less sensitive. int scrollSpeed = 20; // Speed at which you scroll page. float range = 4.0f; //4 gives a decent range. Raising this requires a lowering of speed as well. int truncZone = 3; //anything below this is ignored and the mouse sits still, similar to a deadzone int sleepAmount = 16; //ideally 16, refreshes 60 times per second (1000/16 = ~60) POINT cursor; //ehh //read input --------------------------------------------------------------------------------------------------------------------------------- //read input --------------------------------------------------------------------------------------------------------------------------------- //read input --------------------------------------------------------------------------------------------------------------------------------- //XINPUT_GAMEPAD_BACK if(Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_BACK) { holdBack = true; } else if (Controller->GetState().Gamepad.wButtons != XINPUT_GAMEPAD_BACK) { holdBack = false; } //XINPUT_GAMEPAD_BACK - disable/enable if(holdBack == true && holdingBack == false){ // && holdingLeftMouseButton == false holdingBack = true; printf("---------------BACK-DOWN\n"); } else if(holdBack == false && holdingBack == true){ holdingBack = false; if(disabled == false){ printf("---------------BACK-UP - Toggled off, ignoring all input but 'Back'.\n"); disabled = true; Beep(1800,200); Beep(1600,200); Beep(1400,200); Beep(1200,200); Beep(1000,200); //Sleep(1000); } else if(disabled == true){ printf("---------------BACK-UP - Toggled on, taking all input.\n"); disabled = false; Beep(1000,200); Beep(1200,200); Beep(1400,200); Beep(1600,200); Beep(1800,200); //Sleep(1000); } } if(disabled == false){ //get LX info if(abs(Controller->GetState().Gamepad.sThumbLX) > deadZone) { addXLeft = (speed * (Controller->GetState().Gamepad.sThumbLX*range)); } //zero check else { addXLeft = 0.0f; } //get LY info if(abs(Controller->GetState().Gamepad.sThumbLY) > deadZone) { addYLeft = -(speed * (Controller->GetState().Gamepad.sThumbLY*range)); } //zero check else { addYLeft = 0.0f; } //Get RY info holdScrollUp = (Controller->GetState().Gamepad.sThumbRY > scrollDeadZone); holdScrollDown = (Controller->GetState().Gamepad.sThumbRY < -scrollDeadZone); //XINPUT_GAMEPAD_A holdLeft = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_A); if (holdLeft) { //printf("HOLDING MOUSE1..........................\n"); } else { //printf("NOT HOLDING..........................\n"); } //XINPUT_GAMEPAD_X holdRight = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_X); if (holdRight) { //printf("HOLDING X..........................\n"); } else { //printf("NOT HOLDING X..........................\n"); } //XINPUT_GAMEPAD_B holdEnter = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_B); if (holdEnter) { //printf("HOLDING B..........................\n"); } else { //printf("NOT HOLDING B..........................\n"); } //bumpers/shoulders holdBLeft = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_LEFT_SHOULDER); holdBRight = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_RIGHT_SHOULDER); //XINPUT_GAMEPAD_START holdStart = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_START); //XINPUT_GAMEPAD_LEFT_THUMB holdLThumb = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_LEFT_THUMB); //XINPUT_GAMEPAD_DPAD_UP holdDUp = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_DPAD_UP); //XINPUT_GAMEPAD_DPAD_DOWN holdDDown = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_DPAD_DOWN); //XINPUT_GAMEPAD_DPAD_LEFT holdDLeft = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_DPAD_LEFT); //XINPUT_GAMEPAD_DPAD_RIGHT holdDRight = (Controller->GetState().Gamepad.wButtons == XINPUT_GAMEPAD_DPAD_RIGHT); //process input --------------------------------------------------------------------------------------------------------------------------------- //process input --------------------------------------------------------------------------------------------------------------------------------- //process input --------------------------------------------------------------------------------------------------------------------------------- GetCursorPos(&cursor); leftX = cursor.x; leftY = cursor.y; if (abs(addYLeft) > truncZone) { leftY += (int)addYLeft; } else // truncate extremely low values { //printf("Truncated Y\n"); } if (abs(addXLeft) > truncZone) { leftX += (int)addXLeft; } else // truncate extremely low values { //printf("Truncated X\n"); } //filter non-32768 and 32767, wireless ones can glitch sometimes and send it to the edge of the screen if(addYLeft > 32767) addYLeft = 0; if(addYLeft < -32768) addYLeft = 0; if(addXLeft > 32767) addXLeft = 0; if(addXLeft < -32768) addXLeft = 0; //lmouse click if(holdLeft && !holdingLeft){ // && holdingLeftMouseButton == false INPUT input; input.type = INPUT_MOUSE; input.mi.mouseData=0; input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; input.mi.time = 0; SendInput(1, &input, sizeof(INPUT)); holdingLeft = true; printf("---------------L-DOWN\n"); } else if(!holdLeft && holdingLeft){ INPUT input; input.type = INPUT_MOUSE; input.mi.mouseData=0; input.mi.dwFlags = MOUSEEVENTF_LEFTUP; input.mi.time = 0; SendInput(1, &input, sizeof(INPUT)); holdingLeft = false; printf("---------------L-UP\n"); } //rmouse click if(holdRight && !holdingRight){ // && holdingLeftMouseButton == false INPUT input; input.type = INPUT_MOUSE; input.mi.mouseData=0; input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; input.mi.time = 0; SendInput(1, &input, sizeof(INPUT)); holdingRight = true; printf("---------------R-DOWN\n"); } else if(!holdRight && holdingRight){ INPUT input; input.type = INPUT_MOUSE; input.mi.mouseData=0; input.mi.dwFlags = MOUSEEVENTF_RIGHTUP; input.mi.time = 0; SendInput(1, &input, sizeof(INPUT)); holdingRight = false; printf("---------------R-UP\n"); } //middlemouse click if(holdLThumb && !holdingLThumb){ INPUT input; input.type = INPUT_MOUSE; input.mi.mouseData=0; input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN; input.mi.time = 0; SendInput(1, &input, sizeof(INPUT)); holdingLThumb = true; printf("---------------MM-DOWN\n"); } else if(!holdLThumb && holdingLThumb){ INPUT input; input.type = INPUT_MOUSE; input.mi.mouseData=0; input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP; input.mi.time = 0; SendInput(1, &input, sizeof(INPUT)); holdingLThumb = false; printf("---------------MM-UP\n"); } //scrollwheel up if (holdScrollUp) { INPUT input; input.type = INPUT_MOUSE; input.mi.mouseData = scrollSpeed; input.mi.dwFlags = MOUSEEVENTF_WHEEL; input.mi.time = 0; SendInput(1, &input, sizeof(INPUT)); printf("---------------WHEEL-UP\n"); } //scrollwheel down if (holdScrollDown) { INPUT input; input.type = INPUT_MOUSE; input.mi.mouseData = -scrollSpeed; input.mi.dwFlags = MOUSEEVENTF_WHEEL; input.mi.time = 0; SendInput(1, &input, sizeof(INPUT)); printf("---------------WHEEL-DOWN\n"); } //arrow up if(holdDUp && !holdingDUp){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_UP; input.ki.dwFlags = 0; SendInput(1, &input, sizeof(INPUT)); holdingDUp = true; printf("---------------DPU-DOWN\n"); } else if(!holdDUp && holdingDUp){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_UP; input.ki.dwFlags = KEYEVENTF_KEYUP; SendInput(1, &input, sizeof(INPUT)); holdingDUp = false; printf("---------------DPU-UP\n"); } //arrow down if(holdDDown && !holdingDDown){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_DOWN; input.ki.dwFlags = 0; SendInput(1, &input, sizeof(INPUT)); holdingDDown = true; printf("---------------DPD-DOWN\n"); } else if(!holdDDown && holdingDDown){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_DOWN; input.ki.dwFlags = KEYEVENTF_KEYUP; SendInput(1, &input, sizeof(INPUT)); holdingDDown = false; printf("---------------DPD-UP\n"); } //arrow left if(holdDLeft && !holdingDLeft){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_LEFT; input.ki.dwFlags = 0; SendInput(1, &input, sizeof(INPUT)); holdingDLeft = true; printf("---------------DPL-DOWN\n"); } else if(!holdDLeft && holdingDLeft){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_LEFT; input.ki.dwFlags = KEYEVENTF_KEYUP; SendInput(1, &input, sizeof(INPUT)); holdingDLeft = false; printf("---------------DPL-UP\n"); } //arrow right if(holdDRight && !holdingDRight){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_RIGHT; input.ki.dwFlags = 0; SendInput(1, &input, sizeof(INPUT)); holdingDRight = true; printf("---------------DPR-DOWN\n"); } else if(!holdDRight && holdingDRight){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_RIGHT; input.ki.dwFlags = KEYEVENTF_KEYUP; SendInput(1, &input, sizeof(INPUT)); holdingDRight = false; printf("---------------DPR-UP\n"); } //start if(holdStart && !holdingStart){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_LWIN; input.ki.dwFlags = 0; SendInput(1, &input, sizeof(INPUT)); holdingStart = true; printf("---------------START-DOWN\n"); } else if(!holdStart && holdingStart){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_LWIN; input.ki.dwFlags = KEYEVENTF_KEYUP; SendInput(1, &input, sizeof(INPUT)); holdingStart = false; printf("---------------START-UP\n"); } //enter if(holdEnter && !holdingEnter){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_RETURN; input.ki.dwFlags = 0; SendInput(1, &input, sizeof(INPUT)); holdingEnter = true; printf("---------------B-DOWN\n"); } else if(!holdEnter && holdingEnter){ INPUT input; input.type = INPUT_KEYBOARD; input.ki.wScan = 0; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.wVk = VK_RETURN; input.ki.dwFlags = KEYEVENTF_KEYUP; SendInput(1, &input, sizeof(INPUT)); holdingEnter = false; printf("---------------B-UP\n"); } //left bumper/shoulder (speed cycler) if(holdBLeft && !holdingBLeft){ holdingBLeft = true; printf("---------------BLEFT-DOWN\n"); } else if(!holdBLeft && holdingBLeft){ holdingBLeft = false; printf("---------------BLEFT-UP\n"); if(speed == speed_low) {Beep(240,250); speed = speed_med;} else if(speed == speed_med) {Beep(260,250); speed = speed_high;} else if(speed == speed_high){Beep(200,250); speed = speed_low;} } //left bumper/shoulder if(holdBRight && !holdingBRight){ holdingBRight = true; printf("---------------BRIGHT-DOWN\n"); } else if(!holdBRight && holdingBRight){ holdingBRight = false; printf("---------------BRIGHT-UP\n"); } SetCursorPos(leftX,leftY); //after all click input processing printf("Move X:%d, Y:%d\n", (int)addXLeft, -(int)addYLeft); } Sleep(sleepAmount); } //..........................................................................................End GopherLoop