What is the reason that the button for both code examples ends up in a different location on the form?.
This piece of code sets the button in the correct location on the form.
hCtle = CreateWindowEx(xStyle, "Button", cText, WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or cStyle, _
hctl.rect.left, _ ' // horizontal position
hctl.rect.top, _ ' // vertical position
hctl.rect.right - hctl.rect.left, _ ' // window width
hctl.rect.bottom - hctl.rect.top, _ ' // window height
hwndOwner, Cast(HMENU,id), _
GetModuleHandle(NULL), _
NULL)
I would like to use AFX, but then my button location is no longer correct.
DIM pWindow AS CWindow PTR = AfxCWindowOwnerPtr(hwndOwner)
hCtle = pWindow->AddControl ( "Button", _
hwndOwner, _
id, _
cText, _
hctl.rect.left, _ ' // Horizontal position
hctl.rect.top, _ ' // Vertical position
hctl.rect.right - hctl.rect.left, _ ' // Control width
hctl.rect.bottom - hctl.rect.top, _ ' // Control height
WS_CHILD Or WS_VISIBLE Or WS_TABSTOP Or cStyle, _
xStyle, _
0, _
Null, _
&HFFFFFFFF, _
Null )
can I calculate the correct coordinates with a function?