On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote:
Hi all,
I have a class like this.
class Button : Control {
        ...
        HWND createButton(){
                ...
SetWindowSubclass(this.mHandle, SUBCLASSPROC(&btnWndProc), UINT_PTR(subClsID), cast(DWORD_PTR) this);
        }
}

But compiler says that - "Error: 'this' is not an lvalue and cannot be modified" I've seen many cpp code which uses pointer to 'this' as the last parameter in SetWindowSubclass(). Is there something wrong with my approach ?

I think your issue might be elsewhere because casting this should be fine and it should not complain about that in your given code.

At least you should be able to pass this to another function or even cast it.

Please show the full code and the full error which gives you the stacktrace of where it's called and from where.

Reply via email to