int main(void) { InitIt(); //WINDOW *w_log; while(true) { int line; line = HelpWindow(); line = StatusWindow(line); int kcode=getch(); int optsize = sizeof(optlist)/sizeof(struct option); int keydecode=0; while(optsize--!=0){ if(kcode == optlist[optsize].key){ printw("%s...\n", optlist[optsize].descript); optlist[optsize].func(NULL); keydecode=1; } } if(!keydecode){ if(kcode == 3) goto ExitProg; // Ctrl+C on raw mode else printw("It key(code:%i) don't support, sorry\n", kcode); } refresh(); } ExitProg: CloseIt(); return 0; }
/********************* Start of window procedure **********************/ MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) { USHORT command; /* WM_COMMAND command value */ HPS hps; /* Presentation Space handle */ RECTL rc; /* Rectangle coordinates */ POINTL pt; /* String screen coordinates */ switch( msg ) { case WM_CREATE: if( State == RUNNING ) break; /******************************************************************/ /* Window initialization is performed here in WM_CREATE processing*/ /* WinLoadString loads strings from the resource file. */ /******************************************************************/ InitIt( "DSTD32", Hab, hwnd ); ReDraw( hwnd ); break; case WM_COMMAND: /******************************************************************/ /* When the user chooses option 1, 2, or 3 from the Options pull- */ /* down, the text string is set to 1, 2, or 3, and */ /* WinInvalidateRegion sends a WM_PAINT message. */ /* When Exit is chosen, the application posts itself a WM_CLOSE */ /* message. */ /******************************************************************/ command = SHORT1FROMMP(mp1); /* Extract the command value */ switch (command) { case ID_LOAD: if( State == RUNNING ) break; if( State != NONE ) { KillIt(); State = NONE; } if( LoadIt() ) { State = LOADED; } ReDraw( hwnd ); break; case ID_RUN: if( State == RUNNING ) break; State = RUNNING; ReDraw( hwnd ); if( InHardMode ) { WinLockInput( 0, FALSE ); InHardMode = FALSE; } State = RunIt() ? BROKE : TERMINATED; if( HardMode ) { WinLockInput( 0, TRUE ); InHardMode = TRUE; } ReDraw( hwnd ); break; case ID_KILL: if( State == RUNNING ) break; if( InHardMode ) { WinLockInput( 0, FALSE ); InHardMode = FALSE; } if( State != NONE ) { KillIt(); State = NONE; } ReDraw( hwnd ); break; case ID_HARD: if( State == RUNNING ) break; HardMode = !HardMode; TellHardMode( HardMode ? (char)-1 : 0 ); ReDraw( hwnd ); break; case ID_EXITPROG: if( InHardMode ) { WinLockInput( 0, FALSE ); InHardMode = FALSE; } if( State == RUNNING ) break; WinPostMsg( hwnd, WM_CLOSE, 0L, 0L ); break; default: return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } break; case WM_ERASEBACKGROUND: /******************************************************************/ /* Return TRUE to request PM to paint the window background */ /* in SYSCLR_WINDOW. */ /******************************************************************/ return (MRESULT)( TRUE ); case WM_PAINT: /******************************************************************/ /* Window contents are drawn here in WM_PAINT processing. */ /******************************************************************/ /* Create a presentation space */ hps = WinBeginPaint( hwnd, NULL, &rc ); pt.x = 50; pt.y = 50; /* Set the text coordinates, */ GpiSetColor( hps, CLR_NEUTRAL ); /* colour of the text, */ GpiSetBackColor( hps, CLR_BACKGROUND ); /* its background and */ GpiSetBackMix( hps, BM_OVERPAINT ); /* how it mixes, */ /* and draw the string...*/ strcpy( WhatItIs[ State ] +HARD_POS, IsHardMode[ HardMode ] ); GpiCharStringAt( hps, &pt, (LONG)strlen( WhatItIs[ State ] ), WhatItIs[ State ] ); WinEndPaint( hps ); /* Drawing is complete */ break; case WM_CLOSE: /******************************************************************/ /* This is the place to put your termination routines */ /******************************************************************/ if( State == RUNNING ) break; FiniIt(); WinPostMsg( hwnd, WM_QUIT, 0L, 0L ); /* Cause termination */ break; default: /******************************************************************/ /* Everything else comes here. This call MUST exist */ /* in your window procedure. */ /******************************************************************/ return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } return FALSE; }
bool PerigeeMove::Run() { if ( m_options.debug_prompt ) { DlgConfirmDelete dcd(m_files); CString csCaption; CString csTempl; CString csPrompt; csCaption.LoadString(IDS_CONFIRM_MOVE); csTempl.LoadString(IDS_CONFIRM_MOVE_PROMPT_TEMPL); csPrompt.Format(csTempl, (LPCTSTR)m_files[0].dest); dcd.ChangeCaption(csCaption, csPrompt); if ( IDCANCEL == dcd.DoModal() ) { return false; } } m_progress.ShowWindow(SW_SHOW); // On Windows Vista, verify the user has permission to create files // in the destination folder, and prompt for elevation otherwise if (!m_files.empty() && EnableElevatePrompt() && !VistaHelper::CheckAccess(m_files[0].dest, GENERIC_WRITE, m_token)) { CString message; message.Format(IDS_ELEVATION_REQUIRED_TO_CREATE_FILES_IN_FOLDER, m_files[0].dest); DoElevatePrompt(message); if (m_cancel) return false; } PostPrompt(); Reset(); if (!InitIt()) return false; for(;;) { Reset(); if ( DoIt() ) { return true; } if ( m_cancel ) return false; bool retry = false; // if we're in "postpone" mode, enable prompting now if (m_options.overwrite == CPerigeeCopyOptions::overwrite_postpone) { retry = true; m_options.overwrite = CPerigeeCopyOptions::overwrite_prompt; } // show skipped files dialog if (!retry) { PrePrompt(false); CDialogFailedFiles dff(NULL, m_error_files); retry = IDOK == dff.DoModal(); PostPrompt(); } if ( retry ) { // move failed files back to source list and try again m_files.clear(); for(file_list::iterator it = m_error_files.begin(); it != m_error_files.end(); ++it) { if ( it->error_type < warn_first ) { m_files.push_back(*it); } } } else { return false; } } }