🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: uk.d-i-y
Article #427

Re: OT: Burnham's Brexit Bullshit Baffles Brains

#427
From: Jeff Gaines
Date: Fri, 16 Oct 2026 19:36
120 lines
4990 bytes
On 16/10/2026 in message <njeu1tFub65U1@mid.individual.net> Andy Burns 
wrote:

>Jeff Gaines wrote:
>
>>Andy Burns wrote:
>>
>>>Chris Green wrote:
>>
>>>>How does it know "that golden nugget" is right though?
>>>It doesn't, but Jeff has marked its homework ...
>>
>>It works, Dandini, it works!
>>It is still working and is probably my most used control. I still fail  to 
>>understand how AI came up with it when in 21 years nobody else did.
>Show us its "trick" then ...

You have a Header Class defined thus:

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace JGControls
{
	//	Private NativeWindow class to hook header messages
	class HeaderWindow : NativeWindow
	{
		readonly JListViewOD m_ParentListView;

		const int HDM_LAYOUT = 0x1205;

		public HeaderWindow(JListViewOD parent)
		{
			m_ParentListView = parent;
		}

		protected override void WndProc(ref Message m)
		{
			base.WndProc(ref m);

			if (m.Msg == HDM_LAYOUT)
			{
				// Unpack the HDLAYOUT structures from lParam
				HDLAYOUT hdLayout = (HDLAYOUT)Marshal.PtrToStructure(m.LParam, 
typeof(HDLAYOUT));
				RECT rect = (RECT)Marshal.PtrToStructure(hdLayout.prc, typeof(RECT));
				WINDOWPOS wp = (WINDOWPOS)Marshal.PtrToStructure(hdLayout.pwpos, 
typeof(WINDOWPOS));

				// Alter the height of the header
				wp.cy = m_ParentListView.HeaderHeight;

				// Adjust the remaining area for the ListView items
				rect.top = m_ParentListView.HeaderHeight;

				// Write modified structures back to unmanaged memory
				Marshal.StructureToPtr(wp, hdLayout.pwpos, false);
				Marshal.StructureToPtr(rect, hdLayout.prc, false);

				// Set result to 1 (True) to signal message has been handled
				m.Result = new IntPtr(1);
				return;
			}
		}

		// Win32 Layout Structs
		[StructLayout(LayoutKind.Sequential)]
		private struct RECT { public int left, top, right, bottom; }

		[StructLayout(LayoutKind.Sequential)]
		private struct WINDOWPOS { public IntPtr hwnd, hwndInsertAfter; public 
int x, y, cx, cy, flags; }

		[StructLayout(LayoutKind.Sequential)]
		private struct HDLAYOUT { public IntPtr prc; public IntPtr pwpos; }
	}
}

Then in the owner draw ListView class:

protected override void OnHandleCreated(EventArgs e)
		{
			base.OnHandleCreated(e);

			// Get the handle of the underlying native header control
			IntPtr hHeader = SendMessage(this.Handle, LVM_GETHEADER, IntPtr.Zero, 
IntPtr.Zero);
			if (hHeader != IntPtr.Zero)
			{
				// Subclass the header control using NativeWindow
				m_HeaderWindow = new HeaderWindow(this);
				m_HeaderWindow.AssignHandle(hHeader);
			}
		}

		protected override void OnHandleDestroyed(EventArgs e)
		{
			if (m_HeaderWindow != null)
			{
				m_HeaderWindow.ReleaseHandle();
				m_HeaderWindow = null;
			}
			base.OnHandleDestroyed(e);
		}

So in the header class you reset the dimensions each time the HDM_LAYOUT 
message is received.

If you're interested I can zip up the source for you, its built under .NET 
Framework 3.5 becuase the VS200 iDE has fewere bugs than ater versions but 
it can be re-compiled for later versions.

PS Im not going to spell check this so apologies for any typos!

-- 
Jeff Gaines Dorset UK
Have you ever noticed that all the instruments searching for intelligent 
life are pointing away from Earth?
Technical Details
Message-ID: <xn0pw3iiuia6zkn01w@news.individual.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <11aknut$add0$12@dont-email.me> <20261014103506.14b70c01@jrenewsid.jretrading.com> <cZPzS.2$qBD1.1@fx05.ams1> <njac69F89a8U1@mid.individual.net> <op.3w7f92d10jndxk@pvr2.lan> <njcborFhf8dU1@mid.individual.net> <op.3w821ebh0jndxk@pvr2.lan> <njd0arFko0iU1@mid.individual.net> <op.3w9es0c00jndxk@pvr2.lan> <njeclrFrhs4U1@mid.individual.net> <xn0pw353hhrwuqt01n@news.individual.net> <njef5dFrtqsU1@mid.individual.net> <xn0pw35y5ht5ab001p@news.individual.net> <njehjgFsaeuU1@mid.individual.net> <94m9qm-sic.ln1@q957.zbmc.eu> <njeoesFtchcU1@mid.individual.net> <xn0pw39t4hyau7k01t@news.individual.net> <njeu1tFub65U1@mid.individual.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: "Jeff Gaines" <jgnewsid@outlook.com>
Newsgroups: uk.d-i-y
Subject: Re: OT: Burnham's Brexit Bullshit Baffles Brains
Date: 16 Oct 2026 19:36:14 GMT
Lines: 120
Message-ID: <xn0pw3iiuia6zkn01w@news.individual.net>
References: <11aknut$add0$12@dont-email.me> <20261014103506.14b70c01@jrenewsid.jretrading.com> <cZPzS.2$qBD1.1@fx05.ams1> <njac69F89a8U1@mid.individual.net> <op.3w7f92d10jndxk@pvr2.lan> <njcborFhf8dU1@mid.individual.net> <op.3w821ebh0jndxk@pvr2.lan> <njd0arFko0iU1@mid.individual.net> <op.3w9es0c00jndxk@pvr2.lan> <njeclrFrhs4U1@mid.individual.net> <xn0pw353hhrwuqt01n@news.individual.net> <njef5dFrtqsU1@mid.individual.net> <xn0pw35y5ht5ab001p@news.individual.net> <njehjgFsaeuU1@mid.individual.net> <94m9qm-sic.ln1@q957.zbmc.eu> <njeoesFtchcU1@mid.individual.net> <xn0pw39t4hyau7k01t@news.individual.net> <njeu1tFub65U1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net E1VPYUcmqNizAFZuqrO7cwkjiM+4sKUWRfAszigT0uoiGrUzKh
Cancel-Lock: sha1:G19KXig1k6f0R2eoOME9JkibZvY= sha256:AGIE+VHM2QLFWHAwt6uCKZqXLKfgndT8KiGhi5TyvM0=
User-Agent: XanaNews/1.21-f3fb89f (x86; Portable ISpell)
X-Face: `{n`"d>nF^Uwzc:,L`j<I0Z`+o3aIFomb({]W!ey_aouI;EhEg9Q~,73RF,@{]-!$,A,z>,x
X-Ref: news.individual.net ~XNS:00006361