On Tuesday, 26 May 2020 at 13:37:22 UTC, Vinod K Chandran wrote:
On Tuesday, 26 May 2020 at 12:41:20 UTC, John Chapman wrote:
On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote:
Here is my full code. Please take a look.
https://pastebin.com/av3nrvtT
Change line 124 to:
SetWindowSubclass(this.mHandle, SUBCLASSPROC(&btnWndProc),
UINT_PTR(subClsID), cast(DWORD_PTR)cast(void*)this);
That is, change `&this` to `cast(void*)this`.
Hi,
Thanks for the reply. That will work like charm but we need to
change the code in subclassed button's WndProc like this--
extern(Windows)
private LRESULT btnWndProc(HWND hWnd, UINT message, WPARAM
wParam, LPARAM lParam, UINT_PTR scID, DWORD_PTR refData) {
try {
Button thisBtn = cast(Button)cast(void*)refData;
{
catch (Exception e) {}
....
So far now, two solutions are very clear for this problem.
1. As per John Chapman's suggestion - use
cast(DWORD_PTR)cast(void*)this).
2. Use another varibale to use as an lvalue. -
Button dummyBtn = this;
cast(DWORD_PTR)&dummyBtn;
Among these two, i think 2nd option is good. Am i right ?