BOOL FASTCALL CmdSignatureDlg_SaveSig( HWND hwnd, int index ) { char sz[ _MAX_FNAME ]; HWND hwndList; register int c; HNDFILE fh; hwndList = GetDlgItem( hwnd, IDD_LIST ); ComboBox_GetLBText( hwndList, index, sz ); for( c = 0; sz[ c ]; ++c ) if( !ValidFileNameChr( sz[ c ] ) ) { wsprintf( lpTmpBuf, GS( IDS_STR136 ), sz[ c ] ); fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONEXCLAMATION ); return( FALSE ); } lstrcat( sz, ".sig" ); if( ( fh = Ameol2_CreateFile( sz, DSD_SIG, 0 ) ) == HNDFILE_ERROR ) fMessageBox( hwnd, 0, GS( IDS_STR137 ), MB_OK|MB_ICONEXCLAMATION ); else { WORD wSize; LPSTR lpText; HWND hwndEdit; INITIALISE_PTR(lpText); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); wSize = Edit_GetTextLength( hwndEdit ) + 1; if( !fNewMemory( &lpText, wSize ) ) OutOfMemoryError( hwnd, FALSE, FALSE ); else { Edit_GetText( hwndEdit, lpText, wSize ); if( Amfile_Write( fh, lpText, wSize ) == wSize ) { FreeMemory( &lpText ); Amfile_Close( fh ); return( TRUE ); } FreeMemory( &lpText ); DiskWriteError( hwnd, sz, FALSE, FALSE ); } Amfile_Close( fh ); Amfile_Delete( sz ); } return( FALSE ); }
/* This function handles the WM_NOTIFY message. */ LRESULT FASTCALL RASBlinkProperties_OnNotify( HWND hwnd, int code, LPNMHDR lpnmhdr ) { switch( lpnmhdr->code ) { case PSN_HELP: HtmlHelp( hwnd, szHelpFile, HH_HELP_CONTEXT, idsBLINK_RAS ); break; case PSN_APPLY: { LPBLINKENTRY lpbe; HWND hwndTab; /* Update the blink entry structure. */ lpbe = (LPBLINKENTRY)GetWindowLong( hwnd, DWL_USER ); hwndTab = PropSheet_GetTabControl( GetParent( hwnd ) ); if( !TabCtrl_GetEnable( hwndTab, idRasTab ) ) lpbe->rd.fUseRAS = FALSE; else lpbe->rd.fUseRAS = IsDlgButtonChecked( hwnd, IDD_USERAS ); /* If we use RAS, we'll need the entry name. */ if( lpbe->rd.fUseRAS ) { HWND hwndList; /* Get the entry name. */ hwndList = GetDlgItem( hwnd, IDD_LIST ); ComboBox_GetText( hwndList, lpbe->rd.szRASEntryName, RAS_MaxEntryName+1 ); /* Get username and password. */ Edit_GetText( GetDlgItem( hwnd, IDD_USERNAME ), lpbe->rd.szRASUserName, UNLEN+1 ); Edit_GetText( GetDlgItem( hwnd, IDD_PASSWORD ), lpbe->rd.szRASPassword, PWLEN+1 ); if( ( strlen( lpbe->rd.szRASEntryName ) == 0 ) || ( strlen( lpbe->rd.szRASUserName ) == 0 ) || ( strlen( lpbe->rd.szRASPassword ) == 0 ) ) { fMessageBox( hwnd, 0, GS(IDS_STR1242), MB_OK|MB_ICONEXCLAMATION ); return( PSNRET_INVALID_NOCHANGEPAGE ); } Amuser_Encrypt( lpbe->rd.szRASPassword, rgEncodeKey ); } /* Force the Apply button to be disabled. */ PropSheet_UnChanged( GetParent( hwnd ), hwnd ); return( PSNRET_NOERROR ); } } return( FALSE ); }
void DexMouseTracker::Initialize( void ) { acquisitionOn = false; overrun = false; nAcqFrames = 0; nPolled = 0; char *filename = "DexMouseTrackerDebug.mrk"; // Open a file to store the positions and orientations that were used by // GetCurrentMarkerFrame() to simulate the marker positions. This allows us // to compare with the position and orientation computed by DexApparatus // for testing purposes. fp = fopen( filename, "w" ); if ( !fp ) { fMessageBox( MB_OK, "DexMouseTracker", "Error openning file for write:\n %s", filename ); exit( -1 ); } fprintf( fp, "Time\tPx\tPy\tPz\tQx\tQy\tQz\tQm\n" ); }
/* This function handles the WM_COMMAND message. */ void FASTCALL NewSig_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_EDIT: if( codeNotify == EN_CHANGE ) EnableControl( hwnd, IDOK, Edit_GetTextLength( hwndCtl ) > 0 ); break; case IDOK: { LPSTR lpText; HWND hwndEdit; register int c; lpText = (LPSTR)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); Edit_GetText( hwndEdit, lpText, 9 ); for( c = 0; lpText[ c ]; ++c ) if( !ValidFileNameChr( lpText[ c ] ) ) { wsprintf( lpTmpBuf, GS( IDS_STR136 ), lpText[ c ] ); fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONEXCLAMATION ); break; } if( lpText[ c ] ) { SetFocus( hwndEdit ); Edit_SetSel( hwndEdit, c, c + 1 ); Edit_ScrollCaret( hwndEdit ); break; } } case IDCANCEL: EndDialog( hwnd, id == IDOK ); break; } }
void CreateGripPacketCacheFilename( char *filename, int max_characters, const GripPacketType type, const char *root ) { int bytes_written; switch ( type ) { case GRIP_RT_SCIENCE_PACKET: bytes_written = sprintf( filename, "%s.rt.gpk", root ); break; case GRIP_HK_BULK_PACKET: bytes_written = sprintf( filename, "%s.hk.gpk", root ); break; default: bytes_written = sprintf( filename, "%s.any.gpk", root ); break; } if ( bytes_written < 0 || bytes_written > max_characters ) { fMessageBox( MB_OK, "Grip", "Error in sprintf()." ); exit( -1 ); } }
/// Read housekeeping cache, taking just the most recent value. /// The path to the cache file is presumed to be set in global variable 'packetBufferPathRoot'. /// The contents of the latest HK packet are returned in the structure pointed to by parameter 'hk'. int GetLastPacketHK( EPMTelemetryHeaderInfo *epmHeader, GripHealthAndStatusInfo *hk, char *filename_root ) { static int count = 0; int fid; int packets_read = 0; int bytes_read; int return_code; static unsigned short previousTMCounter = 0; unsigned long bit = 0; int retry_count; EPMTelemetryPacket packet; char filename[MAX_PATHLENGTH]; // Create the path to the housekeeping packet file, based on the root and the packet type. CreateGripPacketCacheFilename( filename, sizeof( filename ), GRIP_HK_BULK_PACKET, filename_root ); // Attempt to open the packet cache to read the accumulated packets. // If it is not immediately available, try for a few seconds. for ( retry_count = 0; retry_count < MAX_OPEN_CACHE_RETRIES; retry_count ++ ) { // Try to open the packet cache file. fid = _open( filename, _O_RDONLY | _O_BINARY, _S_IWRITE | _S_IREAD ); // If open succeeds, it will return zero. So if zero return, break from retry loop. if ( fid >= 0 ) break; // Wait a second before trying again. Sleep( RETRY_PAUSE ); } // If fid is negative, file is not open. This should not happen, because GripMMIStartup should verify // the availability of files containing packets before the GripMMIDesktop form is executed. // So if we do fail to open the file, signal the error and exit. if ( fid < 0 ) { fMessageBox( MB_OK, "GripMMI", "Error reading from %s.", filename ); exit( -1 ); } // Read in all of the data packets in the file. packets_read = 0; while ( 1 ) { bytes_read = _read( fid, &packet, hkPacketLengthInBytes ); // Return less than zero means read error. if ( bytes_read < 0 ) { fMessageBox( MB_OK, "GripMMI", "Error reading from %s.", filename ); exit( -1 ); } // Return less than expected number of bytes means we have read all packets. if ( bytes_read < hkPacketLengthInBytes ) break; packets_read++; // Check that it is a valid GRIP packet. It would be strange if it was not. ExtractEPMTelemetryHeaderInfo( epmHeader, &packet ); if ( epmHeader->epmSyncMarker != EPM_TELEMETRY_SYNC_VALUE || epmHeader->TMIdentifier != GRIP_HK_ID ) { fMessageBox( MB_OK, "GripMMI", "Unrecognized packet from %s.", filename ); exit( -1 ); } // Extract the interesting info in proper byte order. ExtractGripHealthAndStatusInfo( hk, &packet ); } // Finished reading. Close the file and check for errors. return_code = _close( fid ); if ( return_code ) { fMessageBox( MB_OK, "GripMMI", "Error closing %s after binary read.\nError code: %s", filename, return_code ); exit( return_code ); } // The structure pointed to by 'hk' contains the data from the last valid packet that was read from the cache file. // Check if there were new packets since the last time we read the cache. // Return TRUE if yes, FALSE if no. if ( previousTMCounter != epmHeader->TMCounter ) { previousTMCounter = epmHeader->TMCounter; return( TRUE ); } else return ( FALSE ); }
/* This function processes the WM_COMMAND message. */ void FASTCALL OutBasket_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDM_QUICKPRINT: case IDM_PRINT: CmdPrintOutbasket( hwnd ); break; case IDD_HELP: HtmlHelp( hwnd, szHelpFile, HH_HELP_CONTEXT, idsOUTBASKET ); break; case IDCANCEL: SendMessage( hwnd, WM_CLOSE, 0, 0L ); break; case IDD_DELETE: { HWND hwndList; hwndList = GetDlgItem( hwnd, IDD_LIST ); if( IsWindowEnabled( GetDlgItem( hwnd, id ) ) ) if( fMessageBox( hwnd, 0, GS(IDS_STR253), MB_YESNO|MB_ICONINFORMATION ) == IDYES ) { int cDeleted; int nCount; int nSel; int c; /* Set fIgnoreDeleteEvent because we could be * deleting lots of items, and we don't want each * deletion from the out-basket to be individual. */ nCount = ListBox_GetCount( hwndList ); SetWindowRedraw( hwndList, FALSE ); cDeleted = c = 0; nSel = -1; fIgnoreDeleteEvent = TRUE; while( c < nCount ) { if( ListBox_GetSel( hwndList, c ) > 0 ) { OBINFO obinfo; LPOB lpob; lpob = (LPOB)ListBox_GetItemData( hwndList, c ); Amob_GetObInfo( lpob, &obinfo ); if( !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) ) { ListBox_DeleteString( hwndList, c ); nSel = c; Amob_RemoveObject( lpob, FALSE ); ++cDeleted; --nCount; } else ++c; } else ++c; } if( nSel >= nCount ) nSel = nCount - 1; SetWindowRedraw( hwndList, TRUE ); if( cDeleted ) { InvalidateRect( hwndList, NULL, TRUE ); UpdateWindow( hwndList ); if( nSel > -1 ) ListBox_SetSel( hwndList, TRUE, nSel ); Amob_SaveOutBasket( FALSE ); UpdateOutBasketStatus(); ShowOutBasketTotal( hwndOutBasket ); } fIgnoreDeleteEvent = FALSE; OutBasket_OnSetFocus( hwnd, NULL ); } SetFocus( hwndList ); break; } case IDD_HOLD: { HWND hwndList; int nCount; BOOL fFirst; BOOL fHold; int c; hwndList = GetDlgItem( hwnd, IDD_LIST ); nCount = ListBox_GetCount( hwndList ); fFirst = TRUE; fHold = FALSE; for( c = 0; c < nCount; ++c ) if( ListBox_GetSel( hwndList, c ) ) { OBINFO obinfo; LPOB lpob; RECT rc; lpob = (LPOB)ListBox_GetItemData( hwndList, c ); Amob_GetObInfo( lpob, &obinfo ); if( !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) ) { if( fFirst ) { if( obinfo.obHdr.wFlags & OBF_HOLD ) { SetWindowText( GetDlgItem( hwnd, IDD_HOLD ), GS(IDS_STR281) ); fHold = FALSE; } else { SetWindowText( GetDlgItem( hwnd, IDD_HOLD ), GS(IDS_STR282) ); fHold = TRUE; } fFirst = FALSE; } obinfo.obHdr.wFlags &= ~OBF_ERROR; if( fHold ) obinfo.obHdr.wFlags |= OBF_HOLD; else obinfo.obHdr.wFlags &= ~OBF_HOLD; Amob_SetObInfo( lpob, &obinfo ); ListBox_GetItemRect( hwndList, c, &rc ); if( !IsRectEmpty( &rc ) ) InvalidateRect( hwndList, &rc, FALSE ); } } // !!SM!! 2.55.2035 Amob_SaveOutBasket( FALSE ); UpdateOutBasketStatus(); ShowOutBasketTotal( hwndOutBasket ); // !!SM!! 2.55.2035 UpdateWindow( hwndList ); SetFocus( hwndList ); break; } case IDD_KEEP: { HWND hwndList; int nCount; BOOL fFirst; BOOL fKeep; int c; hwndList = GetDlgItem( hwnd, IDD_LIST ); nCount = ListBox_GetCount( hwndList ); fFirst = TRUE; fKeep = FALSE; for( c = 0; c < nCount; ++c ) { if( ListBox_GetSel( hwndList, c ) ) { OBINFO obinfo; LPOB lpob; RECT rc; lpob = (LPOB)ListBox_GetItemData( hwndList, c ); Amob_GetObInfo( lpob, &obinfo ); if( fFirst ) { if( obinfo.obHdr.wFlags & OBF_KEEP ) { fKeep = FALSE; SetWindowText( GetDlgItem( hwnd, IDD_KEEP ), GS(IDS_STR319) ); } else { fKeep = TRUE; SetWindowText( GetDlgItem( hwnd, IDD_KEEP ), GS(IDS_STR318) ); } fFirst = FALSE; } obinfo.obHdr.wFlags &= ~OBF_ERROR; if( fKeep ) obinfo.obHdr.wFlags |= OBF_KEEP; else obinfo.obHdr.wFlags &= ~OBF_KEEP; Amob_SetObInfo( lpob, &obinfo ); ListBox_GetItemRect( hwndList, c, &rc ); if( !IsRectEmpty( &rc ) ) InvalidateRect( hwndList, &rc, FALSE ); } } // !!SM!! 2.55.2035 Amob_SaveOutBasket( FALSE ); UpdateOutBasketStatus(); ShowOutBasketTotal( hwndOutBasket ); // !!SM!! 2.55.2035 UpdateWindow( hwndList ); SetFocus( hwndList ); break; } case IDD_LIST: if( codeNotify == LBN_SELCHANGE ) { UpdateOutBasketStatus(); break; } else if( codeNotify != LBN_DBLCLK ) break; if( !IsWindowEnabled( GetDlgItem( hwnd, IDOK ) ) ) break; case IDOK: { HWND hwndList; int nCount; int c; hwndList = GetDlgItem( hwnd, IDD_LIST ); nCount = ListBox_GetCount( hwndList ); for( c = 0; c < nCount; ++c ) if( ListBox_GetSel( hwndList, c ) > 0 ) { OBINFO obinfo; LPOB lpob; lpob = (LPOB)ListBox_GetItemData( hwndList, c ); Amob_GetObInfo( lpob, &obinfo ); if( Amob_IsEditable( obinfo.obHdr.clsid ) && !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) ) Amob_Edit( lpob ); } break; } } }
/* This function creates a new mailbox and a rule to accompany * that mailbox. */ void FASTCALL CreateSortMailFrom( HWND hwnd ) { LPWINDINFO lpWindInfo; lpWindInfo = GetBlock( hwndTopic ); if( Amdb_GetTopicType( lpWindInfo->lpTopic ) != FTYPE_MAIL ) return; if( Adm_Dialog( hInst, hwnd, MAKEINTRESOURCE(IDDLG_SORTMAILFROM), SortMailFrom, 0L ) ) { MSGINFO msginfo; RULE rule; PTH pth; /* Get the current folder handle. */ Amdb_GetMsgInfo( lpWindInfo->lpMessage, &msginfo ); /* First create a new rule. */ memset( &rule, 0, sizeof(RULE) ); rule.wFlags = FILF_MOVE; rule.pData = lpWindInfo->lpTopic; rule.pMoveData = ptlDest; lstrcpy( rule.szFromText, szRuleAuthor ); if( CreateRule( &rule ) == NULL ) { fMessageBox( hwnd, 0, GS(IDS_STR1043), MB_OK|MB_ICONINFORMATION ); return; } /* If we move existing messages, then loop and move 'em. */ if( fMoveExisting ) { PTH FAR * lppth; int count; HCURSOR hOldCursor; INITIALISE_PTR(lppth); /* Busy, busy, bee */ hOldCursor = SetCursor( hWaitCursor ); /* First pass - count the number of messages. */ count = 0; for( pth = Amdb_GetFirstMsg( lpWindInfo->lpTopic, VM_VIEWCHRON ); pth; pth = Amdb_GetNextMsg( pth, VM_VIEWCHRON ) ) { MSGINFO msginfo2; Amdb_GetMsgInfo( pth, &msginfo2 ); // if( strcmp( msginfo2.szAuthor, szRuleAuthor ) == 0 || ( szRuleAuthor[ 0 ] == '@' && strstr( msginfo2.szAuthor, szRuleAuthor ) != NULL ) ) if( AddressRuleMatch( szRuleAuthor, msginfo2.szAuthor ) != -1 ) ++count; } /* Second pass, allocate a PTH array of count messages and collect * the pth handles to the array. */ if( count > 0 ) { if( fNewMemory( (PTH FAR *)&lppth, ( count + 1 ) * sizeof(PTH) ) ) { int index; index = 0; for( pth = Amdb_GetFirstMsg( lpWindInfo->lpTopic, VM_VIEWCHRON ); pth; pth = Amdb_GetNextMsg( pth, VM_VIEWCHRON ) ) { MSGINFO msginfo2; Amdb_GetMsgInfo( pth, &msginfo2 ); // if( strcmp( msginfo2.szAuthor, szRuleAuthor ) == 0 || ( szRuleAuthor[ 0 ] == '@' && strstr( msginfo2.szAuthor, szRuleAuthor ) != NULL ) ) if( AddressRuleMatch( szRuleAuthor, msginfo2.szAuthor ) != -1 ) { ASSERT( index < count ); lppth[ index++ ] = pth; } } ASSERT( index == count ); lppth[ index++ ] = NULL; DoCopyLocalRange( hwndTopic, lppth, count, ptlDest, TRUE, FALSE ); FreeMemory( (PTH FAR *)&lppth ); } } SetCursor( hOldCursor ); } } }
/* This function handles the WM_COMMAND message. */ void FASTCALL SortMailFrom_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_EXISTING: EnableControl( hwnd, IDD_LIST, TRUE ); EnableControl( hwnd, IDD_PAD2, FALSE ); EnableControl( hwnd, IDD_EDIT, FALSE ); break; case IDD_NEW: EnableControl( hwnd, IDD_LIST, FALSE ); EnableControl( hwnd, IDD_PAD2, TRUE ); EnableControl( hwnd, IDD_EDIT, TRUE ); SetFocus( GetDlgItem( hwnd, IDD_EDIT ) ); break; case IDOK: /* Get the destination folder. */ if( IsDlgButtonChecked( hwnd, IDD_EXISTING ) ) { HWND hwndList; int index; VERIFY( hwndList = GetDlgItem( hwnd, IDD_LIST ) ); index = ComboBox_GetCurSel( hwndList ); ASSERT( CB_ERR != index ); ptlDest = (PTL)ComboBox_GetItemData( hwndList, index ); ASSERT( NULL != ptlDest ); } else { char szMailBox[ LEN_MAILBOX ]; PCL pcl; /* Get the destination folder name. */ GetDlgItemText( hwnd, IDD_EDIT, szMailBox, sizeof( szMailBox ) ); StripLeadingTrailingSpaces( szMailBox ); if( !IsValidFolderName( hwnd, szMailBox ) ) break; if( strchr( szMailBox, ' ' ) != NULL ) { wsprintf( lpTmpBuf, GS(IDS_STR1154), ' ' ); fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONINFORMATION ); break; } if( NULL == ( pcl = Amdb_OpenFolder( NULL, "Mail" ) ) ) pcl = Amdb_CreateFolder( Amdb_GetFirstCategory(), "Mail", CFF_SORT ); ptlDest = NULL; if( pcl ) { if( Amdb_OpenTopic( pcl, szMailBox ) ) { fMessageBox( hwnd, 0, GS(IDS_STR832), MB_OK|MB_ICONEXCLAMATION ); break; } ptlDest = Amdb_CreateTopic( pcl, szMailBox, FTYPE_MAIL ); Amdb_CommitDatabase( FALSE ); } /* Error if we couldn't create the folder (out of memory?) */ if( NULL == ptlDest ) { wsprintf( lpTmpBuf, GS(IDS_STR845), szMailBox ); fMessageBox( hwndFrame, 0, lpTmpBuf, MB_OK|MB_ICONINFORMATION ); break; } } /* Get the address, reject if there isn't one. */ Edit_GetText( GetDlgItem( hwnd, IDD_NAME ), szRuleAuthor, LEN_INTERNETNAME+1 ); if( strlen( szRuleAuthor ) == 0 ) { fMessageBox( hwnd, 0, GS(IDS_STR783), MB_OK|MB_ICONINFORMATION ); HighlightField( hwnd, IDD_NAME); break; } /* Set a flag if all messages are moved to the * destination folder. */ fMoveExisting = IsDlgButtonChecked( hwnd, IDD_FILEALL ); EndDialog( hwnd, TRUE ); break; case IDCANCEL: EndDialog( hwnd, FALSE ); break; } }
/* This function handles the WM_INITDIALOG message. */ BOOL FASTCALL SortMailFrom_OnInitDialog( HWND hwnd, HWND hwndFocus, LPARAM lParam ) { LPWINDINFO lpWindInfo; MSGINFO msginfo; HWND hwndList; HWND hwndEdit; HWND hwndName; int index; PCAT pcat; PCL pcl; PTL ptl; /* Must have a message window open. */ if( NULL == hwndTopic ) { EndDialog( hwnd, 0 ); return( FALSE ); } /* Get details of the message we'll be using and set the * static text field in the dialog. If there is no author field (shouldn't * be possible now) we tell the user and quit the dialog. */ lpWindInfo = GetBlock( hwndTopic ); Amdb_GetMsgInfo( lpWindInfo->lpMessage, &msginfo ); if( msginfo.szAuthor[ 0 ] == '\0' ) { fMessageBox( hwnd, 0, GS(IDS_STR1220), MB_OK|MB_ICONINFORMATION ); EndDialog( hwnd, 0 ); return( FALSE ); } SetDlgItemText( hwnd, IDD_PAD1, GS(IDS_STR1042) ); /* Set the edit box to the author details */ hwndName = GetDlgItem( hwnd, IDD_NAME ); Edit_SetText( hwndName, msginfo.szAuthor ); Edit_LimitText( hwndName, LEN_INTERNETNAME+1 ); /* Fill the list of mail folders. */ VERIFY( hwndList = GetDlgItem( hwnd, IDD_LIST ) ); for( pcat = Amdb_GetFirstCategory(); pcat; pcat = Amdb_GetNextCategory( pcat ) ) for( pcl = Amdb_GetFirstFolder( pcat ); pcl; pcl = Amdb_GetNextFolder( pcl ) ) for( ptl = Amdb_GetFirstTopic( pcl ); ptl; ptl = Amdb_GetNextTopic( ptl ) ) if( Amdb_GetTopicType( ptl ) == FTYPE_MAIL ) { int index; index = ComboBox_InsertString( hwndList, -1, (LPSTR)Amdb_GetTopicName( ptl ) ); ComboBox_SetItemData( hwndList, index, (LPARAM)ptl ); } /* Select the first Mail topic. */ if( ( index = RealComboBox_FindItemData( hwndList, -1, (LPARAM)lpWindInfo->lpTopic ) ) == CB_ERR ) index = 0; ComboBox_SetCurSel( hwndList, index ); /* Set the edit field limits. */ VERIFY( hwndEdit = GetDlgItem( hwnd, IDD_EDIT ) ); Edit_LimitText( hwndEdit, LEN_TOPICNAME ); /* Choose to move to an existing folder. */ CheckDlgButton( hwnd, IDD_EXISTING, TRUE ); EnableControl( hwnd, IDD_PAD2, FALSE ); EnableControl( hwnd, IDD_EDIT, FALSE ); /* Move other messages. */ CheckDlgButton( hwnd, IDD_FILEALL, TRUE ); return( TRUE ); }
void DexNiDaqTargets::ReportNiDaqError ( void ) { char errBuff[2048]={'\0'}; DAQmxGetExtendedErrorInfo( errBuff, 2048); fMessageBox( MB_OK, "DexNiDaqADC", errBuff ); }
/* This function handles the WM_COMMAND message. */ void FASTCALL CmdSignatureDlg_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_LIST: if( codeNotify == CBN_SELCHANGE ) { HWND hwndList; HWND hwndEdit; int index; index = (int)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); if( EditMap_GetModified( hwndEdit ) ) { if( !CmdSignatureDlg_SaveSig( hwnd, index ) ) break; fCancelToClose( hwnd, IDCANCEL ); } hwndList = GetDlgItem( hwnd, IDD_LIST ); index = ComboBox_GetCurSel( hwndList ); CmdSignatureDlg_DisplaySig( hwnd, index ); } break; case IDD_NEW: { char sz[ 9 ]; if( Adm_Dialog( hRscLib, hwnd, MAKEINTRESOURCE( IDDLG_NEWSIG ), NewSig, (LPARAM)(LPSTR)sz ) ) { HWND hwndList; HWND hwndEdit; int index; index = (int)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); hwndList = GetDlgItem( hwnd, IDD_LIST ); if( EditMap_GetModified( hwndEdit ) && ComboBox_GetCount( hwndList ) > 0 ) if( !CmdSignatureDlg_SaveSig( hwnd, index ) ) break; AnsiUpper( sz ); if( ( index = ComboBox_FindStringExact( hwndList, -1, sz ) ) == LB_ERR ) index = ComboBox_AddString( hwndList, sz ); EnableControl( hwnd, IDOK, TRUE ); EnableControl( hwnd, IDD_DELETE, TRUE ); ComboBox_SetCurSel( hwndList, index ); CmdSignatureDlg_DisplaySig( hwnd, index ); fCancelToClose( hwnd, IDCANCEL ); SetFocus( hwndEdit ); } break; } case IDD_DELETE: { HWND hwndList; int index; hwndList = GetDlgItem( hwnd, IDD_LIST ); if( ( index = ComboBox_GetCurSel( hwndList ) ) != CB_ERR ) { char sz[ _MAX_FNAME ]; PCAT pcat; PCL pcl; PTL ptl; /* Get confirmation first. */ if( IDNO == fMessageBox( hwnd, 0, GS(IDS_STR975), MB_YESNO|MB_ICONINFORMATION ) ) break; /* Get the signature and delete the signature * file itself. */ ComboBox_GetLBText( hwndList, index, sz ); lstrcat( sz, ".sig" ); Ameol2_DeleteFile( sz, DSD_SIG ); /* Remove the signature from the listbox and display the * next one, if there is one. */ if( ComboBox_DeleteString( hwndList, index ) == index ) --index; if( index != CB_ERR ) { ComboBox_SetCurSel( hwndList, index ); CmdSignatureDlg_DisplaySig( hwnd, index ); } else { InvalidateRect( hwndList, NULL, FALSE ); UpdateWindow( hwndList ); EnableControl( hwnd, IDD_DELETE, FALSE ); EnableControl( hwnd, IDOK, FALSE ); Edit_SetText( GetDlgItem( hwnd, IDD_EDIT ), "" ); } /* For every topic which used the signature just deleted, * change it to the global signature. */ ComboBox_GetLBText( hwndList, index, sz ); for( pcat = Amdb_GetFirstCategory(); pcat; pcat = Amdb_GetNextCategory( pcat ) ) for( pcl = Amdb_GetFirstFolder( pcat ); pcl; pcl = Amdb_GetNextFolder( pcl ) ) for( ptl = Amdb_GetFirstTopic( pcl ); ptl; ptl = Amdb_GetNextTopic( ptl ) ) { TOPICINFO topicinfo; Amdb_GetTopicInfo( ptl, &topicinfo ); if( lstrcmp( topicinfo.szSigFile, sz ) == 0 ) Amdb_SetTopicSignature( ptl, szGlobalSig ); } fCancelToClose( hwnd, IDCANCEL ); } break; } case IDOK: { HWND hwndEdit; int index; index = (int)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); if( EditMap_GetModified( hwndEdit ) ) if( !CmdSignatureDlg_SaveSig( hwnd, index ) ) break; EndDialog( hwnd, TRUE ); break; } case IDCANCEL: { HWND hwndEdit; hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); if( EditMap_GetModified( hwndEdit ) ) { register int r; r = fMessageBox( hwnd, 0, GS(IDS_STR516), MB_YESNOCANCEL|MB_ICONINFORMATION ); if( r == IDCANCEL ) break; if( r == IDYES ) { int index; index = (int)GetWindowLong( hwnd, DWL_USER ); if( !CmdSignatureDlg_SaveSig( hwnd, index ) ) break; } } EndDialog( hwnd, FALSE ); break; } } }
/* This function handles the WM_COMMAND message. */ void FASTCALL LocalTopic_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_EDIT: if( codeNotify == EN_UPDATE ) EnableControl( hwnd, IDOK, Edit_GetTextLength( hwndCtl ) > 0 ); break; case IDOK: { HWND hwndList; int index; PCL pcl; ptlLocalTopicName = NULL; /* First check that the user selected a folder. */ hwndList = GetDlgItem( hwnd, IDD_LIST ); if( CB_ERR != ( index = ComboBox_GetCurSel( hwndList ) ) ) { pcl = (PCL)ComboBox_GetItemData( hwndList, index ); if( Amdb_IsFolderPtr( pcl ) ) { char szTopicName[ LEN_TOPICNAME+1 ]; HWND hwndEdit; /* Folder okay. Get the topic name. */ hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); Edit_GetText( hwndEdit, szTopicName, LEN_TOPICNAME+1 ); StripLeadingTrailingSpaces( szTopicName ); if( *szTopicName ) { /* Make sure the name is valid. Another check for * spaces which aren't permitted in local topics. */ if( !IsValidFolderName( hwnd, szTopicName ) ) break; if( strchr( szTopicName, ' ' ) != NULL ) { wsprintf( lpTmpBuf, GS(IDS_STR1154), ' ' ); fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONINFORMATION ); break; } /* Check that the topic doesn't already exist. */ if( NULL == Amdb_OpenTopic( pcl, szTopicName ) ) { ptlLocalTopicName = Amdb_CreateTopic( pcl, szTopicName, FTYPE_LOCAL ); Amdb_CommitDatabase( FALSE ); EndDialog( hwnd, FALSE ); break; } /* Error - topic already exists. */ fMessageBox( hwnd, 0, GS(IDS_STR833), MB_OK|MB_ICONEXCLAMATION ); break; } } } break; } case IDCANCEL: EndDialog( hwnd, FALSE ); break; } }
int main( int argc, char *argv[] ) { BOOL new_hk; BOOL new_rt; int i; if ( argc < 2 ) printf( "Using default root path for cache files: %s\n", packetCacheFilenameRoot ); else { packetCacheFilenameRoot = argv[1]; printf( "Using command-line root path for cache files: %s\n", packetCacheFilenameRoot ); } // Construct the paths to the cache files where we expect to read the incoming packets. CreateGripPacketCacheFilename( hkPacketCacheFilePath, sizeof( hkPacketCacheFilePath ), GRIP_HK_BULK_PACKET, packetCacheFilenameRoot ); CreateGripPacketCacheFilename( rtPacketCacheFilePath, sizeof( rtPacketCacheFilePath ), GRIP_RT_SCIENCE_PACKET, packetCacheFilenameRoot ); // Attempt to open the packet cache to read the accumulated packets. // If it is not immediately available, try for a few seconds then query the user. // The user can choose to continue to wait or cancel program execution. int retry_count; int return_code; int fid; int packets_read = 0; char *filename = rtPacketCacheFilePath; int bytes_read; do { for ( retry_count = 0; retry_count < MAX_OPEN_CACHE_RETRIES; retry_count ++ ) { // If open succeeds, it will return zero. So if zero return, break from retry loop. return_code = _sopen_s( &fid, filename, _O_RDONLY | _O_BINARY, _SH_DENYNO, _S_IWRITE | _S_IREAD ); if ( return_code == 0 ) break; // Wait a second before trying again. Sleep( RETRY_PAUSE ); } // If return_code is zero, file is open, so break out of loop and continue. if ( return_code == 0 ) break; // If return_code is non-zero, we are here because the retry count has been reached without opening the file. // Ask the user if they want to keep on trying or abort. else { int mb_answer = fMessageBox( MB_RETRYCANCEL, "GraspMMIlite", "Error opening %s for binary read.\nContinue trying?", filename ); if ( mb_answer == IDCANCEL ) exit( ERROR_CACHE_NOT_FOUND ); // User chose to abort. } } while ( true ); // Keep trying until success or until user cancels. // Read in all of the data packets in the file. packets_read = 0; while ( rtPacketLengthInBytes == (bytes_read = _read( fid, &rtPacket, rtPacketLengthInBytes )) ) { packets_read++; if ( bytes_read < 0 ) { fMessageBox( MB_OK, "GraspMMIlite", "Error reading from %s.", filename ); exit( -1 ); } // Check that it is a valid GRIP packet. It would be strange if it was not. ExtractEPMTelemetryHeaderInfo( &epmHeader, &rtPacket ); if ( epmHeader.epmSyncMarker != EPM_TELEMETRY_SYNC_VALUE || epmHeader.TMIdentifier != GRIP_RT_ID ) { fMessageBox( MB_OK, "GraspMMIlite", "Unrecognized packet from %s.", filename ); exit( -1 ); } // Show some of the realtime science data. ExtractGraspRealtimeDataInfo( rtInfo, rtPacket ); for ( int i = 0; i < GRASP_RT_SLICES_PER_PACKET; i++ ) { if ( strcmp( (char *) rtInfo.dataSlice[i].clientData, "NULL" ) ) { printf( "\nFill Time: %8.3f Frame Time: %8.3f Client Time: %8.3f Client Tag: %s", rtInfo.dataSlice[i].fillTime, rtInfo.dataSlice[i].codaFrame.time, rtInfo.dataSlice[i].clientTime, rtInfo.dataSlice[i].clientData ); if ( !strcmp( "GRASP", (char *) rtInfo.dataSlice[i].clientData ) ) { Grasp::GraspClientData *grasp = (Grasp::GraspClientData *) rtInfo.dataSlice[i].clientData; printf( " %d %6s %08x", grasp->currentTrial, Grasp::GraspParadigmString[grasp->paradigm], grasp->currentState ); Pose pose; char *object; int visible; // vm.CopyPose( pose, grasp->headPose ); object = "Head"; visible = rtInfo.dataSlice[i].HMD.visible; // vm.CopyPose( pose, grasp->handPose ); object = "Hand"; visible = rtInfo.dataSlice[i].hand.visible; vm.CopyPose( pose, rtInfo.dataSlice[i].hand.pose ); object = "Hand"; visible = rtInfo.dataSlice[i].hand.visible; // vm.CopyPose( pose, grasp->chestPose ); object = "Chest"; visible = rtInfo.dataSlice[i].chest.visible; printf( " %5s: %d %s %s", object, visible, vm.vstr( pose.position ), vm.qstr( pose.orientation ) ); } if ( !strcmp( "GRSPGUI", (char *) rtInfo.dataSlice[i].clientData ) ) { GraspGUI::GraspActionSlice *action = (GraspGUI::GraspActionSlice *) rtInfo.dataSlice[i].clientData; for (int j = 0; j < GUI_ITEMS_IN_SLICE; j++ ) { printf( " %03d.%03d.%05d", action->record[j].task, action->record[j].step, action->record[j].code ); } } if ( !strcmp( "ALIGN", (char *) rtInfo.dataSlice[i].clientData ) ) { AlignToRigidBodyGUI::AlignClientBuffer *align = (AlignToRigidBodyGUI::AlignClientBuffer *) rtInfo.dataSlice[i].clientData; printf( " %4s", ( align->prePost == PRE ? "PRE" : "POST" ) ); for ( int unit = 0; unit < MAX_UNITS; unit++ ) { printf( " Coda %d: %s %s", unit, vm.vstr( align->offsets[unit], "<%+6.1f %+6.1f %+6.1f>" ), vm.mstr( align->rotations[unit], "[%+4.3f %+4.3f %+4.3f | %+4.3f %+4.3f %+4.3f | %+4.3f %+4.3f %+4.3f]" ) ); } } } } if ( 0 == ( packets_read % 1000 ) ) { printf( "\nPress a key to continue ..." ); fflush( stdout ); int c = _getch(); if ( ESCAPE == c ) exit( 0 ); } } // Finished reading. Close the file and check for errors. return_code = _close( fid ); if ( return_code ) { fMessageBox( MB_OK, "GraspMMIlite", "Error closing %s after binary read.\nError code: %s", filename, return_code ); exit( return_code ); } printf( "\n\nPress any key to exit ..." ); fflush( stdout ); _getch(); return 0; }
/* This function handles the WM_COMMAND message. */ void FASTCALL Comms_Blink_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_NEW: { LPBLINKENTRY lpbe; HWND hwndList; char sz[ 40 ]; int index; /* First get the name for our new entry. */ if( !Adm_Dialog( hRscLib, hwnd, MAKEINTRESOURCE(IDDLG_NEWBLINKENTRY), NewBlinkEntryDlg, (LPARAM)(LPSTR)sz ) ) break; /* Next, create an entry with default attributes and * add it to the listbox. */ VERIFY( hwndList = GetDlgItem( hwnd, IDD_LIST ) ); lpbe = AddBlinkToCommandTable( sz, BF_FULLCONNECT, szCIXConnCard, 0, FALSE ); index = ListBox_AddString( hwndList, lpbe->szName ); ListBox_SetItemData( hwndList, index, (LPARAM)lpbe ); ListBox_SetCurSel( hwndList, index ); /* Finally, fall thru to the Properties * dialog to edit the blink properties. * PS: Yuk! */ codeNotify = LBN_DBLCLK; } case IDD_LIST: if( codeNotify == LBN_SELCHANGE ) { Comms_Blink_SelChange( hwnd ); break; } else if( codeNotify != LBN_DBLCLK ) break; /* Fall thru to edit selected item. */ case IDD_PROPERTIES: { LPBLINKENTRY lpbe; HWND hwndList; int index; /* Get the selected entry. */ VERIFY( hwndList = GetDlgItem( hwnd, IDD_LIST ) ); index = ListBox_GetCurSel( hwndList ); ASSERT( index != LB_ERR ); lpbe = (LPBLINKENTRY)ListBox_GetItemData( hwndList, index ); ASSERT( 0L != lpbe ); BlinkmanProperties( GetParent( hwnd ), lpbe ); break; } case IDD_REMOVE: { LPBLINKENTRY lpbe; HWND hwndList; int index; /* Get the selected entry. */ VERIFY( hwndList = GetDlgItem( hwnd, IDD_LIST ) ); index = ListBox_GetCurSel( hwndList ); ASSERT( index != LB_ERR ); lpbe = (LPBLINKENTRY)ListBox_GetItemData( hwndList, index ); ASSERT( 0L != lpbe ); /* Cannot delete the Default blink command. */ if( strcmp( lpbe->szName, "Full" ) == 0 ) break; /* Ask before we chop. */ wsprintf( lpTmpBuf, GS(IDS_STR988), lpbe->szName ); if( fMessageBox( hwnd, 0, lpTmpBuf, MB_YESNO|MB_ICONINFORMATION ) == IDYES ) { int count; /* Delete the entry and also remove it from the * listbox and highlight the next entry. */ DeleteBlinkManagerEntry( lpbe ); count = ListBox_DeleteString( hwndList, index ); if( count == index ) --index; ListBox_SetCurSel( hwndList, index ); } SetFocus( hwndList ); break; } } }