[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 515
  • Last Modified:

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

What is the official Visual Basic .NET coding to show quick launch on a toolbar?
0
stephenlecomptejr
Asked:
stephenlecomptejr
  • 9
  • 5
1 Solution
 
ladarlingCommented:
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
 
stephenlecomptejrAuthor Commented:
lddarling,
What is the official mechanism to manipulate Explorer - is it C#, vbscript?
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.

 
jpaulinoCommented:
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
 
stephenlecomptejrAuthor Commented:
Yep...I'm working on it today.
I should be able to finish by the end of today.
Thanks for the quick reply.
0
 
stephenlecomptejrAuthor Commented:
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
 
stephenlecomptejrAuthor Commented:
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
 
jpaulinoCommented:
Have you declared the API's ?
0
 
stephenlecomptejrAuthor Commented:
Yes... I don't think Visual Basic.NET uses KeyEvent - what is its substitute?
0
 
jpaulinoCommented:
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
 
stephenlecomptejrAuthor Commented:
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
 
stephenlecomptejrAuthor Commented:
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
 
stephenlecomptejrAuthor Commented:
I just remarked out the coding wherever KeyEvents were and it has worked without any issues.
0
 
stephenlecomptejrAuthor Commented:
If you do get any replies on this - please post here.

Thank you very sincerely for your replies!
0
 
jpaulinoCommented:
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

Technology Partners: 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!

  • 9
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now