Click here to Skip to main content
15,913,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir14-Nov-05 2:38
YaronNir14-Nov-05 2:38 
General[Message Deleted] Pin
David Crow14-Nov-05 2:45
David Crow14-Nov-05 2:45 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir14-Nov-05 2:45
YaronNir14-Nov-05 2:45 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
David Crow14-Nov-05 3:00
David Crow14-Nov-05 3:00 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir14-Nov-05 3:02
YaronNir14-Nov-05 3:02 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
David Crow14-Nov-05 3:06
David Crow14-Nov-05 3:06 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir14-Nov-05 3:13
YaronNir14-Nov-05 3:13 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
David Crow14-Nov-05 6:30
David Crow14-Nov-05 6:30 
Had it been anything other than explorer.exe, the answer would have only been five minutes away. However, explorer.exe is different in that it doesn't, by default, start a new application each time. It gets its own thread but within an already existing process. To work around this, a registry change was required. Create the following DWORD key:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"DesktopProcess"=dword:00000001


This code will now open Windows Explorer in 'filmstrip' view:

HWND _hWnd = NULL;
 
BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam )
{
    DWORD dwProcessId;
 
    GetWindowThreadProcessId(hWnd, &dwProcessId);
 
    if ((DWORD) lParam == dwProcessId)
    {
        char szText[256];
        if (::GetWindowText(hWnd, szText, sizeof(szText)) > 0) // this check may not be necessary
        {
            char szClass[256];
            GetClassName(hWnd, szClass, sizeof(szClass));
            if (lstrcmp(szClass, "CabinetWClass") == 0)
            {
                _hWnd = hWnd;
                return FALSE;
            }
        }
    }
 
    return TRUE;
}
...
DWORD dwError;
BOOL bResult;
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
 
si.cb = sizeof(si);
 
bResult = CreateProcess(NULL,
                            "c:\\windows\\explorer.exe \"C:\\Documents and Settings\\<user>\\My Documents\\My Pictures\\<folder>\"",
                            NULL,
                            NULL,
                            TRUE,
                            NORMAL_PRIORITY_CLASS,
                            NULL,
                            NULL,
                            &si,
                            &pi);
 
if (! bResult)
    dwError = GetLastError();
 
WaitForInputIdle(pi.hProcess, 3000);
 
EnumWindows(EnumProc, pi.dwProcessId);
 
HWND hWnd = FindWindowEx(_hWnd, NULL, "SHELLDLL_DefView", "");
if (hWnd != NULL)
    ::SendMessage(hWnd, WM_COMMAND, 0x702f, 0);
Obviously this solution has a few shortcomings but I think you get the general idea. I think that FindWindow() can also be used to find the "CabinetWClass" window.


"Take only what you need and leave the land as you found it." - Native American Proverb


GeneralRe: launching windows exploere in 'Film Strip' mode Pin
Sheng Jiang 蒋晟14-Nov-05 19:22
Sheng Jiang 蒋晟14-Nov-05 19:22 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir14-Nov-05 21:50
YaronNir14-Nov-05 21:50 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
David Crow15-Nov-05 3:25
David Crow15-Nov-05 3:25 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir15-Nov-05 5:24
YaronNir15-Nov-05 5:24 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
Sheng Jiang 蒋晟15-Nov-05 8:08
Sheng Jiang 蒋晟15-Nov-05 8:08 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir15-Nov-05 22:12
YaronNir15-Nov-05 22:12 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
Sheng Jiang 蒋晟16-Nov-05 4:18
Sheng Jiang 蒋晟16-Nov-05 4:18 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir14-Nov-05 21:42
YaronNir14-Nov-05 21:42 
QuestionRe: launching windows exploere in 'Film Strip' mode Pin
David Crow15-Nov-05 2:54
David Crow15-Nov-05 2:54 
AnswerRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir15-Nov-05 3:11
YaronNir15-Nov-05 3:11 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
David Crow15-Nov-05 3:28
David Crow15-Nov-05 3:28 
GeneralRe: launching windows exploere in 'Film Strip' mode Pin
YaronNir16-Nov-05 0:17
YaronNir16-Nov-05 0:17 
QuestionCrash in my program when the screensaver is running Pin
André RB14-Nov-05 0:59
André RB14-Nov-05 0:59 
AnswerRe: Crash in my program when the screensaver is running Pin
ThatsAlok14-Nov-05 1:15
ThatsAlok14-Nov-05 1:15 
GeneralRe: Crash in my program when the screensaver is running Pin
André RB14-Nov-05 4:25
André RB14-Nov-05 4:25 
GeneralRe: Crash in my program when the screensaver is running Pin
normanS14-Nov-05 18:22
normanS14-Nov-05 18:22 
GeneralRe: Crash in my program when the screensaver is running Pin
André RB15-Nov-05 23:38
André RB15-Nov-05 23:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.