default folder view

default folder view

Post by Olivie » Mon, 30 Jun 2003 23:11:45



Hi,

I'm new to shell programming (to Windows programming in general) and I'd
like to change the default folder view in Windows explorer (small icons,
always).
As when I click Tools / Folder Options / View tab / "Like Current Folder"
after setting "small icons" view.

I've created, using VC++ 7.0, a console application, and succeeded calling
SHGetDesktopFolder to get an IShellFolder object.

Then I use ParseDisplayName to get a LPITEMIDLIST object.
(I found this on MSDN but I'm not sure it is the simplest way to
proceed...)

Anyway, when I try to use SHCreateShellFolderView function, it does not
compile (undeclared identifier on this keyword).

MSDN at http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/shellcc/platform/shell/reference/functions/shcreateshellfolderview.asp
say that it requires shlobj.h, which is correctly included, else it would
not find SHGetDesktopFolder either.

What could be the problem? As I said above I'm new to Windows programming
so I don't know where to search...

Besides solving this problem, if anyone knows a simpler way to do what I'd
like to do, don't hesitate to point me to the right direction!

Sorry for my English,
Thank you for your answer.
Olivier

 
 
 

default folder view

Post by Henk Devo » Tue, 01 Jul 2003 04:00:49


What you are trying to do sounds simple, but is really very difficult.
You are certainly not going the right way.
The function you should be calling is SHGetSetSettings.
If this function is also undefined, this is because you don't have the
latest Platform SDK.
After that, you have to notify all views that something has changed, and
that is the big problem.
You can use this function:

void Cabinet_RefreshAll()
{
 HWND hWndProgMan = ::FindWindow("ProgMan", NULL);
 if (hWndProgMan)
 {
  ::PostMessage(hWndProgMan, 0x111, 0xA220, 0);
 }
 HWND hWndTray = ::FindWindow("Shell_TrayWnd", NULL);
 if (hWndTray)
 {
  ::PostMessage(hWndProgMan, 0x561, 0, 0);
 }
 EnumWindows(Enum_CabinetRefresh, 0);

Quote:}

It uses the following functions:

BOOL IsExplorerWindow(HWND hWnd)
{
 char buffer[256];
 ::GetClassName(hWnd, buffer, 256);
 return strcmp(buffer, "ExploreWClass") == 0;

Quote:}

BOOL IsFolderWindow(HWND hWnd)
{
 char buffer[256];
 ::GetClassName(hWnd, buffer, 256);
 return (strcmp(buffer, "CabinetWClass") == 0) ||
     (strcmp(buffer, "IEFrame") == 0);

Quote:}

BOOL CALLBACK Enum_CabinetRefresh(HWND hWnd, LPARAM lParam)
{
 if (IsFolderWindow(hWnd) || IsExplorerWindow(hWnd))
 {
  ::PostMessage(hWnd, 0x111, 0xA220, 0);
 }
 return TRUE;

Quote:}

Before calling the function i provided, call the following functions:

  SHSettingsChanged(0, 0);
  ::PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"ShellState");

When doing all of this, some of the windows might be refreshed, but you
don't get any guarantee that it works completely.

Henk Devos
http://www.whirlingdervishes.com


Quote:> Hi,

> I'm new to shell programming (to Windows programming in general) and I'd
> like to change the default folder view in Windows explorer (small icons,
> always).
> As when I click Tools / Folder Options / View tab / "Like Current Folder"
> after setting "small icons" view.

> I've created, using VC++ 7.0, a console application, and succeeded calling
> SHGetDesktopFolder to get an IShellFolder object.

> Then I use ParseDisplayName to get a LPITEMIDLIST object.
> (I found this on MSDN but I'm not sure it is the simplest way to
> proceed...)

> Anyway, when I try to use SHCreateShellFolderView function, it does not
> compile (undeclared identifier on this keyword).

> MSDN at http://msdn.microsoft.com/library/default.asp?url=/library/en-
> us/shellcc/platform/shell/reference/functions/shcreateshellfolderview.asp
> say that it requires shlobj.h, which is correctly included, else it would
> not find SHGetDesktopFolder either.

