Click here to Skip to main content
Licence 
First Posted 7 Sep 2006
Views 45,820
Downloads 925
Bookmarked 47 times

Windows Magics - Grid-lined Explorer Windows

Change the way your Explorer windows present their contents.
3 votes, 15.0%
1
2 votes, 10.0%
2
1 vote, 5.0%
3
4 votes, 20.0%
4
10 votes, 50.0%
5
3.54/5 - 20 votes
μ 3.54, σa 2.70 [?]

Sample Image - GridExplorers.jpg

Overview

This article demonstrates how we can change system windows' properties, styles, etc. using Windows core functions. For example, take a scenario - whenever we open the Explorer windows in Details view, we want to enable grid lines as you see in the above screenshot.

WNDCLASS background

If you have a background knowledge of the platform Windows API and its functionalities, then you know very well that every window we create or the system creates are child windows to the desktop window. Every window has some styles and properties (please refer to the WNDCLASS structure) associated with it. So by changing these properties or styles, we can achieve our desired look and feel and behaviors. By altering these properties, we can play around even with the system windows such as Explorer windows.

How to identify Explorer windows programmatically?

Whenever we start a Windows Explorer instance, it creates a parent window, and its class name (of WNDCLASS structure) would be ExploreWClass. We can use a Windows API named EnumWindows() to enumerate all top level windows. This API will give us each window handle, one by one. Then, we can use the GetClassName() API to get the class name. If the class name is ExploreWClass, then we can conclude that this window is an Explorer instance, as shown below:

// To enumerate all top level windows
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{

      //Get the class name of the current window
      //Truncates if the class name is more 
      //than 15 (don't want more than 15)
      CHAR lpClassName[15];
      GetClassName(hwnd, lpClassName, 15); 

      //If the class name is "ExploreWClass" 
      //then this window is Explorer's main window
      //Then, reterive all its child windows
      if(strcmp(lpClassName, "ExploreWClass") == 0)
            EnumChildWindows(hwnd, EnumChildWindowsProc, lParam);

      //Continue the Enumeration for all top level windows
      return TRUE;
}

How to identify the DetailView windows of Explorer windows?

Once we get the Explorer window handle, we can use the API EnumChildWindows() in order to get all the child window handles. The Explorer program uses the common control listview for its right pan. As like above, we can check the class name of all the child windows. If it matches with SysListView32, then it is a window that we are looking for.

Change the window's style

As you know about the Windows architecture, all communication between Windows and processes occur using messages. So simply send a message to the target window to add the grid lines style, as you see in the code snippet below:

//To enumerate the explorer windows's child windows
BOOL CALLBACK EnumChildWindowsProc(HWND hwnd, LPARAM lParam)
{
    //Get the class name of the current window
    CHAR lpClassName[15];
    //Truncates if the class name is more than 15
    GetClassName(hwnd, lpClassName, 15);

    //If the class name is "SysListView32" 
    //then this window is we are looking for
    if(strcmp(lpClassName, "SysListView32") == 0)
    {
        //First, get the current style
        LRESULT style = SendMessage(hwnd, (UINT) 
                        LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);

        //Apply only if the grid lines not set
    if((style & LVS_EX_GRIDLINES) == 0)
    {
        
            // append the gridlines style
            style |= LVS_EX_GRIDLINES;
            SendMessage(hwnd, (UINT) LVM_SETEXTENDEDLISTVIEWSTYLE, 0, style);
        }
     }

    //Continue the Enumeration for all its child windows
    return TRUE;
}

Conclusion

Hope you enjoyed playing with the system classes. In this way, you can change system windows, and application styles and behaviors. You can simply execute and place this EXE in the Startup, and enjoy the gridlines style until the future versions of Windows give an option to enable this in the display settings.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Venkatakarthikeyan Natarajamoorthy

Software Developer (Senior)

United States United States

