0

I have a dialog window (MFC, CDialogEx) on which I am displaying some kind of information - mostly text, with some hints about the context (hints made with background color, presence of frames and formatting). Text and everything is written in OnPaint(), using standard CPaintDC dc(this);. Text is long, so everything is scrollable and clipped (with dc.SetClipRgn) to the client area of the dialog (minus some margins). So far, so good, everything works as expected.

On top of that I wanted to add radio buttons that will allow showing cross links between parts of the text (this is kind of a story telling system). No problems with adding them either:

    CButton* pCB = new CButton;
    pCB->Create(_T(""), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON | WS_GROUP, cr, this, iButtonNo);
    pCB->ShowWindow(SW_SHOW);

(cr is a CReg with button coordinates, iButtonNo is a control ID). Now, when I scroll the dialog I just call SetWindowPos for every radio button to move it together with the text - and it works OK too.

dialog window with dynamic buttons that I am unable to clip

The only thing that I have no idea how to deal with is the radio button clipping. At the moment they are drawn on the whole dialog window. Is there a way to clip the buttons to the same region my text is clipped? I tried to pass the clipping region to the CButton DC (plus some other tricks I could think of) but to no avail.

3
  • 3
    Create a child dialog that is positioned according to your desired margins and make the buttons children of the child dialog. This automatically clips the buttons to the child dialog and everything will be fine. Commented Jan 20, 2023 at 17:18
  • 1
    @zett42 not without hurdles, but yes, it worked, thanks Commented Jan 21, 2023 at 23:47
  • 1
    Glad to have given the right pointers. If you'd like you could write your own answer. Commented Jan 22, 2023 at 10:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.