void NativeButton::SetIsDefault(bool is_default) { if(is_default == is_default_) { return; } if(is_default) { AddAccelerator(Accelerator(VKEY_RETURN, false, false, false)); } else { RemoveAccelerator(Accelerator(VKEY_RETURN, false, false, false)); } SetAppearsAsDefault(is_default); }
/*********************************** ** ** Removes a keyboard accelerator. ** ** Macro returns: ** ** No macro return value. ** ** Function returns: ** ** TRUE: No parsing error. ** FALSE: Parsing error. ** ***********************************/ BOOL CALLBACK RemoveAcceleratorMacroProc ( HMACROENGINE hMacroEngine, HGLOBAL hAppData, HGLOBAL hMacroData, MACRORETVAL __far * MacroRetValPtr ) { HLPMACRODATAPTR HelpMacroDataPtr; HWND hDataWnd; WORD wKey, wShiftState; /* Lock app. data. */ HelpMacroDataPtr = ( HLPMACRODATAPTR ) GlobalLock( hAppData ); /* Get data window's handle. */ hDataWnd = HelpMacroDataPtr->hDataWnd; /* Unlock app. data. */ GlobalUnlock( hAppData ); /* Get the accelerator's key. */ if( ! GetNextMacroArg( hDataWnd, hMacroEngine, &wKey, MACRO_UNSIGNEDSHORTINT) ) { /* Macro syntax error. */ return( FALSE ); } /* Get the accelerator's shift state. */ if( ! GetNextMacroArg( hDataWnd, hMacroEngine, &wShiftState, MACRO_UNSIGNEDSHORTINT) ) { /* Macro syntax error. */ return( FALSE ); } /* Delete the accelerator. */ RemoveAccelerator( hDataWnd, wKey, wShiftState ); /* No macro syntax errors. */ return( TRUE ); }
BOOL COXShortkeysOrganizer::AddAccelerator(BYTE fVirt, WORD key, WORD cmd, CMultiDocTemplate* pDocTemplate, BOOL bIgnoreConflict/*=FALSE*/) { if(!IsAttached()) { TRACE(_T("COXShortkeysOrganizer::AddAccelerator: there is no attached frame window. You have to attach frame window before calling this function\n")); return FALSE; } COXArrAccelerators* pArrAccels=FindAcceleratorTable(pDocTemplate); if(pArrAccels==NULL) { return FALSE; } WORD cmdExisting=FindAccelerator(fVirt,key,pDocTemplate); if(cmdExisting!=0) { if(!bIgnoreConflict) { TRACE(_T("COXShortkeysOrganizer::AddAccelerator: the shortkey already exists\n")); return FALSE; } else { VERIFY(RemoveAccelerator(fVirt,key,cmdExisting,pDocTemplate)); } } ACCEL accel; accel.fVirt=fVirt; accel.key=key; accel.cmd=cmd; pArrAccels->Add(accel); return TRUE; }
BOOL COXShortkeysOrganizer::RemoveAccelerator(ACCEL* pAccel, CMultiDocTemplate* pDocTemplate) { ASSERT(pAccel!=NULL); return RemoveAccelerator(pAccel->fVirt,pAccel->key,pAccel->cmd,pDocTemplate); }