//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { CDXUTComboBox* pComboBox = NULL; CDXUTComboBox* pAABBLevelComboBox = NULL; switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEWARP: DXUTToggleWARP(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break; case IDC_SCENERASTERIZER_MODE: //CDXUTComboBox* pComboBox = NULL; pComboBox = ( CDXUTComboBox* )pControl; g_eSceneRasterizerMode = ( UINT )PtrToInt( pComboBox->GetSelectedData() ); break; case IDC_AABBSUBLEVEL: pAABBLevelComboBox = ( CDXUTComboBox* )pControl; g_CurrentAABBLevel = ( UINT )PtrToInt( pAABBLevelComboBox->GetSelectedData() ); break; } }
void COXString::LTrim() { int nStringIndex = 0; int nLength = GetLength(); // find first non-space character LPCTSTR lpsz = *this; while (_istspace(*lpsz)) #ifdef WIN32 lpsz = _tcsinc(lpsz); #else lpsz++; #endif // fix up data and length #if _MFC_VER < 0x0700 nStringIndex = lpsz - m_pchData; #else nStringIndex = PtrToInt(lpsz - GetBuffer()); #endif if (nStringIndex == nLength) *this = COXString(_T("")); else *this = Mid(nStringIndex); }
int COXMonthCalCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const { ASSERT_VALID(this); ASSERT(::IsWindow(GetSafeHwnd())); // the control should be designated to provide tooltips if((GetMonthCalStyle()&OXMCS_INFOTIP)==0) return -1; pTI->hwnd=GetSafeHwnd(); GetClientRect(&pTI->rect); MCHITTESTINFO mcHitTest; ::ZeroMemory((void*)&mcHitTest,sizeof(mcHitTest)); mcHitTest.cbSize=sizeof(mcHitTest); mcHitTest.pt=point; /// HitTest(&mcHitTest); ::SendMessage(GetSafeHwnd(),MCM_HITTEST,0,(LPARAM)&mcHitTest); pTI->uId=mcHitTest.uHit; pTI->uFlags&=~(TTF_IDISHWND); // set text to LPSTR_TEXTCALLBACK in order to get TTN_NEEDTEXT message when // it's time to display tool tip pTI->lpszText=LPSTR_TEXTCALLBACK; return PtrToInt(pTI->uId); }
void COXSizeControlBar::TidyUp(CFrameWnd* pTopLevelFrame) { if(m_parrAllocBars!=NULL) { for (int i = PtrToInt(m_parrAllocBars->GetUpperBound()); i >= 0; i--) { ASSERT((*m_parrAllocBars)[i]-> IsKindOf(RUNTIME_CLASS(COXSizeControlBar))); if(::IsWindow(((COXSizeControlBar*)(*m_parrAllocBars)[i])->GetSafeHwnd()) && ((COXSizeControlBar*)(*m_parrAllocBars)[i])->GetTopLevelFrame()== pTopLevelFrame) { ((COXSizeControlBar*)(*m_parrAllocBars)[i])->DestroyWindow(); } if(!::IsWindow(((COXSizeControlBar*)(*m_parrAllocBars)[i])->GetSafeHwnd())) { delete ((*m_parrAllocBars)[i]); } } if(m_parrAllocBars->GetSize()==0) { delete m_parrAllocBars; m_parrAllocBars=NULL; } } }
BOOL COXCsvFile::SetAliases(const CString& sName, const CStringArray& arrAliases) { if(FindColumn(sName)!=1) { // // The original name was found, no need to look any further // return TRUE; } // // The original name was not found, look for the aliases // int nIndex; int nAlias; int nCount=PtrToInt(arrAliases.GetSize()); for(nAlias=0; nAlias<nCount; ++nAlias) { nIndex=FindColumn(arrAliases[nAlias]); if(nIndex!=-1) { // // We have found an alias, rename this column and return // m_arrColumns[nIndex].m_sName=sName; return TRUE; } } // // No luck finding the original name, or any of its aliases // return FALSE; }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break; case IDC_TOGGLEWARP: DXUTToggleWARP(); break; case IDC_TOGGLE_BLUR: g_bUseMotionBlur = !g_bUseMotionBlur; break; case IDC_RENDER_OGRE: g_bRenderOgre = !g_bRenderOgre; break; case IDC_SAMPLE_COUNT: { CDXUTComboBox* pComboBox = ( CDXUTComboBox* )pControl; g_MSAASampleCount = ( UINT )PtrToInt( pComboBox->GetSelectedData() ); HRESULT hr = S_OK; ID3D10Device* pd3dDevice = DXUTGetD3D10Device(); if( pd3dDevice ) V( CreateRenderTarget( pd3dDevice, g_BackBufferWidth, g_BackBufferHeight, g_MSAASampleCount, 0 ) ); } break; } }
HACCEL COXShortkeysOrganizer::BuildAccelTable(CMultiDocTemplate* pDocTemplate) { if(!IsAttached()) { TRACE(_T("COXShortkeysOrganizer::BuildAccelTable: there is no attached frame window. You have to attach frame window before calling this function\n")); return NULL; } COXArrAccelerators* pArrAccels=FindAcceleratorTable(pDocTemplate); if(pArrAccels==NULL) { TRACE(_T("COXShortkeysOrganizer::BuildAccelTable: accelerator table for specified CMultiDocTemplate object doesn't exist\n")); return NULL; } ACCEL* pAccelTable=new ACCEL[pArrAccels->GetSize()]; if(pAccelTable==NULL) { TRACE(_T("COXShortkeysOrganizer::BuildAccelTable: failed to allocate memory for new accelerator table\n")); return NULL; } for(int nIndex=0; nIndex<pArrAccels->GetSize(); nIndex++) { pAccelTable[nIndex].fVirt=pArrAccels->GetAt(nIndex).fVirt; pAccelTable[nIndex].key=pArrAccels->GetAt(nIndex).key; pAccelTable[nIndex].cmd=pArrAccels->GetAt(nIndex).cmd; } HACCEL hNewTable=::CreateAcceleratorTable(pAccelTable,PtrToInt(pArrAccels->GetSize())); m_arrCreatedAccel.Add(hNewTable); delete[] pAccelTable; return hNewTable; }
BOOL COXCustomizeManager::FindPage(COXCustomizePage* pCustomizePage, HSHBGROUP& hGroupTest, int& nIndexTest) const { if(pCustomizePage==NULL) return FALSE; BOOL bFound=FALSE; int nGroupCount= PtrToInt(m_shb.GetGroupCount()); for(int nIndex=0; nIndex<nGroupCount; nIndex++) { HSHBGROUP hGroup=m_shb.FindGroupByOrder(nIndex); ASSERT(hGroup!=NULL); COXSHBListCtrl* pListCtrl=m_shb.GetGroupListCtrl(hGroup); if(pListCtrl!=NULL) { LV_FINDINFO findInfo; findInfo.flags=LVFI_PARAM; findInfo.lParam=(LPARAM)pCustomizePage; nIndexTest=pListCtrl->FindItem(&findInfo); if(nIndexTest!=-1) { hGroupTest=hGroup; bFound=TRUE; break; } } } return bFound; }
LRESULT COXStatusBar::OnSetMinHeight(WPARAM wParam, LPARAM) { LRESULT lResult=Default(); // MFC does not allow a height smaller than the font height m_nMinHeight=PtrToInt(wParam); return lResult; }
static BOOL CALLBACK EnumResLangProc( HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam ) { if (IS_INTRESOURCE(lpszName)) { std::vector<std::pair<int,WORD>> &oldStrings=*(std::vector<std::pair<int,WORD>>*)lParam; oldStrings.push_back(std::pair<int,WORD>(PtrToInt(lpszName),wIDLanguage)); } return TRUE; }
// deletes the underlying array and it's elements void DestroyGadgetResizeHandle(GADGETRESIZEHANDLE Handle) { CPtrArray* pArray = (CPtrArray*)Handle; if (pArray != NULL) { for (int i = PtrToInt(pArray->GetUpperBound()); i >= 0; i--) delete ((RECT_AND_HWND*)pArray->GetAt(i)); delete pArray; } }
int COXLayoutManager::GetChildIndex(UINT nChildWnd) const // --- In : nChildWnd, the child window to search // --- Out : // --- Returns : index of a child window in m_wcTable // --- Effect : search m_wcTable for nChildWnd { int i = 0; for (i = PtrToInt(m_wcTable.GetSize()) - 1; i >= 0 && m_wcTable[i]->nID != nChildWnd; i--); return i; }
int COXWatchBuffer::GetUnmodified() const { ASSERT_VALID(this); ASSERT(sizeof(BYTE) == 1); LPBYTE pModified = (LPBYTE)memchr(m_pFlags, FALSE, m_nLength); if (pModified != NULL) return PtrToInt(pModified - m_pFlags); else return -1; }
void COXString::Format(LPCTSTR pszFormat, LPCTSTR* rgpsz, int nString) { // NOTE: will not work for strings > 255 characters int nTotalLen = PtrToInt(_tcslen(pszFormat)); int i = 0; for (i = 0; i < nString; i++) { if (rgpsz[i] != NULL) nTotalLen += PtrToInt(_tcslen(rgpsz[i])); } LPCTSTR pchSrc = pszFormat; LPTSTR pchDestBegin = GetBuffer(nTotalLen+1); LPTSTR pchDest = pchDestBegin; while (*pchSrc != '\0') { if (pchSrc[0] == _T('%') && (pchSrc[1] >= _T('1') && pchSrc[1] <= _T('9'))) { i = pchSrc[1] - _T('1'); pchSrc += 2; if (i >= nString) { TRACE1("COXString::Format : Illegal string index requested %d\n", i); *pchDest++ = _T('?'); } else if (rgpsz[i] != NULL) { UTBStr::tcscpy(pchDest, nTotalLen, rgpsz[i]); pchDest += _tcslen(pchDest); } } else { *pchDest++ = *pchSrc++; } } ReleaseBuffer((int)((LPCTSTR)pchDest - (LPCTSTR)pchDestBegin)); // Release will assert if we went too far }
DWORD COXTabViewContainer::GetUniqueId() { int nCount=PtrToInt(m_arrUniqueIDs.GetSize()); ASSERT(nCount>0); DWORD dwUniqueID=m_arrUniqueIDs[nCount-1]; if(nCount==1) { m_arrUniqueIDs.SetAt(nCount-1,dwUniqueID+1); } return dwUniqueID; }
int COXCustomizeManager::GetAllPageCount() const { int nPageCount=0; int nGroupCount= PtrToInt(m_shb.GetGroupCount()); for(int nIndex=0; nIndex<nGroupCount; nIndex++) { HSHBGROUP hGroup=m_shb.FindGroupByOrder(nIndex); ASSERT(hGroup!=NULL); nPageCount+=GetPageCount(hGroup); } return nPageCount; }
LRESULT COXAutoComplete::KeyboardProc(int code, WPARAM wParam, LPARAM lParam) { ASSERT(m_pThis); if (code<0) return ::CallNextHookEx(m_pThis->m_hkKbrd,code,wParam,lParam); else { CString sText; CWnd* pWnd=CWnd::GetFocus(); COXAutoStorage* pStorage; _AFX_THREAD_STATE* pThreadState=AfxGetThreadState(); if(pThreadState->m_hTrackingWindow==NULL && pWnd!=NULL && m_pThis->m_mpStorage.Lookup(pWnd->m_hWnd,pStorage)) { if (lParam<0)//key is pressed { switch (wParam) { case VK_NEXT: case VK_PRIOR: case VK_UP: case VK_DOWN: m_pThis->ChangeSel(PtrToInt(wParam)); return TRUE; break; default: if (wParam>VK_HELP) { pWnd->GetWindowText(sText); m_pThis->OnContentsChange(pWnd->m_hWnd,sText); } } } else { switch (wParam) { case VK_NEXT: case VK_PRIOR: case VK_UP: case VK_DOWN: return TRUE; } } } } return ::CallNextHookEx(m_pThis->m_hkKbrd,code,wParam,lParam); }
int COXLayoutManager::AddChild(UINT nChildWnd, BOOL bSetDefaultConstraints /* = TRUE */) { // we do not validate ID here in case child window not created yet, instead we'll do it // at run-time when calculating coordinates // cannot be topmost window if (nChildWnd == 0) return -1; // already added previously int nIndex = PtrToInt(GetChildIndex(nChildWnd)); if (nIndex == -1) { COXWndConstraint* pWC = new COXWndConstraint(nChildWnd); nIndex = PtrToInt(m_wcTable.Add(pWC)); } if (bSetDefaultConstraints) SetDefaultConstraint(nChildWnd); return nIndex; }
void COXFileList::ClearList() { COXFileSpec* pFile; int nIndex = 0; int nMaxIndex = PtrToInt(m_fileArray.GetUpperBound()); while (nIndex <= nMaxIndex) { ASSERT(m_fileArray[nIndex]->IsKindOf(RUNTIME_CLASS(COXFileSpec))); pFile = (COXFileSpec*)m_fileArray[nIndex]; delete pFile; nIndex++; } m_fileArray.RemoveAll(); }
COXSizeControlBar::~COXSizeControlBar() { // if the bar was created with this flag, then ensure it is deleted with it also. if (m_Style & SZBARF_AUTOTIDY) { int i; for (i = PtrToInt(m_parrAllocBars->GetUpperBound()); i >= 0; i--) if ((*m_parrAllocBars)[i] == this) { m_parrAllocBars->RemoveAt(i); break; } ASSERT(i >= 0); // means we didn't delete this item from the list } // This loop of debug code checks that we don't have any other references in the array. // This happens if we changed the auto delete flag during the lifetime of the control bar. #ifdef _DEBUG if (m_parrAllocBars != NULL) { for (int i = PtrToInt(m_parrAllocBars->GetUpperBound()); i >= 0; i--) ASSERT ((*m_parrAllocBars)[i] != this); } #endif if(m_pDockContext!=NULL) { // delete the dock context here - in an attempt to call the correct destructor delete (COXDragDockContext*)m_pDockContext; m_pDockContext = NULL; } // delete the classic skin if ( m_pDockbarSkin != NULL ) delete m_pDockbarSkin; }
OXINTRET COXStatusBar::OnToolHitTest(CPoint point, TOOLINFO* pTI) const { int key=GetAsyncKeyState(VK_LBUTTON); if(key&0x8001) { return -1; } ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); CRect PaneRect; // check child windows first by calling CControlBar int nHit= PtrToInt(CControlBar::OnToolHitTest(point, pTI)); if (nHit != -1) { if (pTI != NULL) { pTI->uFlags &= ~TTF_NOTBUTTON; pTI->uFlags &= ~TTF_CENTERTIP; pTI->lpszText=_tcsdup(m_TipArray.GetAt(nHit)); } return nHit + m_nCount; // register a different toolinfo struct than the percent text } // now hit test against Panes of Statusbar for (int i=0; i < m_nCount; i++) { GetItemRect(i, PaneRect); if (PaneRect.PtInRect(point)) { if (pTI != NULL) { pTI->hwnd=m_hWnd; pTI->rect=PaneRect; pTI->lpszText=_tcsdup(m_TipArray.GetAt(i)); } // found matching rect, return the ID of the Pane return GetItemID(i); } } return -1; }
COXIteratorService COXIteratorService::operator+(int nOffset) { ASSERT(m_nPos != OXITERATORSERVICE_POS_NULL); if (m_nPos == OXITERATORSERVICE_POS_NULL) return *this; Empty(); m_nPos += nOffset; if (m_nPos <= -1) m_nPos = -1; else if (m_nPos >= m_SrvKeyNames.GetSize()) m_nPos = PtrToInt(m_SrvKeyNames.GetSize()); else m_sKeyName = m_SrvKeyNames[m_nPos]; return *this; }
void COXToolTipCtrl::SetTipTextColor(COLORREF clr) { // Update the width for all tooltips whose width is standard. // Non-standard widths have obviously been modified outside // of this function, so leave them be. int nSize = PtrToInt(m_arrTools.GetSize()); for (int i = 0; i < nSize; i++) { COXToolTipInfo* pTool = (COXToolTipInfo*) m_arrTools.GetAt(i); if (!pTool) continue; if (pTool->clrTextColor == m_crTextColor) pTool->clrTextColor = clr; } m_crTextColor = clr; }
COXToolTipCtrl::~COXToolTipCtrl() { m_Font.DeleteObject(); COXToolTipInfo *pInfo = NULL; int nSize = PtrToInt(m_arrTools.GetSize()); for (int nIndex = 0; nIndex < nSize; nIndex++) { pInfo = (COXToolTipInfo* )m_arrTools.GetAt(nIndex); delete pInfo; } m_arrTools.RemoveAll(); if (IsWindow(m_hWnd)) DestroyWindow(); }
LRESULT COXImageListBox::OnDeleteString(WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); LRESULT lResult=Default(); if(lResult!=LB_ERR) { m_imageList.Remove(PtrToInt(wParam)); // update internal data for(int nIndex=(int)wParam; nIndex<GetCount(); nIndex++) { SetItemData(nIndex,GetItemData(nIndex)-1); } } return lResult; }
COXToolTipInfo* COXToolTipCtrl::GetToolInfoPtr(CWnd* pWnd, UINT_PTR nIDTool /*=0*/) { int nSize = PtrToInt(m_arrTools.GetSize()); for (int i = 0; i < nSize; i++) { COXToolTipInfo* pToolInfo = (COXToolTipInfo*) m_arrTools.GetAt(i); if (!pToolInfo) continue; if (pWnd->GetSafeHwnd() == pToolInfo->hWnd && nIDTool == pToolInfo->nIDTool) { return pToolInfo; } } return NULL; }
void COXCsvFile::SetColumns(const CStringArray& arrColumns) { int nIndex; SetError(errNone); // // store the header information // m_nColumns=PtrToInt(arrColumns.GetSize()); m_arrColumns.RemoveAll(); m_arrColumns.SetSize(m_nColumns); for(nIndex=0; nIndex<m_nColumns; ++nIndex) { m_arrColumns[nIndex].m_strData=arrColumns[nIndex]; } }
BOOL COXCsvFile::GetColumns(int nNumExpected) { m_arrColumns.RemoveAll(); m_arrColumns.SetSize(nNumExpected); m_nColumns=nNumExpected; if(ReadLine() || GetLastError()==errTooManyColumns) { if(m_nColumns<m_arrColumns.GetSize()) m_nColumns= PtrToInt(m_arrColumns.GetSize()); for(int nColumn=0; nColumn<m_nColumns; ++nColumn) { m_arrColumns[nColumn].m_sName=m_arrColumns[nColumn].m_strData; m_arrColumns[nColumn].m_strData.Empty(); } return m_nColumns==nNumExpected; } return FALSE; }
int COXToolTipCtrl::SetMaxTipWidth(int nWidth) { int nOldWidth = m_nMaxWidth; m_nMaxWidth = nWidth; // Update the width for all tooltips whose width is standard. // Non-standard widths have obviously been modified outside // of this function, so leave them be. int nSize = PtrToInt(m_arrTools.GetSize()); for (int i = 0; i < nSize; i++) { COXToolTipInfo* pTool = (COXToolTipInfo*) m_arrTools.GetAt(i); if (!pTool) continue; if (pTool->nWidth == nOldWidth) pTool->nWidth = nWidth; } return nOldWidth; }
LRESULT COXCoolComboBox::OnSetFont(WPARAM wParam,LPARAM lParam) { UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(lParam); Default(); CDC* pDC=GetDC(); pDC->SelectObject(GetFont()); TEXTMETRIC tm; pDC->GetTextMetrics(&tm); m_nDefaultFontHeight=tm.tmHeight; m_nDefaultFontHeightSansLeading=pDC->GetTextExtent(_T("ygaQ!|")).cy; ReleaseDC(pDC); int nCurrentHeight=PtrToInt(SendMessage(CB_GETITEMHEIGHT,(WPARAM)-1,0)); if (nCurrentHeight!=m_nDefaultFontHeight+1) SendMessage(CB_SETITEMHEIGHT,(WPARAM)-1,m_nDefaultFontHeight+1); return 0; }