Reputation: 3685
Porting an existing WTL application to C++20. One of the issues we're running into is that atlwin.h has a method "Create" with the following signature:
HWND Create(
_In_opt_ HWND hWndParent,
_In_ _U_RECT rect = NULL,
_In_opt_z_ LPCTSTR szWindowName = NULL,
_In_ DWORD dwStyle = 0,
_In_ DWORD dwExStyle = 0,
_In_ _U_MENUorID MenuOrID = 0U,
_In_opt_ LPVOID lpCreateParam = NULL)
and was being called like this:
Create(hWnd, CRECT(0,0, 100, 200), ....)
The constructor for _U_RECT only takes a reference to a RECT or a pointer to a RECT, which means that you cannot pass a temporary in.
How have people worked around this? I'd hate to have to go through all of the code and replace the above code with:
CRect tmpRect(0, 0, 100, 200);
Create(hwnd, tmpRect, .....);
The version of MSVC being used is 14.37.32822.
Upvotes: 0
Views: 114
Reputation: 3685
I went with a mixin class to add a new method, which I was able to use in all the places I derived from WinImpl.
It added a Create method which had a CRect by value.
Upvotes: 0