Solved

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

Posted on 2008-10-10
15
503 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
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
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
 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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