BOOL CBCGPRegistry::Write(LPCTSTR pszKey, LPPOINT& lpPoint) { if (m_bReadOnly) { ASSERT (FALSE); return FALSE; } ASSERT(m_hKey); BYTE* pData = NULL; DWORD dwLen = 0; { CMemFile file(32); CArchive ar(&file, CArchive::store); CDWordArray dwcArray; dwcArray.SetSize(2); dwcArray.SetAt(0, lpPoint->x); dwcArray.SetAt(1, lpPoint->y); ASSERT(dwcArray.IsSerializable()); dwcArray.Serialize(ar); ar.Close(); dwLen = (DWORD) file.GetLength(); pData = file.Detach(); } ASSERT(pData != NULL && dwLen > 0); LONG lReturn = RegSetValueEx(m_hKey, pszKey, 0, REG_BINARY, pData, dwLen); m_Info.lMessage = lReturn; m_Info.dwSize = dwLen; m_Info.dwType = REG_POINT; if (pData != NULL) { free(pData); pData = NULL; } if(lReturn == ERROR_SUCCESS) return TRUE; return FALSE; }
BOOL CRegistry::Write(LPCTSTR pszKey, LPPOINT& lpPoint) { if (m_bReadOnly) { ASSERT (FALSE); return FALSE; } ASSERT(m_hKey); const int iMaxChars = 20; CDWordArray dwcArray; BYTE* byData = (BYTE*)::calloc(iMaxChars, sizeof(TCHAR)); ASSERT(byData); dwcArray.SetSize(5); dwcArray.SetAt(0, lpPoint->x); dwcArray.SetAt(1, lpPoint->y); CMemFile file(byData, iMaxChars, 16); CArchive ar(&file, CArchive::store); ASSERT(dwcArray.IsSerializable()); dwcArray.Serialize(ar); ar.Close(); const DWORD dwLen = (DWORD) file.GetLength(); ASSERT(dwLen < iMaxChars); LONG lReturn = RegSetValueEx(m_hKey, pszKey, 0, REG_BINARY, file.Detach(), dwLen); m_Info.lMessage = lReturn; m_Info.dwSize = dwLen; m_Info.dwType = REG_POINT; if(byData) { free(byData); byData = NULL; } if(lReturn == ERROR_SUCCESS) return TRUE; return FALSE; }
BOOL CWindowGroups::ArrangeWindows(CWnd *pParentWindow) { int i; RECT rect = { 0, 0, 0, 0 }; const DWORD dwYStep = static_cast<DWORD>(NewGUI_Scale(WG_Y_STEP, pParentWindow)); CDWordArray aPos; aPos.RemoveAll(); const DWORD dwXOffset = static_cast<DWORD>(NewGUI_Scale(WG_OFFSET_LEFT, pParentWindow)); const DWORD dwYOffset = static_cast<DWORD>(NewGUI_Scale(WG_OFFSET_TOP, pParentWindow)); for(i = 0; i < m_aWindows.GetSize(); i++) aPos.Add(dwYOffset); for(i = 0; i < m_aWindows.GetSize(); i++) { if((m_aFlags.GetAt(i) & WGF_REPOSITION) == 0) continue; CWnd *p = (CWnd *)m_aWindows.GetAt(i); if(p != NULL) { p->GetWindowRect(&rect); rect.right = rect.right - rect.left; // Coords to sizes rect.bottom = rect.bottom - rect.top; } rect.top = (LONG)aPos.GetAt((int)m_aGroupIDs.GetAt(i)); rect.left = dwXOffset; if(p != NULL) p->MoveWindow(rect.left, rect.top, rect.right, rect.bottom, TRUE); aPos.SetAt((int)m_aGroupIDs.GetAt(i), (DWORD)rect.top + dwYStep); } aPos.RemoveAll(); return TRUE; }
//*************************************************************************************** BOOL CBCGPXMLSettings::Write(LPCTSTR pszKey, LPPOINT& lpPoint) { if (m_bReadOnly) { ASSERT (FALSE); return FALSE; } const int iMaxChars = 20; CDWordArray dwcArray; BYTE* byData = (BYTE*)::calloc(iMaxChars, sizeof(TCHAR)); ASSERT(byData); dwcArray.SetSize(5); dwcArray.SetAt(0, lpPoint->x); dwcArray.SetAt(1, lpPoint->y); CMemFile file(byData, iMaxChars, 16); CArchive ar(&file, CArchive::store); ASSERT(dwcArray.IsSerializable()); dwcArray.Serialize(ar); ar.Close(); #if _MSC_VER >= 1300 ULONGLONG dwLen = file.GetLength (); #else const DWORD dwLen = file.GetLength (); #endif LPBYTE lpbData = file.Detach (); BOOL bRes = Write (pszKey, lpbData, (UINT) dwLen); if(byData) { free(byData); byData = NULL; } return bRes; }