How to get the pointer of "this" ?
John Chapman
johnch_atms at hotmail.com
Tue May 26 17:14:59 UTC 2020
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) {}
> ....
Yes, that should work.
More information about the Digitalmars-d-learn
mailing list