Solved

Need Visual Basic .NET coding to show quick launch on toolbar.

Posted on 2008-10-10
15
501 Views
Last Modified: 2012-05-05
What is the official Visual Basic .NET coding to show quick launch on a toolbar?
0
Comment
Question by:stephenlecomptejr
  • 9
  • 5
15 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 22685583
0
 
LVL 11

Expert Comment

by:ladarling
ID: 22689260
What is the official Visual Basic .NET coding...
There is no mechanism, official or otherwise, to manipulate Explorer from within VB except using the Windows API, which is what jpaulino is pointing you to. His is about as good as you are gonna get. :-)
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22703718
lddarling,
What is the official mechanism to manipulate Explorer - is it C#, vbscript?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22703839
stephenlecomptejr,
There are no official mechanism to manipulate Explorer. You can use VB, C#, C++, etc.
Have you checked the code from the link I have showed you ?
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22704020
Yep...I'm working on it today.
I should be able to finish by the end of today.
Thanks for the quick reply.
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22705178
I've tried copying and pasting the code only for Show Quick Launch | Lock the Taskbar.
But I get an error on everywhere there is a KeyEvent command used.
Examples:  If apiSetForegroundWindow(hwnd) <> 0 Then KeyEvent(Keys.Q)

Is there a VB.NET translation of this code?  Or do I need to pull this into my older version Visual Basic 6?
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22705598
So far I've adjusted everything with the following - I just need a replacement or work around wherever the KeyEvent exists....

