I recently stumbled over a problem that is bogging me from time to time:
The black rectangle will be a button later, it's just a placeholder for now.
The problem is the new window I create for showing the options the button provides. I just don't know how to position it under my "button"! Currently it lays over the left half of my "button". It is supposed to be right under it.
Right now I use this code:
void SF_PopupControl::RepositionWindow(){ D3DXVECTOR2 AbsPos; GetAbsolutePosition(&AbsPos); RECT r; GetWindowRect(D2DObjects->RenderTarget->GetHwnd(),&r); SetWindowPos(Popup.GetHWND(),HWND_TOP,AbsPos.x+r.left,AbsPos.y+r.top+ItemSize.y,0,0,SWP_NOSIZE);}
But since GetWindowRect includes the window's frame, this can't work and produces the output I've shown above.
Making the popup a child won't work either, because then it starts to fight with Direct2D.