Click here to Skip to main content
15,894,314 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: How do I segment an image in different colors? Pin
Tim Craig10-Apr-10 19:32
Tim Craig10-Apr-10 19:32 
AnswerRe: How do I segment an image in different colors? Pin
Saurabh.Garg11-Apr-10 2:04
Saurabh.Garg11-Apr-10 2:04 
AnswerRe: How do I segment an image in different colors? Pin
@Intersect☺™12-Apr-10 20:50
professional@Intersect☺™12-Apr-10 20:50 
QuestionIPersistFile::Save fails Error Access Denied Pin
ShilpiP10-Apr-10 17:56
ShilpiP10-Apr-10 17:56 
AnswerRe: IPersistFile::Save fails Error Access Denied Pin
Adam Roderick J10-Apr-10 20:59
Adam Roderick J10-Apr-10 20:59 
GeneralRe: IPersistFile::Save fails Error Access Denied Pin
ShilpiP11-Apr-10 5:52
ShilpiP11-Apr-10 5:52 
QuestionUsing a Dialog as a Control in another Dialog Pin
Bram van Kampen10-Apr-10 17:24
Bram van Kampen10-Apr-10 17:24 
AnswerRe: Using a Dialog as a Control in another Dialog Pin
Gary R. Wheeler11-Apr-10 1:14
Gary R. Wheeler11-Apr-10 1:14 
I do this a lot in one of my older applications. Suppose your two dialogs are IDD_MAIN and IDD_SUB, with corresponding MFC classes CMainDlg and CSubDlg. The resource for the sub dialog should have the following styles set: Border=None, Style=Child, and Control=True. This will let the sub dialog visually blend into the main dialog.

The basic approach is to use the sub as a modeless dialog whose parent is the main dialog. You then need something like this to get it going:
BOOL CMainDlg::OnInitDialog()
{
    // create sub-dialog
    CSubDlg *sub = new CSubDlg(CSubDlg::IDD,this);
    sub->Create(CSubDlg::IDD,this);
    sub->MoveWindow(10,10,100,100);
    sub->ShowWindow(SW_SHOW);
}
Obviously, there are lots of ways this needs to be fancied up. You probably want this sub-dialog positioned relative to other controls. What I usually do is place a static control where I want the sub-dialog to go, and then position the sub-dialog using logic like this:
// create sub-dialog
CSubDlg *sub = new CSubDlg(CSubDlg::IDD,this);
sub->Create(CSubDlg::IDD,this);
CRect sub_rect;
GetDlgItem(IDC_SUB_DIALOG)->GetWindowRect(&sub_rect);
ScreenToClient(&sub_rect);
GetDlgItem(IDC_SUB_DIALOG)->DestroyWindow();
sub->SetDlgCtrlID(IDC_SUB_DIALOG);
sub->MoveWindow(&sub_rect);
This logic does several things: it gets the position of the static control, destroys it, and then places the sub dialog in the same position. As a final refinement, it assigns the control ID to the sub dialog.

Note that, for completeness, you really should save the pointer to the sub dialog instance as a member of the main dialog class, and delete it in that class' PostNcDestroy().
Software Zen: delete this;
Fold With Us![^]

GeneralRe: Using a Dialog as a Control in another Dialog Pin
Bram van Kampen11-Apr-10 2:13
Bram van Kampen11-Apr-10 2:13 
GeneralRe: Using a Dialog as a Control in another Dialog Pin
Gary R. Wheeler11-Apr-10 13:22
Gary R. Wheeler11-Apr-10 13:22 
QuestionProblem with reading big amount of numbers from file Pin
vonpik10-Apr-10 13:18
vonpik10-Apr-10 13:18 
QuestionRe: Problem with reading big amount of numbers from file Pin
Tim Craig10-Apr-10 13:46
Tim Craig10-Apr-10 13:46 
AnswerRe: Problem with reading big amount of numbers from file Pin
vonpik10-Apr-10 14:11
vonpik10-Apr-10 14:11 
GeneralRe: Problem with reading big amount of numbers from file Pin
Tim Craig10-Apr-10 19:37
Tim Craig10-Apr-10 19:37 
GeneralRe: Problem with reading big amount of numbers from file Pin
vonpik11-Apr-10 12:16
vonpik11-Apr-10 12:16 
QuestionRe: Problem with reading big amount of numbers from file Pin
David Crow11-Apr-10 15:54
David Crow11-Apr-10 15:54 
AnswerRe: Problem with reading big amount of numbers from file Pin
vonpik13-Apr-10 10:05
vonpik13-Apr-10 10:05 
GeneralRe: Problem with reading big amount of numbers from file Pin
David Crow13-Apr-10 10:16
David Crow13-Apr-10 10:16 
GeneralRe: Problem with reading big amount of numbers from file Pin
vonpik16-Apr-10 3:43
vonpik16-Apr-10 3:43 
GeneralRe: Problem with reading big amount of numbers from file Pin
David Crow16-Apr-10 4:41
David Crow16-Apr-10 4:41 
Rant(*&#@*!^ Templates PinPopular
Tim Craig9-Apr-10 20:40
Tim Craig9-Apr-10 20:40 
GeneralWelcome Pin
CPallini10-Apr-10 4:43
mveCPallini10-Apr-10 4:43 
GeneralRe: Welcome Pin
Tim Craig10-Apr-10 21:30
Tim Craig10-Apr-10 21:30 
GeneralRe: (*&#@*!^ Templates Pin
Gary R. Wheeler11-Apr-10 1:31
Gary R. Wheeler11-Apr-10 1:31 
GeneralRe: (*&#@*!^ Templates Pin
Tim Craig11-Apr-10 9:36
Tim Craig11-Apr-10 9:36 

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.