Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Place vb6 form above System Tray

Posted on 2009-04-03
7
Medium Priority
?
529 Views
Last Modified: 2013-11-25
Dear

I need to Place one Form in Vb6 Just above System Tray with 6 cm in length and 2.5 cm in width.
Any suggestions, Need Help
With Thankx and Regards
0
Comment
Question by:Showkatdar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 31

Expert Comment

by:Frosty555
ID: 24062352
Use Screen.Width and Screen.Height to get the size of the screen.

Then position your form at:
    Form1.Width = Screen.Width - Form1.Width - 15
    Form1.Height = Screen.Height - Form1.Height - 50

Tweak the number at the end to take into account borders on your form, and the taskbar at the bottom of the screen.

Then you can size your form to be whatever size you like and it should appear in the bottom right corner.

You may also want to set your borderstyle to "None" or "Toolbar" so that the border isn't quite as thick and in the way.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 24062812
Using Screen.XXX alone may actually put your form on TOP of the System TaskBar and/or other DeskBands that are running.  What if the TaskBar is made bigger (taller) or they have other such apps running?   What if the TaskBar is dragged to the Top of the screen?  Then your app will be in the bottom right but not flush with the edges...

To properly place your form in the bottom right without obscuring the TaskBar/DeskBands you need to use the SystemParametersInfo() API with the SPI_GETWORKAREA flag:
http://msdn.microsoft.com/en-us/library/ms724947(VS.85).aspx

    SPI_GETWORKAREA: Retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars.

An Example:
Option Explicit
 
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
 
Private Const SPI_GETWORKAREA = 48
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
 
Private Sub Form_Load()
    Dim desktopRect As RECT
    Dim formHeight As Single
    Dim formWidth As Single
 
    formHeight = 150 ' desired height of form in pixels
    formWidth = 150 ' desired width of form in pixels
    Call SystemParametersInfo(SPI_GETWORKAREA, vbNull, desktopRect, 0)
    Call SetWindowPos(Me.hwnd, 0, desktopRect.Right - formWidth, desktopRect.Bottom - formHeight, formWidth, formHeight, 0)
End Sub

Open in new window

0
 

Author Comment

by:Showkatdar
ID: 24062872
Dear Idle Mind,

Thanks for your reply. It is working fine. I accept your reply but need one more little help if you could. Is there any way to give some Effects to this form. Like 3d, or something other than that, should be Interactive.
Thank you and Regards
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24062973
Sorry.  I don't have any recommendations for making the form "prettier"...I code plain looking apps.  =)

Maybe Frosty has some ideas?...
0
 

Author Closing Comment

by:Showkatdar
ID: 31566330
OK Thankx For your wonderful help. It is working. Thankx.
0
 
LVL 31

Expert Comment

by:Frosty555
ID: 24064800
I don't know what you mean by 3D effects, but there are a number of utilities out there to let you "skin" a vb6 form (make it non-rectangular).

See this EE question:
http://www.experts-exchange.com/Programming/Languages/Q_20358281.html

This example:
http://www.freevbcode.com/ShowCode.Asp?ID=1813
0
 
LVL 31

Expert Comment

by:Frosty555
ID: 24064813
Making your form "Always On Top":


-------------------- FORM1.FRM ------------------------
 
Private Sub Command1_Click()
If (MsgBox("Should The Window Be Topmost?", vbQuestion+vbYesNo,"Question") = vbYes) Then
' Set Window to Topmost
SetTopmost(Me, True)
Else
' Cancel Topmost
SetTopmost(Me, False)
End If
End Sub
 
 
 
-------------------- ALWAYSONTOP.BAS -------------------
 
 
Option Explicit
Global ipbans As String
 
Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
    ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
    ByVal cx As Long, ByVal cy As Long, ByVal uFlags As Long) As Long
    
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
 
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOACTIVATE = &H10
 
Public Sub SetTopmost(Form As Form, ByVal Topmost As Boolean)
    Dim hWndInsertAfter As Long
    
    If Topmost Then
        hWndInsertAfter = HWND_TOPMOST
    Else
        hWndInsertAfter = HWND_NOTOPMOST
    End If
    
    SetWindowPos Form.hWnd, hWndInsertAfter, 0, 0, 0, 0, _
        SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE
End Sub

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question