Solved

Show in taskbar

Posted on 2004-04-05
6
590 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
Comment Utility
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 27

Expert Comment

by:Ark
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 17

Expert Comment

by:zzzzzooc
Comment Utility
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 27

Accepted Solution

by:
Ark earned 50 total points
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now