CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    1

    Topmost modeless dlg

    I tried all of this
    CWnd::SetWindowPos(NULL, rect.left, rect.top, rect.bottom, rect.right, WS_EX_TOPMOST );
    CWnd::SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.bottom, rect.right, WS_EX_TOPMOST );
    CWnd::SetWindowPos(&CWnd::wndTop, rect.left, rect.top, rect.bottom, rect.right, WS_EX_TOPMOST );

    Nothing worked and I am getting very wierd result using number 3





  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Topmost modeless dlg

    Why are you using WS_EX_TOPMOST? This is a style used when the window is *created*.

    You are using the wrong constants for SetWindowPos. In the on-line help for SetWindowPos, the constants that describe the operations are clearly stated:

    SWP_NOMOVE
    SWP_NOSIZE
    SWP_NOZORDER
    SWP_NOREDRAW
    SWP_NOACTIVATE
    SWP_SHOWWINDOW
    SWP_DRAWFRAME
    SWP_HIDEWINDOW

    Regards,

    Paul McKenzie


  3. #3
    Join Date
    Aug 1999
    Posts
    11

    Re: Topmost modeless dlg

    I would like to point out that the original user is following microsofts suggestion and The second response is wrong. On the online
    MSDN help for visual c 6.0 Go to the page that explains the extended styles, you will see:

    *WS_EX_TOPMOST Specifies that a window created with this style should be placed above all
    nontopmost windows and stay above them even when the window is deactivated. An application
    can use the SetWindowPos member function to add or remove this attribute.

    Now, that is pretty self explainatory. I have been trying to use ModifyWindowEx which has
    not worked yet, but I haven't tried using this out yet.




  4. #4
    Join Date
    Aug 1999
    Posts
    11

    Re: Topmost modeless dlg

    I figured out how to get this to work, here is a snippet of my code. val is mapped to a checkbox that determines
    whether or not to make a dialog topmost or not. The GetWindowRect gets the current upper left and bottom right
    coordinates of the dialog. Note that people who put the WM_EX_TOPMOST at the end of the SetWindowPos
    function will notice redraw problems. I haven't checked yet but I suspect that both WM_EX_TOPMOST and
    SWP_NOREDRAW probably share enough of the same bits to cause that to occur. Hope this helps.

    GetWindowRect(winRect);
    if( val==1 )
    { saveValue = "ON";

    SetWindowPos(&wndTopMost,winRect.left,winRect.top,winRect.Width(),winRect.Height(),NULL);
    }
    else
    { saveValue = "OFF";
    SetWindowPos(&wndNoTopMost,winRect.left,winRect.top,winRect.Width(),winRect.Height(),NULL);

    }


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