Click here to Skip to main content
15,899,026 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to start another application and run it within another application Pin
Kiran Satish4-Oct-04 7:14
Kiran Satish4-Oct-04 7:14 
GeneralRe: How to start another application and run it within another application Pin
Muhammad Azam4-Oct-04 21:44
Muhammad Azam4-Oct-04 21:44 
GeneralRe: How to start another application and run it within another application Pin
Kiran Satish5-Oct-04 14:11
Kiran Satish5-Oct-04 14:11 
GeneralRe: How to start another application and run it within another application Pin
Muhammad Azam5-Oct-04 20:24
Muhammad Azam5-Oct-04 20:24 
GeneralExitProcess Pin
elephantstar28-Sep-04 12:58
elephantstar28-Sep-04 12:58 
GeneralRe: ExitProcess Pin
Antti Keskinen28-Sep-04 18:01
Antti Keskinen28-Sep-04 18:01 
GeneralRe: ExitProcess Pin
elephantstar29-Sep-04 7:23
elephantstar29-Sep-04 7:23 
GeneralInvalid CTempWnd problem Pin
PJ Arends28-Sep-04 12:57
professionalPJ Arends28-Sep-04 12:57 
Hey all, I am having a problem when given a CTempWnd pointer to a deleted window.

I have developed CButton derived class that is supposed to, when clicked, return the input focus to the window that had it before it was clicked. I do this by saving the HWND of the window that is passed into the OnSetFocus() function, and set the focus back to it in the BN_CLICKED message handler.
void COneClickButton::OnSetFocus(CWnd *pOldWnd)
{
    CButton::OnSetFocus(pOldWnd);
 
    // pass along the focus from window handle
    COneClickButton *pOCB = dynamic_cast<COneClickButton *>(pOldWnd);
    m_hFocusFromWnd = *pOCB ? pOCB->m_hFocusFromWnd : *pOldWnd;
}

BOOL COneClickButton::OnClicked()
{
    if (IsWindow(m_hFocusFromWnd))
        ::SetFocus(m_hFocusFromWnd);
    else
        GetParent()->SetFocus();
 
    return FALSE; // pass BN_CLICKED onto parent
}
Ok, that was the easy part. Now comes the fun part that I am having a problem with.

I am using Chris's MFCGrid on a CPropertyPage, with several COneClickButton buttons on the property sheet. The problem comes when the user is editing a cell on the grid and then clicks one of the buttons while the edit window is still open. The CInPlaceEdit class that the grid uses for editing has a feature where by it closes and deletes itself as soon as it loses the input focus, which is all fine and well. But now, when the COneClickButton gets the focus, the pOldWnd pointer points to a now invalid window and the button has no idea where to return the focus. Currently I just set the focus to the property sheet, which passes the focus to the first control on the page. I want the focus to go back to the MFCGrid.

Anybody have any ideas on how to accomplish this, short of handling WM_SETFOCUS messages for every control in my app?








"You're obviously a superstar." - Christian Graus about me - 12 Feb '03

"Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04

Within you lies the power for good - Use it!
GeneralRe: Invalid CTempWnd problem Pin
Antti Keskinen28-Sep-04 18:08
Antti Keskinen28-Sep-04 18:08 
GeneralRe: Invalid CTempWnd problem Pin
PJ Arends29-Sep-04 6:21
professionalPJ Arends29-Sep-04 6:21 
GeneralRe: Invalid CTempWnd problem Pin
Antti Keskinen29-Sep-04 6:40
Antti Keskinen29-Sep-04 6:40 
GeneralDatabase replication - network and island Pin
Ted Christiansen28-Sep-04 11:56
Ted Christiansen28-Sep-04 11:56 
GeneralRe: Database replication - network and island Pin
ssanoj29-Sep-04 9:59
ssanoj29-Sep-04 9:59 
GeneralSetForegroundWindow fails Pin
Neville Franks28-Sep-04 11:47
Neville Franks28-Sep-04 11:47 
GeneralRe: SetForegroundWindow fails Pin
vcplusplus28-Sep-04 12:14
vcplusplus28-Sep-04 12:14 
GeneralRe: SetForegroundWindow fails Pin
vcplusplus28-Sep-04 12:30
vcplusplus28-Sep-04 12:30 
GeneralRe: SetForegroundWindow fails Pin
Neville Franks28-Sep-04 13:07
Neville Franks28-Sep-04 13:07 
GeneralRe: SetForegroundWindow fails Pin
Neville Franks28-Sep-04 13:42
Neville Franks28-Sep-04 13:42 
GeneralRe: SetForegroundWindow fails Pin
Scott H. Settlemier28-Sep-04 14:46
Scott H. Settlemier28-Sep-04 14:46 
GeneralRe: SetForegroundWindow fails Pin
Neville Franks28-Sep-04 15:15
Neville Franks28-Sep-04 15:15 
GeneralRe: SetForegroundWindow fails Pin
Phil J Pearson29-Sep-04 3:49
Phil J Pearson29-Sep-04 3:49 
GeneralRe: SetForegroundWindow fails Pin
Neville Franks29-Sep-04 10:34
Neville Franks29-Sep-04 10:34 
GeneralRe: SetForegroundWindow fails Pin
Phil J Pearson29-Sep-04 10:53
Phil J Pearson29-Sep-04 10:53 
GeneralRe: SetForegroundWindow fails Pin
Neville Franks29-Sep-04 11:04
Neville Franks29-Sep-04 11:04 
GeneralRe: SetForegroundWindow fails Pin
Phil J Pearson30-Sep-04 7:10
Phil J Pearson30-Sep-04 7:10 

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.