long lGetWindowPlacement(LPCTSTR lpScreenName, WINDOWPLACEMENT *pwp) { TCHAR szBuffer[1000]; DWORD type; DWORD length = sizeof(*pwp); lstrcpy(szBuffer, oszScreenRegistry); lstrcat(szBuffer, lpScreenName); return RegQueryValueExRecursive(HKEY_CURRENT_USER, szBuffer, 0, &type, (BYTE*) pwp, &length); }
long lGetWindowPlacement(const char *oszScreenName, WINDOWPLACEMENT *pwp) { TCHAR szBuffer[1000]; DWORD type; DWORD length = sizeof(*pwp); vMyStrCpy(szBuffer, oszScreenRegistry); vMyStrCpy(szBuffer + strlen(oszScreenRegistry), oszScreenName); return RegQueryValueExRecursive(HKEY_CURRENT_USER, szBuffer, 0, &type, (BYTE*) pwp, &length); }
BOOL ResizeDlg::SetData(const DialogSizerSizingItem *psd, BOOL bShowSizingGrip, HKEY hkRootSave, LPCTSTR pcszName, SIZE *psizeMax) // // Setting a dialog sizeable involves subclassing the window and handling it's // WM_SIZE messages, if we have a hkRootSave and pcszName then we will also be loading/saving // the size and position of the window from the registry. We load from the registry when we // subclass the window and we save to the registry when we get a WM_DESTROY. // // It will return non-zero for success and zero if it fails { R_ASSERT( psd ); R_ASSERT( ( hkRootSave != NULL && pcszName != NULL ) || ( hkRootSave == NULL && pcszName == NULL ) ); // // Make sure all of the parameters are valid. if( ::IsWindow( *this ) && psd && ( ( hkRootSave != NULL && pcszName != NULL && !IsBadStringPtr( pcszName, 0xFFFF ) ) || ( hkRootSave == NULL && pcszName == NULL ) ) && ( psizeMax == NULL || !IsBadReadPtr( psizeMax, sizeof( SIZE ) ) ) ) { DialogData *pdd = (DialogData *)AddDialogData(); if( pdd ) { pdd->hkRootSave = hkRootSave; pdd->pcszName = pcszName; pdd->m_bShowSizingGrip = bShowSizingGrip; pdd->nItemCount = ResizeDlgGetItemCount( psd ) + 1; pdd->psd = (DialogSizerSizingItem *) calloc(pdd->nItemCount, sizeof(DialogSizerSizingItem )); if( pdd->psd ) { // // Copy all of the user controls etc. for later, this way the user can quite happily // let the structure go out of scope. ResizeDlgCopyItems( pdd->psd, psd ); if( psizeMax ) { pdd->m_ptLargest.x = psizeMax->cx; pdd->m_ptLargest.y = psizeMax->cy; pdd->m_bLargestSet = true; } // // If the there was save info passed in then we need to make damn good use of it // by attempting to load the RegistryData structure if( hkRootSave && pcszName ) { RegistryData rd; DWORD dwSize = sizeof( RegistryData ); DWORD dwType = REG_BINARY; if( RegQueryValueExRecursive( hkRootSave, pcszName, NULL, &dwType, reinterpret_cast<LPBYTE>( &rd ), &dwSize ) == ERROR_SUCCESS && dwSize == sizeof( rd ) ) { if( !(GetWindowLong( *this, GWL_STYLE ) & WS_VISIBLE) ) rd.m_wpl.showCmd = SW_HIDE; VAPI( SetWindowPlacement( &rd.m_wpl ) ); } } return TRUE; } else { free(pdd); } } } return FALSE; }