Reputation: 975
I created a clss name NRGroupBox to manage a custom GroupBox style. I had some helpers to add controls in the groupbox :
NRGroupBox
{
...
NRButton * CreateButton(std::string id, CRect position, std::string content);
NREdit * CreateEdit(std::string id, CRect position);
NRStatic * CreateStatic(std::string id, CRect position, std::string text);
NRComboBox * CreateComboBox(std::string id, CRect position);
...
std::map<std::string, NREdit * > edits;
std::map<std::string, NRStatic * > labels;
std::map<std::string, NRButton * > buttons;
std::map<std::string, NRComboBox * > comboBoxes;
...
}
Here is the code of one of the helper functions : (the four functions are quite similar)
NREdit * NRGroupBox::CreateEdit(std::string id, CRect position)
{
if(!edits.count(id))
{
NREdit * buff = new NREdit();
buff->Create(WS_CHILD | WS_VISIBLE, position, this, editIds++);
buff->MoveWindow(position);
edits[id] = buff;
}
return edits[id];
}
My problem is that when I call this function the edit box doesn't show, I need to call MoveWindow
outside the CreateEdit
function. I don't understand why I need to do this.
Here is an example of how I want to use NRGroupBox
and CreateEdit
function.
BOOL ConfigWindow::OnInitDialog()
{
if(!CDialog::OnInitDialog())
{
NRthrow("Impossible de créer la fenêtre");
return FALSE;
}
MoveWindow(0,0,800,800);
ShowWindow(SW_SHOW);
groupBox = new NRGroupBox();
groupBox->Create("Test GroupBox", CRect(0,0,500,500), this);
groupBox->SetNRStyle();
bouton = groupBox->CreateButton("bouton", CRect(230,60,100,20), "Test Bouton");
label = groupBox->CreateStatic("label", CRect(10,60,100,20), "Test label");
editBox = groupBox->CreateEdit("editBox", CRect(120,60,100,20));
// Actually I need those lines, but I don't want to need it.
//editBox->MoveWindow(120,60,100,20);
bouton->MoveWindow(230,60,100,20);
label->MoveWindow(10,60,100,20);
NRDebug::Notice("Création d'une fenêtre de Paramétrage");
return TRUE;
}
Thanks for your help
Upvotes: 1
Views: 98
Reputation: 10415
CRect(120,60,100,20)
You have the coordinates in the wrong order, with right < left and bottom < top
Upvotes: 1