Private Function ShowQuickLaunch(ByVal qShow As Boolean) As Int32

    On Error Resume Next
    Dim hwnd, twnd, qwnd, lwnd As Int32, dResult As New DialogResult
    Dim oShell As Object = CreateObject("Shell.Application")
    hwnd = 0 : twnd = 0 : qwnd = 0 : lwnd = 0
    oShell.TrayProperties()
    For i As Int32 = 1 To 70
      hwnd = apiFindWindow(Nothing, _
         "Taskbar and Start Menu Properties")
      If hwnd <> 0 Then
        SendKeys.Flush() : Threading.Thread.Sleep(100)
        Exit For
      End If
      SendKeys.Flush() : Threading.Thread.Sleep(70)
    Next
    twnd = apiFindWindowEx(hwnd, 0, Nothing, "Taskbar")
    qwnd = apiFindWindowEx(twnd, 0, "Button", "Show &Quick Launch")
    ShowQuickLaunch = apiSendMessage(qwnd, BM_GETCHECK, 0, Nothing)
    If ShowQuickLaunch = BST_CHECKED Then
      If qShow = False Then
        dResult = MessageBox.Show("The Quick Launch window is showing." _
        & vbCrLf & vbCrLf & "Would you like to hide it now?", _
        "Taskbar Settings", MessageBoxButtons.YesNo, _
           MessageBoxIcon.Question)
        If dResult = Windows.Forms.DialogResult.Yes Then
          SendKeys.Flush() : Threading.Thread.Sleep(100)
          If apiSetForegroundWindow(hwnd) <> 0 Then KeyEvent(Keys.Q)
          If apiSetForegroundWindow(hwnd) <> 0 Then KeyEvent(Keys.Q)
          SendKeys.Flush() : Threading.Thread.Sleep(100)
          apiSendMessage(qwnd, BM_SETCHECK, BST_UNCHECKED, Nothing)
          SendKeys.Flush() : Threading.Thread.Sleep(100)
          If apiSetForegroundWindow(hwnd) <> 0 Then KeyEvent(Keys.A)
          SendKeys.Flush() : Threading.Thread.Sleep(100)
          ShowQuickLaunch = apiSendMessage(qwnd, BM_GETCHECK, _
             0, Nothing)
          If ShowQuickLaunch = BST_UNCHECKED Then
            apiSendMessage(hwnd, WM_CLOSE, 0, Nothing)
            MessageBox.Show("The Quick Launch window is hidden.", _
                            "Success", _
            MessageBoxButtons.OK, MessageBoxIcon.Information)
          Else
            MessageBox.Show("The Quick Launch window is still showing.  Try to hide it manually.", "Failure", MessageBoxButtons.OK, _
              MessageBoxIcon.Information)
            Return -1
          End If
        End If
      End If
    ElseIf ShowQuickLaunch = BST_UNCHECKED OrElse _
       ShowQuickLaunch = BST_INDETERMINATE Then
      If qShow = True Then
        dResult = MessageBox.Show("The Quick Launch window is hidden." _
        & vbCrLf & vbCrLf & "Would you like to show it now?", _
           "Taskbar Settings", _
        MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If dResult = Windows.Forms.DialogResult.Yes Then
          lwnd = apiFindWindowEx(twnd, 0, "Button", _
             "&Lock the taskbar")
          If apiSendMessage(lwnd, BM_GETCHECK, 0, Nothing) = _
             BST_CHECKED Then
            dResult = MessageBox.Show("The taskbar is locked." _
               & vbCrLf & vbCrLf & _
            "Would you like to unlock it now?", _
               "Taskbar Settings", _
            MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If dResult = Windows.Forms.DialogResult.Yes Then
              SendKeys.Flush() : Threading.Thread.Sleep(100)
              If apiSetForegroundWindow(hwnd) <> 0 _
                 Then KeyEvent(Keys.L)
              If apiSetForegroundWindow(hwnd) <> 0 _
              Then KeyEvent(Keys.L)
              SendKeys.Flush() : Threading.Thread.Sleep(100)
              apiSendMessage(lwnd, BM_SETCHECK, _
                             BST_UNCHECKED, Nothing)
              SendKeys.Flush() : Threading.Thread.Sleep(100)
              If apiSetForegroundWindow(hwnd) <> 0 _
                 Then KeyEvent(Keys.A)
              SendKeys.Flush() : Threading.Thread.Sleep(100)
              ShowQuickLaunch = apiSendMessage(lwnd, _
                 BM_GETCHECK, 0, Nothing)
              If ShowQuickLaunch = BST_UNCHECKED Then
                MessageBox.Show("The taskbar is unlocked.", _
                                "Success", _
                MessageBoxButtons.OK, _
                   MessageBoxIcon.Information)
              Else
                MessageBox.Show("The taskbar is still locked.", _
                                "Failure", _
                MessageBoxButtons.OK, MessageBoxIcon.Warning)
                ShowQuickLaunch = -1
              End If
            End If
          End If
          SendKeys.Flush() : Threading.Thread.Sleep(100)
          If apiSetForegroundWindow(hwnd) <> 0 _
             Then KeyEvent(Keys.Q)
          If apiSetForegroundWindow(hwnd) <> 0 _
             Then KeyEvent(Keys.Q)
          SendKeys.Flush() : Threading.Thread.Sleep(100)
          apiSendMessage(qwnd, BM_SETCHECK, BST_CHECKED, Nothing)
          SendKeys.Flush() : Threading.Thread.Sleep(100)
          If apiSetForegroundWindow(hwnd) <> 0 _
             Then KeyEvent(Keys.A)
          SendKeys.Flush() : Threading.Thread.Sleep(100)
          ShowQuickLaunch = apiSendMessage(qwnd, BM_GETCHECK, _
             0, Nothing)
          If ShowQuickLaunch = BST_CHECKED Then
            apiSendMessage(hwnd, WM_CLOSE, 0, Nothing)
            MessageBox.Show("The Quick Launch window is showing.", _
                            "Success", _
            MessageBoxButtons.OK, MessageBoxIcon.Information)
          Else
            MessageBox.Show("The Quick Launch window is still hidden.  Try to show it manually.", "Failure", MessageBoxButtons.OK, _
                  MessageBoxIcon.Information)
            Return -1
          End If
        End If
      End If
    End If
    apiSendMessage(hwnd, WM_CLOSE, 0, Nothing)
  End Function
0
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

 
LVL 48

Expert Comment

by:jpaulino
ID: 22705935
Have you declared the API's ?
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22706096
Yes... I don't think Visual Basic.NET uses KeyEvent - what is its substitute?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22706497
This is VB.NET and I don't know what's KeyEvent.
I will ask the author of the article and then let you know.
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22707335
The other interesting thing about that code is there a tie back to a createshortcut function but there is no listing of the code....can you ask the author about that as well?
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22707405
I'm also having trouble determining where the code is to lock the taskbar...
I don't want it to lock the taskbar and would rather change the code to account for this option in the function...
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22707496
I just remarked out the coding wherever KeyEvents were and it has worked without any issues.
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 22707497
If you do get any replies on this - please post here.

Thank you very sincerely for your replies!
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22707585
Ok, but you can also follow in the link I provide you.
I have made a comment there and I'm just waiting for any reply.
0

Featured Post

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.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now