Thread: always on top?

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    10

    Exclamation always on top?

    bah i can never remeber the code to make a program always on top, if someone could give me the code for it ill write it down this time,

    using microsoft visual studio

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    In your WndProc:

    Code:
    case WM_KILLFOCUS:
      SetFocus(hwnd);//or handle to whatever window u want
      break;

  3. #3
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    This sounds like a virus.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    He didn't ask for code for a window that keeps focus, he asked for how to make a window stay on top.... hardly sounds like virus like activity to me! if that's the case, then the task manager is a virus!

    you need to have a look at the SetWindowPos() function:

    Code:
    SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    hope this helps
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    10

    Cool

    its not a virus, im not into those....anymore
    i just need to make a program that will open and close the cd-rom when you push shift-F11, my open and close button is hard to get to with the way my comptuer is setup (i have a really really cramped little space for all my stuff), so this would make it much much easier on me

  6. #6
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Ok sorry about that.
    But if it just stayed on top you would have to click it first and then press shift+F11 for it to recieve the message.

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    10
    so then i would have to set focus to it too?

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Or use 'default button' style so ENTER or SPACEBAR will click it.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  9. #9
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    even with the default button style the window needs to have focus.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  10. #10
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    Or you could map a hotkey to your prog and have that give focus. Then open and close the CD whenever you get/lose focus. Just a thought.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to make opengl draw in lighter colors ?
    By jabka in forum Game Programming
    Replies: 2
    Last Post: 12-17-2007, 06:12 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. OpenGL, loading BMP Textures?
    By Zeusbwr in forum Game Programming
    Replies: 12
    Last Post: 12-09-2004, 05:16 PM
  4. Odd 3D Invis Objects?
    By Zeusbwr in forum Game Programming
    Replies: 4
    Last Post: 12-07-2004, 07:01 PM
  5. Stack functions as arrays instead of node pointers
    By sballew in forum C Programming
    Replies: 8
    Last Post: 12-04-2001, 11:13 AM