{"action":"created","comment":{"url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/comments/24260967","id":24260967,"diff_hunk":"@@ -1,48 +1,111 @@\n-﻿using System.ComponentModel;\n-using System.Drawing;\n+﻿using System;\n+using System.Reflection;\n+using System.Runtime.InteropServices;\n using System.Windows.Forms;\n \n namespace NTH.Windows.Forms\n {\n-    // TODO\n+    // TODO: Support non-vista systems, currently only Vista+ is supported with the following code\n     public class NthListView : ListView\n     {\n-        protected override CreateParams CreateParams\n-        {\n-            get\n-            {\n-                var cp = base.CreateParams;\n-                if(Environment.OSVersion.Version.Major >= 6)\n-                    cp |= 0; // TODO\n-                return cp;\n-            }\n-        }\n+        private const int LVM_FIRST = 0x1000;\n+        private const int LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54;\n+        private const int LVS_EX_DOUBLEBUFFER = 0x00010000;\n+        private bool _isExplorerListView;\n+\n+        //protected override CreateParams CreateParams\n+        //{\n+        //    get\n+        //    {\n+        //        var cp = base.CreateParams;\n+        //        if(Environment.OSVersion.Version.Major >= 6)\n+        //            cp |= 0; // TODO\n+        //        return cp;\n+        //    }\n+        //}\n+\n         public NthListView()\n         {\n-            SetBuffingOptions();\n+            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);\n+            //if (Environment.OSVersion.Version.Major < 6)\n+            //    SetStyle(ControlStyles.UserPaint, true);\n+            UpdateStyles();\n+\n+            FullRowSelect = true; // Customizable...\n         }\n \n-        private void SetBuffingOptions()\n+        //protected override void OnPaint(PaintEventArgs e)\n+        //{\n+        //    if (GetStyle(ControlStyles.UserPaint))\n+        //    {\n+        //        Message m = new Message\n+        //        {\n+        //            HWnd = Handle,\n+        //            Msg = WM_PRINTCLIENT,\n+        //            WParam = e.Graphics.GetHdc(),\n+        //            LParam = (IntPtr) PRF_CLIENT\n+        //        };\n+        //        DefWndProc(ref m);\n+        //        e.Graphics.ReleaseHdc(m.WParam);\n+        //    }\n+        //    base.OnPaint(e);\n+        //}\n+\n+        public void MakeCollapsable() // Adds expanders to the groups, should be called in form's Show-event\n         {\n-            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);\n-            // Disable default CommCtrl painting on non-Vista systems\n             if (Environment.OSVersion.Version.Major < 6)\n-                SetStyle(ControlStyles.UserPaint, true);\n+                return;\n+\n+            const int lvmFirst = 0x1000;\n+            const int LVM_SETGROUPINFO = (lvmFirst + 147);\n+\n+            foreach (ListViewGroup group in Groups)\n+            {\n+                var placeHolderGroup = new NthListViewGroup();\n+                placeHolderGroup.CbSize = Marshal.SizeOf(placeHolderGroup);\n+                placeHolderGroup.State = NthListViewGroupState.Collapsible;\n+                placeHolderGroup.Mask = NthListViewGroupMask.State;\n+                placeHolderGroup.GroupId = GetGroupId(group);\n+\n+                if (placeHolderGroup.GroupId >= 0)\n+                    NativeMethods.SendMessage(Handle, LVM_SETGROUPINFO, new IntPtr(placeHolderGroup.GroupId), ref placeHolderGroup);","path":"src/NTH.Windows.Forms/NTH.Windows.Forms/NthListView.cs","position":89,"original_position":89,"commit_id":"b83fb982412c765213fc82c98a840380260ee4c8","original_commit_id":"b83fb982412c765213fc82c98a840380260ee4c8","user":{"login":"nikeee","id":4068864,"avatar_url":"https://avatars.githubusercontent.com/u/4068864?v=3","gravatar_id":"","url":"https://api.github.com/users/nikeee","html_url":"https://github.com/nikeee","followers_url":"https://api.github.com/users/nikeee/followers","following_url":"https://api.github.com/users/nikeee/following{/other_user}","gists_url":"https://api.github.com/users/nikeee/gists{/gist_id}","starred_url":"https://api.github.com/users/nikeee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikeee/subscriptions","organizations_url":"https://api.github.com/users/nikeee/orgs","repos_url":"https://api.github.com/users/nikeee/repos","events_url":"https://api.github.com/users/nikeee/events{/privacy}","received_events_url":"https://api.github.com/users/nikeee/received_events","type":"User","site_admin":false},"body":"I don't know whether the pinvoke call makes it necessary to pin the struct `NthListViewGroup` using the GC's PinObjct function to make sure the GC does not move the struct while being used by the native method.\r\nSee:\r\nhttp://manski.net/2012/06/pinvoke-tutorial-pinning-part-4/\r\nAlso, if it's getting pinned, we can refactor/remove the SendMessage overload that has an explicit `NthListViewGroup` parameter. Instead, we could just use `objectToBePinned.AddrOfPinnedObject()` and IntPtr (which is already present).","created_at":"2015-02-06T18:37:25Z","updated_at":"2015-02-06T18:37:25Z","html_url":"https://github.com/nikeee/NTH.Windows.Forms/pull/1#discussion_r24260967","pull_request_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/comments/24260967"},"html":{"href":"https://github.com/nikeee/NTH.Windows.Forms/pull/1#discussion_r24260967"},"pull_request":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/1","id":28817428,"html_url":"https://github.com/nikeee/NTH.Windows.Forms/pull/1","diff_url":"https://github.com/nikeee/NTH.Windows.Forms/pull/1.diff","patch_url":"https://github.com/nikeee/NTH.Windows.Forms/pull/1.patch","issue_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/issues/1","number":1,"state":"open","locked":false,"title":"Added collapsable Explorer ListView","user":{"login":"ProgTrade","id":6246521,"avatar_url":"https://avatars.githubusercontent.com/u/6246521?v=3","gravatar_id":"","url":"https://api.github.com/users/ProgTrade","html_url":"https://github.com/ProgTrade","followers_url":"https://api.github.com/users/ProgTrade/followers","following_url":"https://api.github.com/users/ProgTrade/following{/other_user}","gists_url":"https://api.github.com/users/ProgTrade/gists{/gist_id}","starred_url":"https://api.github.com/users/ProgTrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProgTrade/subscriptions","organizations_url":"https://api.github.com/users/ProgTrade/orgs","repos_url":"https://api.github.com/users/ProgTrade/repos","events_url":"https://api.github.com/users/ProgTrade/events{/privacy}","received_events_url":"https://api.github.com/users/ProgTrade/received_events","type":"User","site_admin":false},"body":"- A bit of refactoring (optimized Using-directives etc.)\r\n- Changed code of Explorer ListView, old one is commented out\r\n- Made Explorer ListView collapsable and changed code a bit (maybe\r\ncurrently not yet compatible with systems < Windows Vista)\r\n- Made NthLinkLabel class sealed because of virtual member call in\r\nconstructor (can be changed of course, if necessary/wished)","created_at":"2015-02-06T15:39:37Z","updated_at":"2015-02-06T18:37:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a57285381329298a763647e71e5465b6a3460a7b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/1/commits","review_comments_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/1/comments","review_comment_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/comments/{number}","comments_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/issues/1/comments","statuses_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/statuses/b83fb982412c765213fc82c98a840380260ee4c8","head":{"label":"ProgTrade:master","ref":"master","sha":"b83fb982412c765213fc82c98a840380260ee4c8","user":{"login":"ProgTrade","id":6246521,"avatar_url":"https://avatars.githubusercontent.com/u/6246521?v=3","gravatar_id":"","url":"https://api.github.com/users/ProgTrade","html_url":"https://github.com/ProgTrade","followers_url":"https://api.github.com/users/ProgTrade/followers","following_url":"https://api.github.com/users/ProgTrade/following{/other_user}","gists_url":"https://api.github.com/users/ProgTrade/gists{/gist_id}","starred_url":"https://api.github.com/users/ProgTrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProgTrade/subscriptions","organizations_url":"https://api.github.com/users/ProgTrade/orgs","repos_url":"https://api.github.com/users/ProgTrade/repos","events_url":"https://api.github.com/users/ProgTrade/events{/privacy}","received_events_url":"https://api.github.com/users/ProgTrade/received_events","type":"User","site_admin":false},"repo":{"id":30382219,"name":"NTH.Windows.Forms","full_name":"ProgTrade/NTH.Windows.Forms","owner":{"login":"ProgTrade","id":6246521,"avatar_url":"https://avatars.githubusercontent.com/u/6246521?v=3","gravatar_id":"","url":"https://api.github.com/users/ProgTrade","html_url":"https://github.com/ProgTrade","followers_url":"https://api.github.com/users/ProgTrade/followers","following_url":"https://api.github.com/users/ProgTrade/following{/other_user}","gists_url":"https://api.github.com/users/ProgTrade/gists{/gist_id}","starred_url":"https://api.github.com/users/ProgTrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProgTrade/subscriptions","organizations_url":"https://api.github.com/users/ProgTrade/orgs","repos_url":"https://api.github.com/users/ProgTrade/repos","events_url":"https://api.github.com/users/ProgTrade/events{/privacy}","received_events_url":"https://api.github.com/users/ProgTrade/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ProgTrade/NTH.Windows.Forms","description":"A library that contains nice-to-have functionality for Windows Forms applications.","fork":true,"url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms","forks_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/forks","keys_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/teams","hooks_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/hooks","issue_events_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/issues/events{/number}","events_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/events","assignees_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/assignees{/user}","branches_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/branches{/branch}","tags_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/tags","blobs_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/git/refs{/sha}","trees_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/statuses/{sha}","languages_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/languages","stargazers_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/stargazers","contributors_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/contributors","subscribers_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/subscribers","subscription_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/subscription","commits_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/commits{/sha}","git_commits_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/git/commits{/sha}","comments_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/comments{/number}","issue_comment_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/issues/comments/{number}","contents_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/contents/{+path}","compare_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/merges","archive_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/downloads","issues_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/issues{/number}","pulls_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/pulls{/number}","milestones_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/milestones{/number}","notifications_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/labels{/name}","releases_url":"https://api.github.com/repos/ProgTrade/NTH.Windows.Forms/releases{/id}","created_at":"2015-02-05T22:35:08Z","updated_at":"2015-02-06T15:36:05Z","pushed_at":"2015-02-06T15:36:05Z","git_url":"git://github.com/ProgTrade/NTH.Windows.Forms.git","ssh_url":"git@github.com:ProgTrade/NTH.Windows.Forms.git","clone_url":"https://github.com/ProgTrade/NTH.Windows.Forms.git","svn_url":"https://github.com/ProgTrade/NTH.Windows.Forms","homepage":null,"size":540,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nikeee:master","ref":"master","sha":"c9f4978dea4175bd0e80294ef95964b31ed1c8d4","user":{"login":"nikeee","id":4068864,"avatar_url":"https://avatars.githubusercontent.com/u/4068864?v=3","gravatar_id":"","url":"https://api.github.com/users/nikeee","html_url":"https://github.com/nikeee","followers_url":"https://api.github.com/users/nikeee/followers","following_url":"https://api.github.com/users/nikeee/following{/other_user}","gists_url":"https://api.github.com/users/nikeee/gists{/gist_id}","starred_url":"https://api.github.com/users/nikeee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikeee/subscriptions","organizations_url":"https://api.github.com/users/nikeee/orgs","repos_url":"https://api.github.com/users/nikeee/repos","events_url":"https://api.github.com/users/nikeee/events{/privacy}","received_events_url":"https://api.github.com/users/nikeee/received_events","type":"User","site_admin":false},"repo":{"id":22068250,"name":"NTH.Windows.Forms","full_name":"nikeee/NTH.Windows.Forms","owner":{"login":"nikeee","id":4068864,"avatar_url":"https://avatars.githubusercontent.com/u/4068864?v=3","gravatar_id":"","url":"https://api.github.com/users/nikeee","html_url":"https://github.com/nikeee","followers_url":"https://api.github.com/users/nikeee/followers","following_url":"https://api.github.com/users/nikeee/following{/other_user}","gists_url":"https://api.github.com/users/nikeee/gists{/gist_id}","starred_url":"https://api.github.com/users/nikeee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikeee/subscriptions","organizations_url":"https://api.github.com/users/nikeee/orgs","repos_url":"https://api.github.com/users/nikeee/repos","events_url":"https://api.github.com/users/nikeee/events{/privacy}","received_events_url":"https://api.github.com/users/nikeee/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nikeee/NTH.Windows.Forms","description":"A library that contains nice-to-have functionality for Windows Forms applications.","fork":false,"url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms","forks_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/forks","keys_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/teams","hooks_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/hooks","issue_events_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/issues/events{/number}","events_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/events","assignees_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/assignees{/user}","branches_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/branches{/branch}","tags_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/tags","blobs_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/git/refs{/sha}","trees_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/statuses/{sha}","languages_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/languages","stargazers_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/stargazers","contributors_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/contributors","subscribers_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/subscribers","subscription_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/subscription","commits_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/commits{/sha}","git_commits_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/git/commits{/sha}","comments_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/comments{/number}","issue_comment_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/issues/comments/{number}","contents_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/contents/{+path}","compare_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/merges","archive_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/downloads","issues_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/issues{/number}","pulls_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls{/number}","milestones_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/milestones{/number}","notifications_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/labels{/name}","releases_url":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/releases{/id}","created_at":"2014-07-21T14:50:48Z","updated_at":"2015-02-06T01:01:39Z","pushed_at":"2015-02-06T01:05:21Z","git_url":"git://github.com/nikeee/NTH.Windows.Forms.git","ssh_url":"git@github.com:nikeee/NTH.Windows.Forms.git","clone_url":"https://github.com/nikeee/NTH.Windows.Forms.git","svn_url":"https://github.com/nikeee/NTH.Windows.Forms","homepage":null,"size":540,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/1"},"html":{"href":"https://github.com/nikeee/NTH.Windows.Forms/pull/1"},"issue":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/issues/1"},"comments":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/nikeee/NTH.Windows.Forms/statuses/b83fb982412c765213fc82c98a840380260ee4c8"}}}}