I made one of these threads a few months ago, but I never solved this problem because I was offered a work-around that was a better choice at the time. But now I'm back to this problem. And although there might be a way to work-around this one, I really don't want. I really want to get this right, because it'll come in so useful. I have a custom CSortListCtrl class that derives from CMFCListCtrl and a custom CSortHeaderCtrl class that derives from CMFCHeaderCtrl. I want to replace the header control in the list control with my custom header control, but can't seem to get it right. So far, this is the code I have in the custom list control.

Code:
void CSortListCtrl::PreSubclassWindow()
{
	CMFCListCtrl::PreSubclassWindow();

	i_header.SubclassWindow(GetHeaderCtrl().GetSafeHwnd());
}
I've also tried having i_header as a pointer and creating it right before subclassing, and that didn't work either. I also tried overriding the GetHeaderCtrl() function to return my header ctrl, but that gives me a runtime exception that causes the program to crash. I've also tried using this line which I found online, but same error.

Code:
i_header.SubclassDlgItem(0, this);
I feel like I've ready every tutorial on the internet and can't get it right. What am I missing?

EDIT: I should mention that the code I posted compiles, but doesn't actually subclass, as my override functions aren't called.