C++ cast to D cast again

BLS nanali at nospam-wanadoo.fr
Sun Sep 30 02:46:26 PDT 2007


Hi and sorry about picking on your nerves gain :(
// C++
class CWin
{
//
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uID, WPARAM wParam, 
LPARAM lParam)
{
   CWin* pWnd=NULL;  // init pWnd
}

// later ...
CWin* pChild=reinterpret_cast<CWin*>((HWND)
::GetWindowLong(pWnd->GetDlgItem( ((( LPDRAWITEMSTRUCT )lParam)->CtlID) 
),GWL_USERDATA) );


}

//our D class
class CWin
{
static LRESULT WndProc(HWND hWnd, UINT uID, WPARAM wParam, LPARAM lParam)
{
   CWin pWnd=null;  // init pWnd as    ---reference !
}
/* instead of :
CWin* pChild=reinterpret_cast<CWin*>
we use
CWin pChild = cast(CWin) cast(void*)

But I am not sure how to translate :
((HWND)
::GetWindowLong(pWnd->GetDlgItem( ((( LPDRAWITEMSTRUCT )lParam)->CtlID) 
),GWL_USERDATA) );
*/

}

GetWindowLong() is a Windows Api, sure you know it.
So what the correct translation ?
Bjoern
Beside, I still wonder : Having a class A, Is A* pA a legal construct in D.
What is pA from a technical view; a pointer to a reference ?


More information about the Digitalmars-d-learn mailing list