Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

'Always on top' (VC++)

  • 03-06-2004 10:03am
    #1
    Registered Users, Registered Users 2 Posts: 1,253 ✭✭✭


    Hey lads and lassies,

    I have posted before about an application that I am developing. Well, heres another question (sorry if I am piling them on)...

    I want to make my MFC application to be 'always on top' as it will be used by my collegues in conjunction with another application.

    It would be useful if my application was always on top. That way my collegues could use their normal program and mine at the same time. (My program is small on the screen and therefore they would not interfear with each other).

    I found some code on the net and it is in my 'OnInitialUpdate()' function but it does not work. Here is the code:

    SetWindowPos(&this->wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

    I have looked at this function in the MFC help files but they dont shed any light on why it is not working. I think that maybe I have it in the wrong place or something. But I am not sure where it should go!

    Any sugestions?? (Thanks)


Comments

  • Registered Users, Registered Users 2 Posts: 1,423 ✭✭✭Merrion


    It Should probably be:
    SetWindowPos(&this->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
    


  • Registered Users, Registered Users 2 Posts: 1,253 ✭✭✭gobby


    Originally posted by Merrion
    It Should probably be:
    SetWindowPos(&this->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
    
    Hmmm... Tried it and I got a couple of compilation errors back.

    error C2039: 'hwnd' : is not a member of 'CSnapshotInformationView'
    error C2660: 'SetWindowPos' : function does not take 7 parameters


  • Registered Users, Registered Users 2 Posts: 1,372 ✭✭✭silverside


    try something like

    AfxGetMainWnd()->SetWindowPos(HWND_TOPMOST, etc... )


  • Registered Users, Registered Users 2 Posts: 1,253 ✭✭✭gobby


    Originally posted by silverside
    try something like

    AfxGetMainWnd()->SetWindowPos(HWND_TOPMOST, etc... )
    Excellent silverside. Did the job perfectly! Thanks a mill. :D


  • Registered Users, Registered Users 2 Posts: 1,253 ✭✭✭gobby


    Okay so since silverside has given me a solution another problem in the same area has arisen... :(

    Thw code silverside gave worked perfectly with one annoying problem. In my code a Browse for Folder dialog boy is implimented. ('SHBrowseForFolder()')

    Unfortunatly this Browse dialog box is underneath the 'Always On Top' dialog.

    I have looked into the problem and tbh I am not sure why this happens. I think that the Browse dialog is another thread (which is also annoying) but I have no idea how to get even a pointer to the dialog so that I can make it the 'Top Most' window.

    Can anybody give me some sugestions here!? :confused:


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,253 ✭✭✭gobby


    Ahhhh.... Isnt it much better when you solve a problem yourself. Simple solution too. Just had to specify that the previous window owned the browse dialog then it inherited the z order.

    :D:D


Advertisement