|
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
|
|
|
|
|
Hi Nathan ,
thanx for your quick reply.
But when I try your 2 lines of code it won't work.
There will not be any error message, there are simply no icons in the tree !
My coding skills aren't as good as yours!
Perhaps, if it is not too much effort you could have a closer look to my code which i have uploaded and implement the code how and where it has to be?
I really tried it to build up this view for 2 day's, i'm not too lazy i simply couldn't get it to work
Please help me
Thank and best regards
Crocodile Buck
|
|
|
|
|
Lazy reply:
Go check my article on detecting drives - it has code for showing drive icons, etc.
And read the comments, where most of that information came from.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Hi Mr. Clarke,
i know your article, and it is very good.
I can show the drive letters and the lablels that's not the problem. I know how to detect the drives etc.
The Problem is that i couldn't show the system icons.
I think there is something wrong with my SytemImageList , i think there are not enough icons in it, or not the right icons !
Perhaps if you have a look at the small sample i have uploaded, it will take you only seconds to detect and terminate the mistake!
Thanx for your quick reply
best regards
Crocodile Buck
|
|
|
|
|
I solved the Problem
Best regards
Crocodile Buck
|
|
|
|
|
CrocodileBuck wrote: I solved the Problem
Glad to hear it - I was just going through my emails, and had some spare time so was going to attack your code.
What was the solution in the end?
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I have this in C#
[DllImport("user32")]
public static extern int SendMessage(HWND hwnd, int wMsg, int wParam, IntPtr lParam);
and I dont know what is its equivalent in C++.
|
|
|
|
|
It's simple to use on the c++ dont need to load any dll file or library file.
LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam );
|
|
|
|
|
it shows me an error in 'UINT' do i have to specify something else before this code?
|
|
|
|
|
How did you use it? can you show your code?
|
|
|
|
|
public ref class Win32{
private: Win32() { }
public:
literal int WM_USER = 0x400;
literal int WM_PAINT = 0xF;
literal int WM_KEYDOWN = 0x100;
literal int WM_KEYUP = 0x101;
literal int WM_CHAR = 0x102;
literal int EM_GETSCROLLPOS = (WM_USER + 221);
literal int EM_SETSCROLLPOS = (WM_USER + 222);
literal int VK_CONTROL = 0x11;
literal int VK_UP = 0x26;
literal int VK_DOWN = 0x28;
literal int VK_NUMLOCK = 0x90;
literal short KS_ON = 0x01;
literal short KS_KEYDOWN = 0x80;
[StructLayout(LayoutKind::Sequential)]
ref struct POINT
{ public: int x, y;}
LRESULT SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
};
|
|
|
|
|
If you just want to call the win32 API in C++, you don't need all that garbage stuff.
The symbols for windows messages are in header files that you just include and to call SendMessage() you just do something like this...
::SendMessage(hWnd,WM_SOMEMESSAGE,wParam,lParam);
|
|
|
|
|
letueros wrote: LRESULT SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); //This is what you told me
Yeah thats right.I think this little code is helpful for you and also for some messages you dont need to declare them like WM_PAINT/WM_KEYDOWN,...
class win32
{
public:
win32()
{
}
void Changecaption(HWND hwnd,UINT m_Message);
};
void win32::Changecaption(HWND hwnd,UINT m_Message)
{
SendMessageW(hwnd,m_Message,0,(WPARAM)_T("Hi how are you"));
}
win32 m_cTest;
m_cTest.Changecaption(m_hWnd,WM_SETTEXT);
|
|
|
|
|
C++ is different with C# some things are easy and some things are difficult to use.
|
|
|
|
|
Hamid. wrote: C++ is different with C# some things are easy and some things are difficult to use.
off course! i am still learning it
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Really what did you learn ?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi all,
How can I force the user to select only via dropdown, but not allowing him to edit in combobox?
Thanks,
Sunil.
Regards,
Sunil Kumar
|
|
|
|
|
Change the combobox style to CBS_DROPDOWNLIST [^]. You can change this in the resource editor. Look at the properties pane, and change the style selection.
|
|
|
|
|
open combo box properties and change style type to DropList
|
|
|
|
|
Thanks a lot,
The problem is solved.
Regards,
Sunil Kumar
|
|
|
|
|
I am trying to read the summary property of docx file, i used the following code but get HRESULT S_FALSE while reading ReadMultiple.
Here is the code:
#include <stdio.h>
#include <windows.h>
#include <ole2.h>
#include <locale.h>
// Dumps simple PROPVARIANT values.
void DumpPropVariant(PROPVARIANT *pPropVar) {
// Don't iterate arrays, just inform as an array.
if(pPropVar->vt & VT_ARRAY)
{
printf("(Array)\n");
return;
}
// Don't handle byref for simplicity, just inform byref.
if(pPropVar->vt & VT_BYREF)
{
printf("(ByRef)\n");
return;
}
// Switch types.
switch(pPropVar->vt) {
case VT_EMPTY:
printf("(VT_EMPTY)\n");
break;
case VT_NULL:
printf("(VT_NULL)\n");
break;
case VT_BLOB:
printf("(VT_BLOB)\n");
break;
case VT_BOOL:
printf("%s (VT_BOOL)\n",
pPropVar->boolVal ? "TRUE/YES" : "FALSE/NO");
break;
case VT_I2: // 2-byte signed int.
printf("%d (VT_I2)\n", (int)pPropVar->iVal);
break;
case VT_I4: // 4-byte signed int.
printf("%d (VT_I4)\n", (int)pPropVar->lVal);
break;
case VT_R4: // 4-byte real.
printf("%.2lf (VT_R4)\n", (double)pPropVar->fltVal);
break;
case VT_R8: // 8-byte real.
printf("%.2lf (VT_R8)\n", (double)pPropVar->dblVal);
break;
case VT_BSTR: // OLE Automation string.
{
// Translate into ASCII.
char dbcs[1024];
char *pbstr = (char *)pPropVar->bstrVal;
int i = wcstombs(
dbcs, pPropVar->bstrVal, *((DWORD *)(pbstr-4)));
dbcs[i] = 0;
printf("%s (VT_BSTR)\n", dbcs);
}
break;
case VT_LPSTR: // Null-terminated string.
{
printf("%s (VT_LPSTR)\n", pPropVar->pszVal);
}
break;
case VT_FILETIME:
{
char *dayPre[] =
{"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
FILETIME lft;
FileTimeToLocalFileTime(&pPropVar->filetime, &lft); SYSTEMTIME lst;
FileTimeToSystemTime(&lft, &lst);
printf("%02d:%02d.%02d %s, %s %02d/%02d/%d (VT_FILETIME)\n",
1+(lst.wHour-1)%12, lst.wMinute, lst.wSecond,
(lst.wHour>=12) ? "pm" : "am",
dayPre[lst.wDayOfWeek%7],
lst.wMonth, lst.wDay, lst.wYear);
}
break;
case VT_CF: // Clipboard format.
printf("(Clipboard format)\n");
break;
default: // Unhandled type, consult wtypes.h's VARENUM structure.
printf("(Unhandled type: 0x%08lx)\n", pPropVar->vt);
break;
}
}
// Dump's built-in properties of a property storage.
void DumpBuiltInProps(IPropertySetStorage *pPropSetStg) {
printf("\n==================================================\n");
printf("BuiltInProperties Properties...\n");
printf("==================================================\n");
IPropertyStorage *pPropStg = NULL;
HRESULT hr;
PROPVARIANT propRead;
HRESULT Enum(IEnumSTATPROPSETSTG** PropEnum);
// Open summary information, getting an IpropertyStorage.
hr = pPropSetStg->Open(FMTID_SummaryInformation,
STGM_READ | STGM_SHARE_EXCLUSIVE, &pPropStg);
if(FAILED(hr))
{
printf("No Summary-Information.\n");
return;
}
// Array of PIDSI's you are interested in.
struct pidsiStruct {
char *name;
long pidsi;
} pidsiArr[] = {
{"Title", PIDSI_TITLE}, // VT_LPSTR
{"Subject", PIDSI_SUBJECT}, // ...
{"Author", PIDSI_AUTHOR},
{"Keywords", PIDSI_KEYWORDS},
{"Comments", PIDSI_COMMENTS},
{"Template", PIDSI_TEMPLATE},
{"LastAuthor", PIDSI_LASTAUTHOR},
{"Revision Number", PIDSI_REVNUMBER},
{"Edit Time", PIDSI_EDITTIME}, // VT_FILENAME (UTC)
{"Last printed", PIDSI_LASTPRINTED}, // ...
{"Created", PIDSI_CREATE_DTM},
{"Last Saved", PIDSI_LASTSAVE_DTM},
{"Page Count", PIDSI_PAGECOUNT}, // VT_I4
{"Word Count", PIDSI_WORDCOUNT}, // ...
{"Char Count", PIDSI_CHARCOUNT},
{"Thumpnail", PIDSI_THUMBNAIL}, // VT_CF
{"AppName", PIDSI_APPNAME}, // VT_LPSTR
{"Doc Security", PIDSI_DOC_SECURITY}, // VT_I4
{0, 0}
};
// Count elements in pidsiArr.
int nPidsi = 0;
for(nPidsi=0; pidsiArr[nPidsi].name; nPidsi++);
// Initialize PROPSPEC for the properties you want.
PROPSPEC *pPropSpec = new PROPSPEC [nPidsi];
PROPVARIANT *pPropVar = new PROPVARIANT [nPidsi];
for(int i=0; i<npidsi; i++)="">
{
ZeroMemory(&pPropSpec[i], sizeof(PROPSPEC));
pPropSpec[i].ulKind = PRSPEC_PROPID;
pPropSpec[i].propid = pidsiArr[i].pidsi;
}
// Read properties.
hr = pPropStg->ReadMultiple(nPidsi, pPropSpec, pPropVar);
if(FAILED(hr)) // HERE I GOT hr = S_FALSE
{
printf("IPropertyStg::ReadMultiple() failed w/error %08lx\n", hr);
}
else
{
int i;
// Dump properties.
for(i=0; i<npidsi; i++)="">
{
printf("%16s: ", pidsiArr[i].name);
DumpPropVariant(pPropVar + i);
}
}
// De-allocate memory.
delete [] pPropVar;
delete [] pPropSpec;
// Release obtained interface.
pPropStg->Release();
}
// Dump's custom and built-in properties of a compound document.
void DumpProps(char *filename) {
// Translate filename to Unicode.
WCHAR wcFilename[1024];
setlocale( LC_ALL, "" );
int i = mbstowcs(wcFilename, filename, strlen(filename));
setlocale( LC_ALL, "C" );
wcFilename[i] = 0;
IPropertySetStorage *pPropSetStg = NULL;
HRESULT hr;
hr = ::StgOpenStorageEx(wcFilename, STGM_READ | STGM_SHARE_EXCLUSIVE, STGFMT_ANY,
0, NULL, NULL, IID_IPropertySetStorage, (void**)&pPropSetStg);
if(FAILED(hr))
{
printf("QI for IPropertySetStorage failed w/error %08lx", hr);
pStorage->Release();
return;
}
// Dump properties.
DumpBuiltInProps(pPropSetStg);
// Release obtained interfaces.
pPropSetStg->Release();
}
// Program entry-point.
void main(int argc, char **argv) {
char *s;
DumpProps("1.docx");
scanf("%s",&s);
}
|
|
|
|
|
If you want someone to even try to look at your code, read the posting guidelines at the top of the forum, They're there for a good reason.
Hint: pre tag.
Also, choosing an actual name, rather than a number helps.
Lastly, a bit more of a question please! What have you tried? Etc. Have you looked for CP articles that may help? Examples on MSDN? etc.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
I need to write a console application which would get me the list of users in a particular system and their corresponding user account privilege (Administrator, Guest, User, etc.). How could I do this ?
Thanks in advance.
|
|
|
|
|
See GetUserNameEx and LookupAccountName .
|
|
|
|
|
Hi all,
i want to know how can i use Enter key in TreeCtrl?
i want to use this same as LButtonDown function.
i m using Lbuttondown like this.
void CMyTree::OnLButtonDown(UINT nFlags, CPoint point)
{
CTreeView::OnLButtonDown(nFlags, point);
CTreeCtrl& tc = GetTreeCtrl();
UINT uFlags = 0;
HTREEITEM hItem = tc.HitTest(point, &uFlags);
if(!hItem)
return;
tc.SelectItem(hItem);
tc.SetFocus();
CString Previous_File;
CString Tree_str = tc.GetItemText(hItem);
CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd();
if (Tree_str==_T("Str"))
{
AfxMessageBox(Tree_str);
}
please anybody can tell me how can i do this.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|