> What could be the problem? As I said above I'm new to Windows programming
> so I don't know where to search...

> Besides solving this problem, if anyone knows a simpler way to do what I'd
> like to do, don't hesitate to point me to the right direction!

> Sorry for my English,
> Thank you for your answer.
> Olivier


 
 
 

default folder view

Post by Axel Sommerfeld » Wed, 02 Jul 2003 00:54:39



> Anyway, when I try to use SHCreateShellFolderView function, it does
> not compile (undeclared identifier on this keyword).

You need the Platform SDK November 2002 or newer.

Regards,
Axel

 
 
 

default folder view

Post by Olivie » Fri, 04 Jul 2003 19:47:04




Quote:> What you are trying to do sounds simple, but is really very difficult.

Then, especially thank you for your reply!

Quote:> You are certainly not going the right way.
> The function you should be calling is SHGetSetSettings.

It seems like this function can only change options like "show hidden
folders" and so on, those with check boxes in the interface.
I don't think it can be used to show small icons for example.

Quote:> If this function is also undefined, this is because you don't have the
> latest Platform SDK.

That's what I thought but I installed Core SDK from MS website, updated
Feb 2003, and in the help of the SDK I see SHGetViewStatePropertyBag. But  
in Visual Studio it doesn't use the new version I think, because it can't
find SHGetViewStatePropertyBag in the help (nore when it compiles),
although it sees SHGetDesktopFolder for example.

Creating a new project yields the same results.

Quote:> After that, you have to notify all views that something has changed,
> and that is the big problem.

I think we misunderstood: I don't want to refresh the current views  (I
admit it wasn't very clear in my first post). I don't even mind if I must
reboot the computer for the changes to take effect.
I'd like to change the default view, that is, tell Windows that each time  
I open a new folder (one for which it has not stored any special view
property yet), it should show small icons.

As when I click "Like Current Folder" in Tools / Folder Options.

Or did I misunderstood your point?

> Henk Devos
> http://www.whirlingdervishes.com



>> Hi,

>> I'm new to shell programming (to Windows programming in general) and
>> I'd like to change the default folder view in Windows explorer (small
>> icons, always).
>> As when I click Tools / Folder Options / View tab / "Like Current
>> Folder" after setting "small icons" view.

>> I've created, using VC++ 7.0, a console application, and succeeded
>> calling SHGetDesktopFolder to get an IShellFolder object.

>> Then I use ParseDisplayName to get a LPITEMIDLIST object.
>> (I found this on MSDN but I'm not sure it is the simplest way to
>> proceed...)
(...)
>> Besides solving this problem, if anyone knows a simpler way to do
>> what I'd like to do, don't hesitate to point me to the right
>> direction!

>> Sorry for my English,
>> Thank you for your answer.
>> Olivier

 
 
 

1. How to set the default view for a namespace extension folder?

Hi all,

Just a simple (I hope) question that I can't seem to find
an answer to. I have a shell extension (which uses
SHCreateShellFolderView, in case that matters) which is
acting as a "virtual drive". I have also implemented the
ICategorizer/ICategoryProvider interfaces to group the
folders/files based on certain criteria, and everything is
working great. But I would like to set the folder view so
that it defaults to the "Detail" view with the grouping
turned on. But I don't understand how to do this. Can
anyone tell me? I guess it's really 2 questions: 1) how to
get the default folder view to be "detail" view, and 2)
how to force the grouping/categorization to be "on".

Thanks!
Phil

2. What media for audio?

3. Default View vs Web View

4. Task bar won't come out of hiding!

5. Vuescan Default folder

6. CD Label Question?

7. Vuescan : default folder problems.

8. Cable modem sharing problem

9. VueScan X 7.3.5 - Default Folder

10. How can I change the default folder Visio uses when I open documents?

11. Creating new folder window with default pane settings

12. How to change the folder's default icon?

13. restoring original default folders