?
Solved

Show in taskbar

Posted on 2004-04-05
6
Medium Priority
?
620 Views
Last Modified: 2011-09-20
Hi, i've created a program using VB in excel. I know there are a lot of major drawbacks to using it but we don't have VB in the work, this may be one of those drawbacks. At the beginning i have hidden the application so that all that is on the screen is my program. However because i have hidden the application the taskbar icon has been done away with and i have no way to just click on it if it gets lost to the back of a window. I have toyed with minimizing the application but it minimizes my form and i also thought about keeping my form on top but decided against that as what i really want is just to be able to click on an icon in the taskbar and for it to jump to the front again as with all other windows/applications. If its possible, could you tell me how to do this?

I know its probably not possible and if it is its probably so simple but i'm just a beginner so sorry if i'm wasting your time.

Thanks

Scott
0
Comment
Question by:scotster
[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
  • 2
  • 2
  • 2
6 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10763302
Hmm... what exactly are you trying to do?

1.) You hide the application (Excel?) but keep your program (forms?) visible.
2.) Since the application (Excel?) is hidden, you can't bring it back. How would you be able to "click on it if it gets lost" if it's hidden?

Confusing.. maybe because it's 2am. :D
0
 
LVL 28

Expert Comment

by:Ark
ID: 10763665
Probably you can use following solutions:
1. Tray icon (area at the bottom right corner, where clocks, sound icon, MSN messenger etc seats).
2. Using hot-key combination when user press, say, Ctrl+Alt+P keys? your app brings to top.

or combination of above 2 ways
0
 

Author Comment

by:scotster
ID: 10780518
How would i create a trayicon with my form? I think i tried it using VB but i've never tried it with VB in excel. That would be fine if that would work. As you can tell i am self taught and this far have only had the "help" option as a guide. Oh and here of course.

BTW zzzzzooc its not excel i want to be able to click on if it gets lost  i want an icon for the form on the taskbar for the form that comes up called calib1. Example would be excel loads, shows in taskbar click enable macro's excel disappears calib1 shows. I'd like to have an icon in the taskbar for calib1. After a bit of reading i have found that its virtually impossible to have a showintaskbar for the form as it would only work for excel when using vb in an application. Something to do with child windows or something like that.

Thanks

Scotster
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10780593
Not sure if this can work from VBA in Excel but you can try setting your form's (if it even has a handle?) extended style to be that of one that shows up in the taskbar.


Example..

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_APPWINDOW = &H40000
Private Sub Form_Load()
    Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW)
End Sub
0
 
LVL 28

Accepted Solution

by:
Ark earned 200 total points
ID: 10781537
It'll work on all windows including VBA excell/word etc. forms, though (IMHO)
Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_APPWINDOW)
will be better :)

As for Icon in Tray:

Option Explicit
Private Declare Function Shell_NotifyIcon _
Lib "shell32.dll" Alias _
"Shell_NotifyIconA" (ByVal dwMessage As Long, _
lpData As NOTIFYICONDATA) _
As Long

Private Type NOTIFYICONDATA
   cbSize As Long
   hwnd As Long
   uID As Long
   uFlags As Long
   uCallbackMessage As Long
   hIcon As Long
   szTip As String * 64
End Type
Private Const NIM_ADD = &H0 ' add icon
Private Const NIM_DELETE = &H2 ' remove icon
Private Const NIF_MESSAGE = &H1 ' use messages
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4

Private Const NIF_FLAG = NIF_MESSAGE Or NIF_ICON Or NIF_TIP

'Messages
Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Const WM_RBUTTONDBLCLK = &H206
Private Const WM_MBUTTONDOWN = &H207
Private Const WM_MBUTTONUP = &H208
Private Const WM_MBUTTONDBLCLK = &H209

Private Icn As NOTIFYICONDATA

Private Sub Form_Resize()
   If Me.WindowState = vbMinimized Then
      With Icn
         .cbSize = Len(Icn)
         .hwnd = Picture1.hwnd
         .uID = 1
         .uFlags = NIF_FLAG 'вот и наша константа,
         .uCallbackMessage = WM_MOUSEMOVE
         .hIcon = Picture1.Picture
      End With
      Shell_NotifyIcon NIM_ADD, Icn ' add icon
      Me.Hide 'Hide form
   End If
End Sub

Private Sub mnuMainExit_Click()
'Your pop-up menu - exit member
   Shell_NotifyIcon NIM_DELETE, Icn
   Unload Me
   End
End Sub

Private Sub mnuMainShow_Click()
'Your pop-up menu - show member
   Me.WindowState = vbNormal
   Me.Show
   Shell_NotifyIcon NIM_DELETE, Icn
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
X = X / Screen.TwipsPerPixelX
Select Case X
Case WM_LBUTTONDOWN
    'Code for left button click. Probably mnuMainShow_Click
Case WM_RBUTTONDOWN
    Me.PopupMenu mnuMain
Case WM_MOUSEMOVE
Case WM_LBUTTONDBLCLK
Case WM_RBUTTONUP
Case WM_RBUTTONDBLCLK
End Select
End Sub

0
 

Author Comment

by:scotster
ID: 10818001
WOW, i'm not at work just now but i will give that a go as soon as i get there. I wish i could figure things out as well as that lol. My programming skill is slightly lacking as i have only been at it for a month or so and completely self taught so i'm a bit limited. Do you recommend a course or continuing with self teachings?

Thanks for the answer, points will be sent out as soon as i try it.

Thanks again

scotster
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

743 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