|
for non- ole file types we have to get pointer of IID_IPropertySetStorage rather than istorage and the rest will be the same.
only problme here is we cant update office 2007 file type as the file structure of office 2007 file type is bit different.
if you fine any solution for accessing office 2007 do let me know.
if(nFileType == non- ole)
{
hr =SetPropertySetStorage(pszFilePath);
if (hr == S_OK )
{
hr = SetSummaryInfoStorage();
if(FAILED(hr))
{
printf(" Summaryinfo storage failed w/error %08lx", hr);
return hr;
}
hr = SetCustomInfoStorage();
if(FAILED(hr))
{
printf(" Custom storage failed w/error %08lx", hr);
return hr;
}
}
else
{
return hr;
}
}
HRESULT CFileProperties::SetPropertySetStorage(const char * pszFilePath )
{
HRESULT hr = S_OK;
if(pszFilePath == NULL && m_pStorage != NULL)
{
hr = m_pStorage->QueryInterface(IID_IPropertySetStorage, (void **)&m_pPropSetStg);
if(FAILED(hr))
{
printf("QI for IPropertySetStorage failed w/error %08lx", hr);
//Releasing IStorage
m_pStorage->Release();
m_pStorage = NULL;
return hr;
}
}
else if(pszFilePath != NULL && m_pStorage == NULL)
{
// Translate filename to Unicode.
WCHAR wcFilename[1024];
setlocale( LC_ALL, "" );
int i = mbstowcs(wcFilename, pszFilePath , strlen(pszFilePath ));
setlocale( LC_ALL, "C" );
wcFilename[i] = 0;
// Open the document as an OLE compound document.
hr = StgOpenStorageEx( wcFilename,
STGM_READ|STGM_SHARE_DENY_WRITE,
STGFMT_ANY,
0, NULL, NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&m_pPropSetStg) );
if(FAILED(hr))
{
if(hr == STG_E_FILENOTFOUND)
printf("File not found.");
else if(hr == STG_E_FILEALREADYEXISTS)
printf("Not a compound file.");
else
printf("StgOpenStorage() failed w/error %08lx", hr);
return hr;
}
}
return hr;
}
HRESULT CFileProperties::SetSummaryInfoStorage()
{
HRESULT hr = S_FALSE;
if(m_pPropSetStg != NULL)
{
// Create SummaryInformation, getting an IpropertyStorage.
hr= m_pPropSetStg->Create(FMTID_SummaryInformation,
0,
PROPSETFLAG_DEFAULT,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE,&m_pSummaryInfoStg);
//propertystorage already exists for SummaryInformation
if(hr == STG_E_FILEALREADYEXISTS )
{
// Open summary information, getting an IpropertyStorage.
hr = m_pPropSetStg->Open(FMTID_SummaryInformation,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &m_pSummaryInfoStg);
if(FAILED(hr))
{
printf("No Summary-Information.\n");
return hr;
}
}
}
return hr;
}
HRESULT CFileProperties::SetCustomInfoStorage( )
{
HRESULT hr = S_FALSE;
if(m_pPropSetStg != NULL)
{
// Create UserDefinedProperties, getting an IpropertyStorage.
hr= m_pPropSetStg->Create(FMTID_UserDefinedProperties,
0,
PROPSETFLAG_DEFAULT,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE,&m_pCustomInfoStg);
//propertystorage already exists for UserDefinedProperties
if(hr == STG_E_FILEALREADYEXISTS )
{
// Open User-Defined-Properties, getting an IpropertyStorage.
hr = m_pPropSetStg->Open(FMTID_UserDefinedProperties,
STGM_READWRITE| STGM_SHARE_EXCLUSIVE, &m_pCustomInfoStg);//| STGM_WRITE
if(FAILED(hr))
{
printf("No User Defined Properties.\n");
return hr;
}
}
}
return hr;
}
hi
|
|
|
|
|
For reading Non ole files(office 2007 files)
if (NonOLEGetMetaHandler(m_bstrFileName, &clsidMetaHandler) == S_OK)
{
CoInitialize(NULL);
// Create instance of the Metadata Handler object...
hr = CoCreateInstance(clsidMetaHandler, NULL, CLSCTX_INPROC, IID_IPersistFile,(void**)&prtsf);
if (SUCCEEDED(hr))
{
// Ask it to load the file for parsing...
hr = prtsf->Load(m_bstrFileName, (STGM_READWRITE | STGM_SHARE_EXCLUSIVE));
if (SUCCEEDED(hr))
{
// If it succeeded, ask for the property set storage...
hr = prtsf->QueryInterface(IID_IPropertySetStorage,(void**)&m_pPropSetStg);
if (SUCCEEDED(hr))
{
//ASSIGN_INTERFACE(m_pPrstFile, prtsf);
// hr= m_pPropSetStg->Create(FMTID_SummaryInformation,
// 0,
// PROPSETFLAG_DEFAULT,
// STGM_READWRITE | STGM_SHARE_EXCLUSIVE,&m_pSummaryInfoStg);
hr = SetSummaryInfoStorage();
if(FAILED(hr))
{
printf(" Summaryinfo storage failed w/error %08lx", hr);
return hr;
}
hr = SetCustomInfoStorage();
if(FAILED(hr))
{
printf(" Custom storage failed w/error %08lx", hr);
return hr;
}
prtsf->Release();
}
}
HRESULT CFileProperties::NonOLEGetMetaHandler(LPCWSTR pwszFile, LPCLSID lpClsid)
{
HRESULT hret = REGDB_E_CLASSNOTREG; // Assume no handler
HKEY hkeyExt, hkeyHandler = NULL;
LPSTR pszExt;
if ((pwszFile == NULL) || (*pwszFile == L'\0') || (lpClsid == NULL))
return E_INVALIDARG;
// Get the extension for the file...
pszExt = NonOLEConvertToMBCS(GetExtensionPart(pwszFile), CP_ACP);
if (pszExt == NULL) return E_OUTOFMEMORY;
// Now get the key that is associated with that extension...
hkeyExt = GetHKCRKey("%s", pszExt);
if (hkeyExt)
{
// Check for the handler under that key...
hkeyHandler = GetHKCRKey("%s\\ShellEx\\PropertyHandler", pszExt);
if (hkeyHandler == NULL)
{
CHAR szType[MAX_PATH];
DWORD dwT, cb = MAX_PATH; szType[0] = '\0';
// If it does exist there, check under the associated type...
if ((RegQueryValue(hkeyExt, NULL, szType, (LONG*)&cb) == ERROR_SUCCESS) && (cb))
{
hkeyHandler = GetHKCRKey("%s\\ShellEx\\PropertyHandler", szType);
if (hkeyHandler == NULL)
{
// If still no handler, you can check for handler on the "perceivedtype", which normally
// is for things like images that can have multiple extensions to single base type...
cb = MAX_PATH; szType[0] = '\0';
if ((RegQueryValueEx(hkeyExt, "PerceivedType", NULL, &dwT, (BYTE*)szType, &cb) == ERROR_SUCCESS) &&
(cb) && (dwT == REG_SZ))
{
hkeyHandler = GetHKCRKey("SystemFileAssociations\\%s\\ShellEx\\PropertyHandler", szType);
}
}
}
}
RegCloseKey(hkeyExt);
}
// If we got a reg key, then there is an handler key, lookup the GUID and provide to the caller...
if (hkeyHandler)
{
CHAR szGUID[80];
DWORD cb = 80; szGUID[0] = '\0';
if ((RegQueryValue(hkeyHandler, NULL, szGUID, (LONG*)&cb) == ERROR_SUCCESS) && (cb))
{
BSTR bstrGuid = NonOLEConvertToBSTR(szGUID, CP_ACP);
if (bstrGuid)
{
hret = CLSIDFromString(bstrGuid, lpClsid);
SysFreeString(bstrGuid);
}
}
RegCloseKey(hkeyHandler);
}
CoTaskMemFree(pszExt);
return hret;
}
hi
|
|
|
|
|
i create an activex with Visual c++6(mfc) and called its property in a vc sample.
i add one new property to AxtiveX but when i run my sample get "invalid number of parameters" error message.
i didnt any change in old property and just add new property with class wizard but get this error.
please help me
|
|
|
|
|
Can you put a bit of code where the error is coming? I guess that if you didn't change anything but you add a new property it is maybe missing something when you call/create your control.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Nelek wrote: Can you put a bit of code where the error is coming?
DISP_PROPERTY_EX(CMyCtrl, "AutoChecking", GetAutoChecking, SetAutoChecking, VT_BOOL)
//=============================================
afx_msg void SetAutoChecking(BOOL bNewValue);
afx_msg BOOL GetAutoChecking();
//=============================================
void CMyCtrl::SetAutoChecking(BOOL bNewValue)
{
bAutoCheck = bNewValue;
SetModifiedFlag();
}
//=============================================
BOOL CMyCtrl::GetAutoChecking()
{
// TODO: Add your property handler here
return bAutoCheck;
}
//=============================================
dispidAutoChecking = 17L,
|
|
|
|
|
Change version of lib.
See MSDN[^] for more information.
Prasad
MS MVP - VC++
|
|
|
|
|
Is it possible for me to use GetControlUnkown() function of CWnd in a static library built with the option of not using MFC
Regards
|
|
|
|
|
Look in the MFC source code and see how it implements that function. MFC is, at its heart, a wrapper for the Win32 API.
Judy
|
|
|
|
|
I want to draw a calendar on desktop.
I use SPI_GETDESKWALLPAPER & SPI_SETDESKWALLPAPER to get & set the wallpaper. But I don't know how to create a bitmap with a specific path & how to copy a bitmap to another bitmap so that we can save the previous desktop. Until now, I just add bitmap to resource & use. So, I don't know how to do. S ome one plz help me ...
|
|
|
|
|
Take a look here[^]
Edit: Changed Link with more precise search
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
modified on Sunday, May 18, 2008 6:36 AM
|
|
|
|
|
If I can find, I won't ask you
|
|
|
|
|
capint wrote: If I can find, I won't ask you
If you don't say you have already searched we can not adivinate it.
By the way, in that results there are articles that use some things that you will need to make what you want. Just to explain all is a bit large to be done at once. Take a look on the articles, make tests and ask when you have problem in one section. You will easily get the help asking something concrete that you can't solve that something with so much information to be given as your first post.
capint wrote: how to copy a bitmap to another bitmap so that we can save the previous desktop
Take a look into the articles 2,3 and 4 of the search results I gave you. Make a screenshot can be more or less the same as getting the bitmap of the desktop.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hello everyone,
I need for my program to store some results (recordings) into a database and then to access or search that recordings from/in DB.
I searched on Msdn but didn't find a concrete example. Has anyone an explicit easy to understand example?
I need to store: file names, size, last time modified, if readonly and other things.
the program is something like:
int main( void )
{
struct _finddata_t c_file;
intptr_t hFile;
// Find first .c file in current directory
if( (hFile = _findfirst( "*.c", &c_file )) == -1L )
printf( "No *.c files in current directory!\n" );
else
{
printf( "Listing of .c files\n\n" );
printf( "RDO HID SYS ARC FILE DATE %25c SIZE\n", ' ' );
printf( "--- --- --- --- ---- ---- %25c ----\n", ' ' );
do {
char buffer[30];
printf( ( c_file.attrib & _A_RDONLY ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_SYSTEM ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_HIDDEN ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_ARCH ) ? " Y " : " N " );
ctime_s( buffer, _countof(buffer), &c_file.time_write );
printf( " %-12s %.24s %9ld\n", c_file.name, buffer, c_file.size );
} while( _findnext( hFile, &c_file ) == 0 );
_findclose( hFile );
}
}
Thanks very much!
|
|
|
|
|
All these examples and none of them come close to satisfying your request. Amazing.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
[DllImport("user32")] static int SendMessage(HWND^hwnd, int wMsg, int wParam, IntPtr^lParam);
How do I use this C# in C++?
|
|
|
|
|
|
I've been using XML to persist my data structures. But now as the amount of data I process and the small numbers of changes I make to the data...
Flushing it out as XML has become VERY TIME CONSUMING. At least it is in one 12MB file...
There must be a better way!
Any good alternatives out there?
- I would like to store "tree data" (maps within maps)
- I would like to have quick disk write for small changes...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Hi
Can I change the title and icon of a given dialog box at run time?
Thanx
|
|
|
|
|
About the icon... I am not sure, but the title can be done with SetWindowText .
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Nelek already answered about the title. For the icon try
SetClassLong(hWnd, GCL_HICON, (LONG) hNewHicon);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
But this is to be used once the dialog is already created and shown or by the creation? In a project I was changing icons as well but in the CChildFrm when creating the View, so with size and styles.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
CWnd::SetIcon()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Or you can use of WM_SETTEXT and WM_SETICON.
|
|
|
|
|
Hi ,
i coded a working treeview(SDI/Windows Explorer Style), but hardly without icons, there is shown only one icon in my treeview.
Pic :
http://filehosting.at/images/download.php?file=b14ad20aa1a01412004995061e3202bb
I want to show the original explorer icons in my treeview so i tried it with
SHGetFileInfo()
...but it won't work
Here is some sample code (i don't want to post too much):
1. This function detects the drives and labels :
void CLeftView::CreateRoots()
{
CString strMessage;
int nPos = 65;
CString strDrive;
TCHAR szLabel[128];
DWORD dwVolumeSerialNumber;
DWORD dwMaxNameLength;
DWORD dwFileSystemFlags;
TCHAR szFileSysName[128];
UINT uDriveType;
CString cstrWirDir;
TCHAR infoBuf[INFO_BUFFER_SIZE];
DWORD dwDriveList = GetLogicalDrives ();
GetWindowsDirectory(infoBuf, INFO_BUFFER_SIZE);
cstrWirDir = infoBuf;
cstrWirDir = cstrWirDir.GetAt(0);
cstrWirDir = cstrWirDir + ":";
while (dwDriveList)
{
if (dwDriveList & 1)
{
strDrive = "?:\\";
strDrive.SetAt (0,nPos);
uDriveType = GetDriveType(strDrive);
GetVolumeInformation (strDrive, szLabel,
sizeof( szLabel ) - 1,
&dwVolumeSerialNumber,
&dwMaxNameLength,
&dwFileSystemFlags,
szFileSysName,
sizeof( szFileSysName ) - 1);
switch(uDriveType)
{
case 2:
strDrive = strDrive.Left(2);
InsertFileItem("3½-Diskette (" + strDrive +")");
break;
case 3:
strDrive = strDrive.Left(2);
InsertFileItem((CString)szLabel + " (" + strDrive +")");
break;
case 5:
strDrive = strDrive.Left(2);
InsertFileItem((CString)szLabel + " (" + strDrive +")");
break;
default:
break;
}
}
dwDriveList >>= 1;
nPos++;
}
}
2. This function should build the tree with all the icons :
void CLeftView::InsertFileItem(const CString sFile)
{
CTreeCtrl &trCtrl = this->GetTreeCtrl();
trCtrl.SetImageList(&m_SysImageList.GetImageList(), TVSIL_NORMAL);
SHFILEINFO sfi;
SHGetFileInfo(sFile, 0, &sfi, sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
int nIconIndex;
nIconIndex = sfi.iIcon;
CString sTemp = sFile;
TV_INSERTSTRUCT tvis;
ZeroMemory(&tvis, sizeof(TV_INSERTSTRUCT));
tvis.hParent = TVI_ROOT;
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
tvis.item.pszText = sTemp.GetBuffer(sTemp.GetLength());
tvis.item.iImage = nIconIndex;
trCtrl.InsertItem(&tvis);
sTemp.ReleaseBuffer();
I don't know if it is enough code or not to detect my mistake so i uploaded a very small project (only the treeview with my code) here :
[url]http://www.filehosting.at/files/download.php?file=1cadb172342f4f83577c45e72addfc42[/url]
Thank you very much for your help
best regards
Cocodile Buck
|
|
|
|
|
CrocodileBuck wrote: SHGetFileInfo(sFile, 0, &sfi, sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
When you create the tree control, you need to call SHGetFileInfo with SHGFI_SYSICONINDEX | SHGFI_SMALLICON , and get the return value, which is a handle to the system image list. You then need to set your tree view's small icon image list to be the system image list. After that, your tree view should show the right icons. The code would be something like this:
HANDLE hSystemImageList = SHGetFileInfo(sKnownFile, 0, &sfi, sizeof(SHELLFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
trCtrl.SetImageList(CImageList::FromHandle(hSystemImageList), TVSIL_NORMAL);
Nathan
|
|
|
|
|