I had a look at the code again and saw I was creating a WNDCLASSEX class but just using the typical CreateWindow call, not CreateWindowEx.

Also reserved some extra space in the cbWndExtra variable on the window class.

No longer need to use AddRef() anywhere to get it to work when using the Dialog Box. Which to be honest is a relief. I wouldn't really want to be having to worry about COM ptrs not keeping track of themselves properly.

However the error persists when I just open and close the window. In the mdxgifactory COM ptr there's a problem with the Release() part:

Struggling to call AddRef() in Windows Procedure - with user data & LongPtr-com-issue_1-jpg

I suspect I'm just handling a pointer badly somewhere. Just can't figure out where at the moment