how to implement the IShellFolder::CompareIDs for column click

how to implement the IShellFolder::CompareIDs for column click

Post by S. Yan » Sun, 25 Aug 2002 09:28:17


hi,

  Now I am implementing the IShellFolder::CompareIDs function for column
click, because I used the SHCreateShellFolderViewEx to create the view
object, so the detail requirement of the CompareIDs is unknownm, the outline
of the code is listed as follows, but it does not work correctly. For
example, when I click the second column four times, the shell view sort
correctly two times and sort by the first column two times, so it seems to
be a periodic behaviour of four. Why? From the debug trace informatino, I
found when second column is clicked every time, the view object not only
query the second column compare result(lParam = 0x00000001), but also query
the first column(lParam = 0x00000000). My operating system is windows 2000.

  IShellDetails::ColumnClick: return S_FALSE;

  IShellFolder::CompareIDs:
    step1: uColumn = lParam & SHCIDS_COLUMNMASK.
    step2: using the IShellFolder2::MapColumnToSCID and
IShellFolder2::GetDetailsEx to get the value of the pidl1 and pidl2. In this
step, a condition of one level id list is assumed, or it will just return
E_NOTIMPL)
    step3: using the VarCmp to compare the value.

  IShellFolder2::GetDefaultColumnState: SHCOLSTATE_TYPE_STR |
SHCOLSTATE_ONBYDEFAULT.

Thanks.

Shengtian Yang

 
 
 

how to implement the IShellFolder::CompareIDs for column click

Post by Henk Devo » Sun, 25 Aug 2002 20:12:42


Your CompareIDs must be wrong.
Most likely you return -1 instead of a hresult with -1 as the scode
(0xFFFFFFFF instead of 0x0000FFFF).

Henk Devos
http://www.whirlingdervishes.com


Quote:> hi,

>   Now I am implementing the IShellFolder::CompareIDs function for column
> click, because I used the SHCreateShellFolderViewEx to create the view
> object, so the detail requirement of the CompareIDs is unknownm, the
outline
> of the code is listed as follows, but it does not work correctly. For
> example, when I click the second column four times, the shell view sort
> correctly two times and sort by the first column two times, so it seems to
> be a periodic behaviour of four. Why? From the debug trace informatino, I
> found when second column is clicked every time, the view object not only
> query the second column compare result(lParam = 0x00000001), but also
query
> the first column(lParam = 0x00000000). My operating system is windows
2000.

>   IShellDetails::ColumnClick: return S_FALSE;

>   IShellFolder::CompareIDs:
>     step1: uColumn = lParam & SHCIDS_COLUMNMASK.
>     step2: using the IShellFolder2::MapColumnToSCID and
> IShellFolder2::GetDetailsEx to get the value of the pidl1 and pidl2. In
this
> step, a condition of one level id list is assumed, or it will just return
> E_NOTIMPL)
>     step3: using the VarCmp to compare the value.

>   IShellFolder2::GetDefaultColumnState: SHCOLSTATE_TYPE_STR |
> SHCOLSTATE_ONBYDEFAULT.

> Thanks.

> Shengtian Yang


 
 
 

how to implement the IShellFolder::CompareIDs for column click

Post by S. Yan » Sun, 25 Aug 2002 20:52:22



> Your CompareIDs must be wrong.
> Most likely you return -1 instead of a hresult with -1 as the scode
> (0xFFFFFFFF instead of 0x0000FFFF).

Thanks, Henk.

But my return code is correct, the code is:

// sResult is the compare value.
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, sResult);

Shengtian Yang

 
 
 

how to implement the IShellFolder::CompareIDs for column click

Post by Henk Devo » Sun, 25 Aug 2002 22:05:10


It is certainly a problem in your CompareIDs.
Check the code again.



> > Your CompareIDs must be wrong.
> > Most likely you return -1 instead of a hresult with -1 as the scode
> > (0xFFFFFFFF instead of 0x0000FFFF).

> Thanks, Henk.

> But my return code is correct, the code is:

> // sResult is the compare value.
> return MAKE_HRESULT(SEVERITY_SUCCESS, 0, sResult);

> Shengtian Yang

 
 
 

how to implement the IShellFolder::CompareIDs for column click

Post by S. Yan » Mon, 26 Aug 2002 14:30:04



> It is certainly a problem in your CompareIDs.
> Check the code again.

Thanks a lot, Henk.

You are right, the mistake is just the return value.

The following code which is copied from msdn document is not correct.
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, sResult);

because the type of sResult is SHORT,
so if sResult = -1, then
(unsigned long)(SHORT)sResult = 0xffffffff;

I modified the code as follows
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (USHORT)sResult);

then all mistakes disappears.

Shengtian Yang

 
 
 

how to implement the IShellFolder::CompareIDs for column click

Post by Maksym Schipk » Wed, 28 Aug 2002 21:26:28


Yes, I confirm that the code from MSDN documentation is incorrect - I myself
faced with the same problem several weeks ago. Now my code logs all return
values from all important functions... :)

--
Best regards,
  Maksym Schipka
  Senior Software Developer
  Invisimail IOM Ltd



> > It is certainly a problem in your CompareIDs.
> > Check the code again.

> Thanks a lot, Henk.

> You are right, the mistake is just the return value.

> The following code which is copied from msdn document is not correct.
> return MAKE_HRESULT(SEVERITY_SUCCESS, 0, sResult);

> because the type of sResult is SHORT,
> so if sResult = -1, then
> (unsigned long)(SHORT)sResult = 0xffffffff;

> I modified the code as follows
> return MAKE_HRESULT(SEVERITY_SUCCESS, 0, (USHORT)sResult);

> then all mistakes disappears.

> Shengtian Yang