CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Posts
    20

    trouble w/SetWindowPos

    1. CFormView derived class has a button that opens a CRecordView derived class.
    2. In the CRecordView OnInitDlg, I call SetWindowPos(&wndTop, 0, 0, 0, 0,SWP_NOMOVE|SWP_NOSIZE) to try to move the CRecordView derived class to the top of the z-order. This call return non-zero value, which, according to msdn docs, means it was successful.
    3. CFormView window is still top window in z-order.

    I want the CRecordView to draw on top of the CFormView. Can someone tell me what I'm doing wrong?

    Thanks,
    -Brian

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757
    Weird. Consider adding SWP_SHOWWINDOW to the last parameter.

    Kuphryn

  3. #3
    Join Date
    Jan 2003
    Posts
    20
    The really weird thing is that I have another CRecordView derived class that opens a different recordset when a button is pressed on the CFormView derived class. It opens on top! Everything seems to be the same between the two, but one behaves differently.

    I must have done something subtley different when I created this view. I'll try recreating it to see if that helps.

    Even doing the following trick doesn't work:
    //Attach foreground window thread
    //to our thread
    DWORD ForeGroundID = GetWindowThreadProcessId(::GetForegroundWindow(),NULL);
    DWORD CurrentID = GetCurrentThreadId();
    AttachThreadInput ( ForeGroundID, CurrentID, TRUE );

    //Do our stuff here ;-)
    SetActiveWindow()
    SetForegroundWindow()
    SetFocus(); //Just playing safe

    //Detach the attached thread
    AttachThreadInput ( ForeGroundID, CurrentID, FALSE );

    The call to SetActiveWindow returns 0! Something weird is going on...

    -Brian

  4. #4
    Join Date
    Feb 2002
    Posts
    5,757
    What if you called SetWindowPos() from its parent?

    Kuphryn

  5. #5
    Join Date
    Jan 2003
    Posts
    20
    Thanks for your help, Kuphryn. I just figured out how to get the correct behavior:

    code was:
    pEmailDocTemplate->OpenDocumentFile(NULL);
    ((CDialog*) this)->GotoDlgCtrl(GetDlgItem(IDC_PRINTEMAIL));

    I'm still learning about the this operator, but my call order is a no-no. If I make the default button call before OpenDocumentFile, it works correctly. This is a case where you probably could have told me the problem if I gave more code...

    code should be:
    ((CDialog*) this)->GotoDlgCtrl(GetDlgItem(IDC_PRINTEMAIL));
    pEmailDocTemplate->OpenDocumentFile(NULL);

    -Brian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured