Click here to Skip to main content
15,884,298 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ even numbers query Pin
Richard MacCutchan1-Mar-22 22:40
mveRichard MacCutchan1-Mar-22 22:40 
QuestionRe: C++ even numbers query Pin
David Crow1-Mar-22 3:50
David Crow1-Mar-22 3:50 
AnswerRe: C++ even numbers query Pin
Richard Andrew x642-Mar-22 9:42
professionalRichard Andrew x642-Mar-22 9:42 
QuestionC Pin
Christine Belisario25-Feb-22 20:48
Christine Belisario25-Feb-22 20:48 
AnswerRe: C Pin
Richard MacCutchan25-Feb-22 22:52
mveRichard MacCutchan25-Feb-22 22:52 
AnswerRe: C Pin
RedDk26-Feb-22 8:47
RedDk26-Feb-22 8:47 
GeneralRe: C Pin
Greg Utas26-Feb-22 10:32
professionalGreg Utas26-Feb-22 10:32 
Questionhow to dynamically delete sub-control created in run-time Pin
wuxianzhong18-Feb-22 15:54
wuxianzhong18-Feb-22 15:54 
first of all, i shall thanks all of you guys.
In my project, i created some STATIC & EDIT controls in a CDialog and set these control's parent to a group box(also a STATIC control).
it works well for create, but it can't be delete dynamically.
For example, i create 5 EDIT control then delete it(there are no sub-controls in group box this time), and i create 2 EDIT control again, oops! there are 5 EDIT control showing in the group box. So, i guess this caused by the group box haven't refreshed in time. and then i sendmessage to group box to force it to refresh. unfortunately it doesn't works.
here is my code:
<pre lang="C++">
void CPLCDlg::DynamicCreateEdit(UINT nNums)
{
const int YSpace = 15;
const int EHeight = 20;
const UINT EDITID = 72000;
if (nNums <= 0)
return;
CButton* pGroup = (CButton*)GetDlgItem(IDC_STATIC_GROUP);
if (NULL != pGroup)
{
if (NULL != m_pDynEdit && m_siNumsOfDynEdit > 0)
{
for (short i = 0; i < m_siNumsOfDynEdit; i++)
{
if (NULL != m_pDynEdit[i].GetSafeHwnd())
{
m_pDynEdit[i].ShowWindow(SW_HIDE);
m_pDynEdit[i].DestroyWindow();
}
delete m_pDynEdit[i];
}
delete[] m_pDynEdit;
m_pDynEdit = NULL;
::SendMessage(pGroup->GetSafeHwnd(), WM_ERASEBKGND, 0, 0);
}
pGroup->Invalidate(FALSE);
pGroup->RedrawWindow();
pGroup->UpdateWindow();
CRect rcPos;
CString str;
rcPos.SetRectEmpty();
m_pDynEdit = new CEdit[nNums]();
for (short i = 0; i < nNums; i++)
{
rcPos.left = 10;
rcPos.top = 20 + (EHeight + YSpace) * i;
rcPos.right = rcPos.left + 30;
rcPos.bottom = rcPos.top + EHeight;
str.Empty();
str.Format(_T("%d"), i + 1);
if (m_pDynEdit[i].CreateEx(WS_EX_STATICEDGE, _T("EDIT"), (LPCTSTR)str, ES_CENTER | WS_VISIBLE | WS_CHILD | WS_TABSTOP, rcPos, pGroup, EDITID + i))
{
//m_pDynEdit[i].SetWindowText(_T("0"));
}

}
m_siNumsOfDynEdit = nNums;
}
}

</pre>
AnswerRe: how to dynamically delete sub-control created in run-time Pin
Gerry Schmitz18-Feb-22 20:30
mveGerry Schmitz18-Feb-22 20:30 
AnswerRe: how to dynamically delete sub-control created in run-time Pin
Victor Nijegorodov18-Feb-22 21:18
Victor Nijegorodov18-Feb-22 21:18 
AnswerRe: how to dynamically delete sub-control created in run-time Pin
Randor 19-Feb-22 6:27
professional Randor 19-Feb-22 6:27 
QuestionAzure DevOps Chocolatey question : install vs2022 Pin
Maximilien17-Feb-22 7:52
Maximilien17-Feb-22 7:52 
AnswerRe: Azure DevOps Chocolatey question : install vs2022 Pin
Mircea Neacsu17-Feb-22 8:02
Mircea Neacsu17-Feb-22 8:02 
GeneralRe: Azure DevOps Chocolatey question : install vs2022 Pin
Maximilien18-Feb-22 3:23
Maximilien18-Feb-22 3:23 
GeneralRe: Azure DevOps Chocolatey question : install vs2022 Pin
Mircea Neacsu18-Feb-22 5:06
Mircea Neacsu18-Feb-22 5:06 
QuestionMessage Closed Pin
13-Feb-22 18:51
Member 1496877113-Feb-22 18:51 
AnswerRe: resource wanted - print control / color codes Pin
Gerry Schmitz13-Feb-22 19:32
mveGerry Schmitz13-Feb-22 19:32 
AnswerRe: resource wanted - print control / color codes Pin
Richard MacCutchan13-Feb-22 22:24
mveRichard MacCutchan13-Feb-22 22:24 
AnswerRe: resource wanted - print control / color codes Pin
Peter_in_278013-Feb-22 22:31
professionalPeter_in_278013-Feb-22 22:31 
QuestionStatic OwnerDraw SS_OWNERDRAW DrawItem not being called Pin
ForNow7-Feb-22 14:53
ForNow7-Feb-22 14:53 
AnswerRe: Static OwnerDraw SS_OWNERDRAW DrawItem not being called Pin
Richard MacCutchan7-Feb-22 21:08
mveRichard MacCutchan7-Feb-22 21:08 
GeneralRe: Static OwnerDraw SS_OWNERDRAW DrawItem not being called Pin
Victor Nijegorodov7-Feb-22 22:49
Victor Nijegorodov7-Feb-22 22:49 
GeneralRe: Static OwnerDraw SS_OWNERDRAW DrawItem not being called Pin
Richard MacCutchan7-Feb-22 23:39
mveRichard MacCutchan7-Feb-22 23:39 
AnswerRe: Static OwnerDraw SS_OWNERDRAW DrawItem not being called Pin
Victor Nijegorodov7-Feb-22 22:42
Victor Nijegorodov7-Feb-22 22:42 
GeneralRe: Static OwnerDraw SS_OWNERDRAW DrawItem not being called Pin
ForNow8-Feb-22 1:23
ForNow8-Feb-22 1:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.