Click here to Skip to main content
15,907,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionShow and close dialog Pin
trunghd15-Nov-05 22:34
trunghd15-Nov-05 22:34 
AnswerRe: Show and close dialog Pin
Steen Krogsgaard15-Nov-05 22:46
Steen Krogsgaard15-Nov-05 22:46 
GeneralRe: Show and close dialog Pin
trunghd16-Nov-05 0:25
trunghd16-Nov-05 0:25 
GeneralRe: Show and close dialog Pin
toxcct16-Nov-05 0:56
toxcct16-Nov-05 0:56 
GeneralRe: Show and close dialog Pin
Steen Krogsgaard16-Nov-05 1:34
Steen Krogsgaard16-Nov-05 1:34 
AnswerRe: Show and close dialog Pin
Rage15-Nov-05 23:08
professionalRage15-Nov-05 23:08 
GeneralRe: Show and close dialog Pin
trunghd16-Nov-05 0:23
trunghd16-Nov-05 0:23 
GeneralRe: Show and close dialog Pin
Rage16-Nov-05 1:54
professionalRage16-Nov-05 1:54 
trunghd wrote:
I use Create()& SetWindowPos functions to put the new dialog at the bottom of this button.
Firstly, I've tried to use OnKillFocus to check when the dialog lost focus but I always get WM_KILLFOCUS message immediately after SetWindowPos function. So the dialog disappear immediately after appear.


Ok, this explains why OnKillFocus is not our solution here.


trunghd wrote:
I've tried to catch WM_ACTIVATE


I still do not know if you are using MFC, but I will assume it. If not, post back and i'll give you the plain Win32 code.

So override the WM_ACTIVATE message (I guess you know how to do, if not : Right-click on your dlg class in the class borwser, [Add Windows MEssage Handler], Set [Filter for messages available to class] (on the bottom right) combo box on [Window], Select WM_ACTIVATE in the left listctrl and Click Add Handler button).

Then

void CYourDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
		
	if ((WM_INACTIVE == nState ) && (pWndOther == FromHandle(m_hWnd))
        { 
            // Here dismiss your dialog, for instance: CDialog::OnClose();
            
        }
        else
        { 
          CDialog::OnActivate(nState, pWndOther, bMinimized);
        }
	
} 


~RaGE();

-- modified at 7:56 Wednesday 16th November, 2005
Questionneed help Pin
toufiq_raja15-Nov-05 20:42
toufiq_raja15-Nov-05 20:42 
AnswerRe: need help Pin
Michael P Butler15-Nov-05 21:05
Michael P Butler15-Nov-05 21:05 
GeneralRe: need help Pin
toufiq_raja16-Nov-05 18:43
toufiq_raja16-Nov-05 18:43 
AnswerRe: need help Pin
toxcct15-Nov-05 22:07
toxcct15-Nov-05 22:07 
GeneralRe: need help Pin
toufiq_raja16-Nov-05 23:14
toufiq_raja16-Nov-05 23:14 
GeneralRe: need help Pin
toxcct17-Nov-05 2:21
toxcct17-Nov-05 2:21 
GeneralRe: need help Pin
toufiq_raja20-Nov-05 20:08
toufiq_raja20-Nov-05 20:08 
QuestionHow to use CByteArray to store and retrieve pictures Pin
snprani15-Nov-05 20:02
snprani15-Nov-05 20:02 
QuestionHow To set tab order at runtime using SetWindowPos() so as to shift the focus from one edit box to another edit box(of any control) when down arrow button pressed Pin
zxc8915-Nov-05 19:44
zxc8915-Nov-05 19:44 
AnswerRe: How To set tab order at runtime using SetWindowPos() so as to shift the focus from one edit box to another edit box(of any control) when down arrow button pressed Pin
Rage15-Nov-05 21:02
professionalRage15-Nov-05 21:02 
GeneralRe: How To set tab order at runtime using SetWindowPos() so as to shift the focus from one edit box to another edit box(of any control) when down arrow button pressed Pin
dabs15-Nov-05 22:27
dabs15-Nov-05 22:27 
AnswerRe: How To set tab order at runtime using SetWindowPos() so as to shift the focus from one edit box to another edit box(of any control) when down arrow button pressed Pin
Owner drawn15-Nov-05 23:52
Owner drawn15-Nov-05 23:52 
QuestionExtracing data from word document to notepad or edit box Pin
Ankush Mehta15-Nov-05 19:41
Ankush Mehta15-Nov-05 19:41 
AnswerRe: Extracing data from word document to notepad or edit box Pin
Rage15-Nov-05 21:06
professionalRage15-Nov-05 21:06 
AnswerRe: Extracing data from word document to notepad or edit box Pin
Barm15-Nov-05 21:20
Barm15-Nov-05 21:20 
AnswerRe: Extracing data from word document to notepad or edit box Pin
grigsoft15-Nov-05 21:54
grigsoft15-Nov-05 21:54 
QuestionCompiler warning Pin
Raza568015-Nov-05 18:39
Raza568015-Nov-05 18:39 

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.