Checkbox label

Started by
2 comments, last by ApochPiQ 17 years, 6 months ago
Hi everyone. I'm using c++ (no MFC), and I've created a checkbox using this code...

  m_hWalkableBox = CreateWindowEx(
    0,
    "BUTTON",
    "Walkable?",
    WS_CHILD | WS_VISIBLE | BS_CHECKBOX | BS_RIGHTBUTTON,
    73,
    5,
    13,
    13,
    m_hAttributeWnd,
    (HMENU)CHK_WALKABLE,
    m_hInst,
    NULL
    );



It creates an empty checkbox with a big W in it. The text shows up inside of the checkbox, instead of to the left. Anyone know what's causing this? Edit: couldn't find a site to host the image, so I removed it.
Advertisement
Quote:
HWND CreateWindowEx(

DWORD dwExstyle,
LPCTSTR lpClassName,
LPCTSTR lpWindowName,
DWORD dwstyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);

Probably because in the call that you've posted x > nWidth.
Oh, well that wasn't the problem, but you made me notice that I wasn't allowing it to be wide enough to show the text. I made the width to be the exact width of the checkbox, not allowing any more room for the label. Thanks.
The x coordinate is the coordinate of the left edge of the checkbox control relative to the parent window's client area. The nWidth value is a width which is offset from the left edge to yield the right edge's coordinate. There is no reason why your x coordinate shouldn't be greater than the width of the checkbox.

As the OP already discovered, the problem is that the total width of the control being created is too small. The x coordinate is in no way involved.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement