BOOL CmyWord::Open(CString fileName) { if(FALSE == PathFileExists(fileName) || -1 == fileName.Find(_T(".doc"))) { AfxMessageBox(_T("请确定路径是否正确!"),MB_OK|MB_ICONSTOP); return FALSE; } CComVariant Read(FALSE); CComVariant AddToR(FALSE); CComVariant Name(fileName); COleVariant vTrue((short)TRUE); COleVariant vFalse((short)FALSE); COleVariant varstrNull(_T("")); COleVariant varZero((short)0); COleVariant varTrue(short(1),VT_BOOL); COleVariant varFalse(short(0),VT_BOOL); COleVariant vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR); if(!m_wdApp.m_lpDispatch) { if(CreateApp()==FALSE) { return FALSE; } } if(!m_wdDoc.m_lpDispatch) { m_wdDocs=m_wdApp.GetDocuments(); if(!m_wdDocs.m_lpDispatch) { AfxMessageBox(_T("DocuMent 对象创建失败")); CloseApp(); return FALSE; } } CComVariant format(0);//打开方式 0 为doc的打开方式 //doc=docs.Open(&Name,varFalse,&Read,&AddToR,vOpt,vOpt,vFalse,vOpt,vOpt,&format,vOpt,vTrue,vOpt,vOpt,vOpt,vOpt); m_wdDoc = m_wdDocs.Add(&Name, vOpt, vOpt, vOpt); if(!m_wdDoc.m_lpDispatch) { AfxMessageBox(_T("文件打开失败")); CloseApp(); return FALSE; } else { m_wdSel=m_wdApp.GetSelection(); if(!m_wdSel.m_lpDispatch) { AfxMessageBox(_T("打开失败")); CloseApp(); return FALSE; } return TRUE; } }
int main_handler(int type, int par1, int par2) { int i; if (type == EVT_SHOW) { ClearScreen(); FullUpdate(); DrawRect(10, 18, 580, 104, 0); for(i=0; i<16; i++) { FillArea(12+i*36, 20, 36, 100, i*0x111111); } FullUpdate(); FineUpdate(); } if (type == EVT_KEYPRESS) { CloseApp(); } return 0; }
LONG WINAPI WindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { switch( message ) { // Monitor keystrokes for manipulating video window // and program options case WM_KEYDOWN: switch( wParam ) { case VK_ESCAPE: case VK_SPACE: case VK_RETURN: g_bUserInterruptedPlayback = TRUE; CloseApp(); break; } break; case WM_DESTROY: PostQuitMessage(0); return 0; } // Pass this message to the video window for notification of system changes if (pVW) pVW->NotifyOwnerMessage((LONG_PTR) hWnd, message, wParam, lParam); return (LONG) DefWindowProc(hWnd, message, wParam, lParam); }
LONG WINAPI WindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { switch( message ) { // Monitor keystrokes for manipulating video window // and program options case WM_KEYDOWN: switch( wParam ) { case VK_ESCAPE: case VK_SPACE: case VK_RETURN: g_bUserInterruptedPlayback = TRUE; CloseApp(); break; } break; case WM_DESTROY: PostQuitMessage(0); return 0; } return (LONG) DefWindowProc(hWnd, message, wParam, lParam); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->lineEdit->setText("NaN"); ui->horizontalSlider->setValue(500); ui->horizontalSlider->show(); onethread = new myThread(this); onethread->duty_value = 500; connect(onethread, SIGNAL(deviceAmbient()), this, SLOT(SliderChanged())); connect(onethread, SIGNAL(deviceAmbient()), this, SLOT(EditContentChange())); onethread->start(QThread::NormalPriority); connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(CloseApp())); }
// Entry Point int main(int argc, char *argv[]) { // Init SDL InitializeApp(); // Init Window Display display = {}; Display_Initialize(&display, FIXED_WIDTH, FIXED_HEIGHT, "Tècniques Intel·ligència Artificial per a Videojocs"); // Init Gamepad Input InputSingleton::Instance()->Init(); // Init StateManager StateManager manager = {}; manager.display = &display; manager.switcherCallback = &SwitcherCallbackFunction; // Init State MenuState* menuState = new MenuState(); menuState->display = &display; StateManager_ChangeState(&manager, menuState); // Loop StateManager_RunCurrentState(&manager); // Finish StateManager StateManager_Free(&manager); // Finish Gamepad Input InputSingleton::Instance()->Deinit(); // Finish Window Display_Free(&display); // Finish SDL CloseApp(); return 0; }
void balda_controller_main_menu_handler(int index) { switch (index) { case 101: // Resume // Do nothing break; case 111: // New game -> Single player balda_controller_new_game(BALDA_GAME_TYPE_ONE_PLAYER); break; case 112: // New game -> Two players balda_controller_new_game(BALDA_GAME_TYPE_TWO_PLAYERS); break; case 121: // Easy balda_set_game_difficulty(g_balda_controller.balda, BALDA_GAME_DIFFICULTY_EASY); balda_controller_set_difficulty_bullet(0); break; case 122: // Normal balda_set_game_difficulty(g_balda_controller.balda, BALDA_GAME_DIFFICULTY_NORMAL); balda_controller_set_difficulty_bullet(1); break; case 123: // Hard balda_set_game_difficulty(g_balda_controller.balda, BALDA_GAME_DIFFICULTY_HARD); balda_controller_set_difficulty_bullet(2); break; case 140: // About Message(ICON_INFORMATION, (char*)balda_string(BALDA_STR_ABOUT_TITLE), (char*)balda_string(BALDA_STR_ABOUT_MESSAGE), 10000); break; case 150: // Exit CloseApp(); break; } }
static void pwd_query_kbdhandler(char* text) { if (text != NULL) write(ipcfd, text, strlen(text)); CloseApp(); }
int calendar_handler(int type, int par1, int par2) { if (type == EVT_SHOW) { GenerateCalendar(); DrawCalendar(); } if (type == EVT_ORIENTATION) { SetOrientation(par1); GenerateCalendar(); DrawCalendar(); } if (type==EVT_KEYPRESS) switch(par1) { case KEY_LEFT: case KEY_PREV: case KEY_PREV2: if (year>1) { year--; if (year%4==0) LongYear=1; else LongYear=0; if (LongYear && year%100==0 && year%400!=0) LongYear=0; FirstDay=(FirstDay+371-365*(1-LongYear)-366*LongYear)%7; GenerateCalendar(); DrawCalendar(); } break; case KEY_RIGHT: case KEY_NEXT: case KEY_NEXT2: if (year<10000) { if (year%4==0) LongYear=1; else LongYear=0; if (LongYear && year%100==0 && year%400!=0) LongYear=0; FirstDay=(FirstDay+365*(1-LongYear)+366*LongYear)%7; year++; GenerateCalendar(); DrawCalendar(); } break; case KEY_OK: case KEY_BACK: CloseApp(); break; } #ifndef BASIC if (type == EVT_POINTERUP) { if (par1 > (ScreenWidth() - HeaderWidth) / 2 - 10 && par1 < (ScreenWidth() - HeaderWidth) / 2 + SymbolWidth + 10 && par2 > 0 && par2 < 40) { calendar_handler(EVT_KEYPRESS, KEY_LEFT, 0); } if (par1 > (ScreenWidth() + HeaderWidth) / 2 - SymbolWidth - 10 && par1 < (ScreenWidth() + HeaderWidth) / 2 + 10 && par2 > 0 && par2 < 40) { calendar_handler(EVT_KEYPRESS, KEY_RIGHT, 0); } } #endif return 0; }