CButton *btn = new CButton();
btn->Create("btn", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(0,0,50,50), this, 1234);
btn = new CButton();
btn->Create("btn", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(40,30,50,50), this, 1234);
running above code in CDialog::OnInitDialog() will only display first button correctly, the second button will be displayed incompletely.
Any suggestion is appreciated.
The
CRectconstructor you’re using is not doing what you think it’s doing. The 4 parameter override takes left, right, top, bottom as parameters. You are simply making the rectangle too small – there’s nothing incomplete about it.As an aside you’re giving both controls the same control ID of 1234 – that’s potentially dangerous – you should rather give them unique values.