locked
How to create a border around a static control? RRS feed

  • Question

  • I created a static control to display different images, see the code below.

    CStatic m_ctrlImage;
    CRect rectImage(rectTree.left, rectTree.bottom, rectTree.right, rectTree.bottom + 200);
    m_ctrlImage.Create(NULL, WS_CHILD | SS_BITMAP | WS_VISIBLE | SS_REALSIZEIMAGE | SS_CENTERIMAGE, rectImage, this, IDC_IMAGE);

    The image can be displayed in the static control, but there is no border around the rectangular area of the static control. How to create a border around a static control?

    Thanks in advance.

    Monday, August 6, 2018 3:10 PM

Answers

  • Add the WS_BORDER style.  You may need to make the static control's CRect a few pixels larger than the image for the border to be seen.

    • Edited by RLWA32 Monday, August 6, 2018 3:46 PM added sizing observation
    • Marked as answer by Yan Yang Monday, August 6, 2018 3:50 PM
    Monday, August 6, 2018 3:37 PM