Click here to Skip to main content
15,914,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionLogOff User from a Service running as System Pin
Gurkenscheibe13-Apr-07 10:44
Gurkenscheibe13-Apr-07 10:44 
Questionwhich one is parent? Pin
iayd13-Apr-07 9:02
iayd13-Apr-07 9:02 
AnswerRe: which one is parent? Pin
Wes Aday13-Apr-07 9:54
professionalWes Aday13-Apr-07 9:54 
QuestionRe: which one is parent? Pin
Maximilien13-Apr-07 9:56
Maximilien13-Apr-07 9:56 
AnswerRe: which one is parent? Pin
CPallini13-Apr-07 10:10
mveCPallini13-Apr-07 10:10 
AnswerRe: which one is parent? Pin
CPallini13-Apr-07 10:06
mveCPallini13-Apr-07 10:06 
AnswerRe: which one is parent? Pin
bob1697213-Apr-07 10:10
bob1697213-Apr-07 10:10 
AnswerRe: which one is parent? Pin
JudyL_MD13-Apr-07 10:14
JudyL_MD13-Apr-07 10:14 
This example is MFC

In each parent, create the child like:
CChildDlg childDlg (this)
This will pass the parent CWnd to the child and the standard MFC implementation will store the CWnd pointer.

In the child, when something occurs that has to be sent back to the parent, simply do:
GetParent ()->PostMessage (build whatever message and parameters you need)

If the child really cares about _which_ parent called him, modify the child's constructor to include another parameter and pass in an indicator that the child can store in its member variables that shows who created the child.
CChildDlg childDlg (this, flag_value)
Now, in the child, when you want to call into a specific parent, cast the parent CWnd pointer to the appropriate parent class based on the flag
if (flag_value == parent_1)<br />
{<br />
Dlg1 *pDlg = (Dlg1 *) GetParent ();<br />
// use pDlg<br />
}<br />
else if (flag_value == parent_2)<br />
{<br />
Dlg2 *pDlg = (Dlg2 *) GetParent ();<br />
// use pDlg<br />
}<br />
else<br />
// you get the idea


You need to be careful when you call back into another window class that you don't do things that may cause your window to redraw. In general, it is much better to post a windows message than it is to call directly when communicating between windows.

Judy
GeneralRe: which one is parent? Pin
iayd13-Apr-07 11:15
iayd13-Apr-07 11:15 
Questionhard disk serial number in vista Pin
viral_umang@hotmail.com13-Apr-07 8:59
viral_umang@hotmail.com13-Apr-07 8:59 
AnswerRe: hard disk serial number in vista Pin
bob1697213-Apr-07 9:58
bob1697213-Apr-07 9:58 
QuestionRe: hard disk serial number in vista Pin
viral_umang@hotmail.com13-Apr-07 10:16
viral_umang@hotmail.com13-Apr-07 10:16 
AnswerRe: hard disk serial number in vista Pin
bob1697213-Apr-07 10:45
bob1697213-Apr-07 10:45 
QuestionWhat happens if client CSocket does not process/clear returned package? Pin
zipliu13-Apr-07 5:04
zipliu13-Apr-07 5:04 
AnswerRe: What happens if client CSocket does not process/clear returned package? Pin
Mark Salsbery13-Apr-07 7:28
Mark Salsbery13-Apr-07 7:28 
GeneralRe: What happens if client CSocket does not process/clear returned package? Pin
zipliu13-Apr-07 9:03
zipliu13-Apr-07 9:03 
GeneralRe: What happens if client CSocket does not process/clear returned package? Pin
Mark Salsbery13-Apr-07 11:15
Mark Salsbery13-Apr-07 11:15 
GeneralRe: What happens if client CSocket does not process/clear returned package? Pin
zipliu13-Apr-07 9:04
zipliu13-Apr-07 9:04 
Questiongroup policy- pls help me Pin
deeps_cute13-Apr-07 5:02
deeps_cute13-Apr-07 5:02 
QuestionApply header programmatically Pin
Al_Pennyworth13-Apr-07 4:23
Al_Pennyworth13-Apr-07 4:23 
AnswerRe: Apply header programmatically Pin
Roger Stoltz13-Apr-07 4:44
Roger Stoltz13-Apr-07 4:44 
AnswerRe: Apply header programmatically Pin
Cedric Moonen13-Apr-07 4:50
Cedric Moonen13-Apr-07 4:50 
AnswerRe: Apply header programmatically Pin
krmed13-Apr-07 5:33
krmed13-Apr-07 5:33 
AnswerRe: Apply header programmatically Pin
Al_Pennyworth13-Apr-07 8:07
Al_Pennyworth13-Apr-07 8:07 
AnswerRe: Apply header programmatically Pin
Michael Dunn13-Apr-07 8:43
sitebuilderMichael Dunn13-Apr-07 8:43 

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.