how to clip a dynamically created dialog controls

55 views Asked by At

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.

0

There are 0 answers