Member
Venkat Nataraj works as a Technical Consultant for GE Healthcare, USA. Earlier, he worked as a Software Tech Lead for Dell Inc, System Analyst for Satyam Computer Services and Software Engineering Consultant for GE Power Systems, Bently Nevada. He is an MCSD.NET early achiever. He has been working in the last 11+ years in software design and development of leading-edge business solutions with various development tools, technologies, platforms, and architectures. Here is the latest certifications by him:
 
• General Electric (GE) Certified GE Green Belt in Six Sigma
• Microsoft Certified Professional (MCP)
• Microsoft Certified Application Developer for Microsoft .NET (MCAD.NET)
• Microsoft Certified Solution Developer for Microsoft .NET (MCSD.NET)
• MCSD.NET Early achiever
• Brainbench Certified Visual C++ programmer
• Computer Society of India (CSI) awarded first place in the inter-college Computer Quiz Competition
• Computer Society of India (CSI) awarded first place in the inter-college Software Contest
• Received “Process Innovation” award from Dell Inc
 
He spends his free time with music, watching hollywood movies and Sujatha's stories. His favorite musician is Ilayaraja. Bringing real music to his soul and heart. Hariharan is his most favorite singer.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionFull row selection PinmemberSoham Dasgupta1:33 1 Sep '11  
QuestionGrid-lined Explorer Windows + hilite? PinmemberKurt@K-K-Kanada21:50 15 Sep '10  
QuestionPossible as Profile's Explorer Default? Pinmemberbarryc_mailbox7:40 28 Jan '09  
AnswerRe: Possible as Profile's Explorer Default? Pinmemberbarryc_mailbox7:53 28 Jan '09  
GeneralNice job, makes you think... PinmemberAlexEvans20:39 27 Sep '06  
GeneralThis is no magic! [modified] PinmemberSoftS9:42 17 Sep '06  
GeneralRe: This is no magic! PinmemberVenkatakarthikeyan Natarajamoorthy1:23 18 Sep '06  
QuestionAchieve the same effect with registry? Pinmembertkdmaster14:17 14 Sep '06  
AnswerRe: Achieve the same effect with registry? PinmemberVenkatakarthikeyan Natarajamoorthy1:30 18 Sep '06  
GeneralExceptionally Impressed with your Name Pinmemberkackermann4:49 12 Sep '06  
GeneralRe: Exceptionally Impressed with your Name PinmemberDieter Hammer21:01 14 Sep '06  
JokeRe: Exceptionally Impressed with your Name PinmemberRalph Wetzel11:27 15 Sep '06  
GeneralRe: Exceptionally Impressed with your Name PinmemberDieter Hammer21:01 18 Sep '06  
GeneralNice feature... PinmemberHogfather3:50 12 Sep '06  
GeneralNice, but only for real Explorer Windows ... PinmemberMartin08150:32 8 Sep '06  
GeneralRe: Nice, but only for real Explorer Windows ... PinmemberVenkatakarthikeyan Natarajamoorthy0:38 8 Sep '06  
GeneralRe: Nice, but only for real Explorer Windows ... PinmemberMartin08151:08 8 Sep '06  
GeneralRe: Nice, but only for real Explorer Windows ... PinmemberVenkatakarthikeyan Natarajamoorthy1:31 8 Sep '06  
GeneralRe: Nice, but only for real Explorer Windows ... PinmemberMartin08151:44 8 Sep '06  
Generalnice customization of Windows explorer... Pinmemberjoshidipesh20:28 7 Sep '06  
GeneralExcellent thinking Pinmembersivas_v19:49 7 Sep '06  
GeneralFormatting of snippets PinmemberEd.Poore4:16 7 Sep '06  
JokeRe: Formatting of snippets Pinmemberbarryc_mailbox7:35 28 Jan '09  

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120210.1 | Last Updated 14 Sep 2006
Article Copyright 2006 by Venkatakarthikeyan Natarajamoorthy
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid