Results 1 to 10 of 10

Thread: Positioning a form right above the taskbar, but in the right corner?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Positioning a form right above the taskbar, but in the right corner?

    Hi there everyone. Earlier I was working on a form that centers in the middle of the bottom of the screen above the task bar. It works awesome, and the kindergarten kids love being able to reach the buttons.

    I was looking at another form, but wanted to put it above the task bar in the right corner.

    I found this code to help put it in the corner...

    VB Code:
    1. Me.Left = (Screen.Width - Me.Width)
    2.     Me.Top = (Screen.Height - Me.Height)

    This does put it in the corner, but it would be awesome if it was above the task bar.

    Would any one know how?

    Thanks!

  2. #2
    Hyperactive Member
    Join Date
    Oct 2013
    Posts
    389

    Re: Positioning a form right above the taskbar, but in the right corner?

    What you're looking for is an 'always on top' feature.

    this may help you:
    http://www.vbforums.com/showthread.p...-always-on-top

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Positioning a form right above the taskbar, but in the right corner?

    That is awesome. I added the code to let it stay always on top. Would you know how I can make the form move just above the taskbar? Just case it will block out the clock/date/the show desktop button.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Positioning a form right above the taskbar, but in the right corner?

    You are making the assumption that the taskbar is always at the bottom of the screen. That is probably true for a vast majority of users, but it can be moved. There is an API (SystemParametersInfo) that can tell you what part of the screen is not used up by the taskbar and other toolbars. A rectangle (RECT) structure is returned and you can align your window to anywhere within that rectangle and be pretty assured you won't be overlapping anything important.

    Suggest searching this forum for examples. Use this keyword in your search: SPI_GETWORKAREA
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Positioning a form right above the taskbar, but in the right corner?

    Quote Originally Posted by Justin M View Post
    Earlier I was working on a form that centers in the middle of the bottom of the screen above the task bar.

    . . .

    I was looking at another form, but wanted to put it above the task bar in the right corner.
    You only needed to modify a single line in that earlier code in order to achieve what you want. You'll have to change this:

    Code:
    X = (MI.rcMonitor.Right - MI.rcMonitor.Left - nWidth) \ 2&
    to this:

    Code:
    X = MI.rcMonitor.Right - MI.rcMonitor.Left - nWidth
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  6. #6
    Hyperactive Member
    Join Date
    Jun 2011
    Posts
    461

    Re: Positioning a form right above the taskbar, but in the right corner?

    VB Code:
    1. Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" ( _
    2. ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
    3. Private Const SPI_GETWORKAREA As Long = 48
    4. Private Type RECT
    5. lLeft As Long
    6. lTop As Long
    7. lRight As Long
    8. lBottom As Long
    9. End Type
    10.  
    11. Private Sub Form_Load()
    12. Dim deskRECT As RECT
    13. Call SystemParametersInfo(SPI_GETWORKAREA, 0&, deskRECT, 0&)
    14. Me.Move (deskRECT.lRight * Screen.TwipsPerPixelX) - Me.Width, _
    15. (deskRECT.lBottom * Screen.TwipsPerPixelY) - Me.Height
    16. End Sub

  7. #7
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Positioning a form right above the taskbar, but in the right corner?

    In the OP's previous thread, SPI_GETWORKAREA was already deemed unsuitable because the OP appears to be using more than 1 monitors.

    Quote Originally Posted by Justin M View Post
    I use a high one myself when I code, but the projectors at school use lower resolutions.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Positioning a form right above the taskbar, but in the right corner?

    Quote Originally Posted by Bonnie West View Post
    In the OP's previous thread, SPI_GETWORKAREA was already deemed unsuitable because the OP appears to be using more than 1 monitors.
    That API applies to the primary monitor only, but GetMonitorInfo API can be used for other than the primary monitor. That API also can return the work area available but additional APIs needed to determine which monitor. A non-VB example exists on MSDN
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Positioning a form right above the taskbar, but in the right corner?

    I also think that the mention of "projectors" does not mean that he has more than one connected at once but rather a general statement about the projectors used at the school. Of course it is possible that more than one is in use which if true does complicate things a bit, unless they are used in clone mode which would be the same to the program as just using a single screen.

  10. #10
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Positioning a form right above the taskbar, but in the right corner?

    Quote Originally Posted by LaVolpe View Post
    That API applies to the primary monitor only, but GetMonitorInfo API can be used for other than the primary monitor. That API also can return the work area available but additional APIs needed to determine which monitor.
    Exactly. And that's the reason I offered "a more robust alternative".

    Quote Originally Posted by DataMiser View Post
    I also think that the mention of "projectors" does not mean that he has more than one connected at once but rather a general statement about the projectors used at the school. Of course it is possible that more than one is in use which if true does complicate things a bit, unless they are used in clone mode which would be the same to the program as just using a single screen.
    I was assuming that Justin was using at least 2 output devices: a laptop (?) and a projector. Based on his statement that the projector's resolution was lower than his laptop's, I surmised that the projector wasn't just a clone of the main laptop display.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

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