MyTetra Share
Делитесь знаниями!
Как скрыть/показать панель задач и ярлыки на рабочем столе
Время создания: 02.03.2020 07:09
Текстовые метки: DPI, разрешение экрана
Раздел: VB
Запись: xintrea/mytetra_db_adgaver_new/master/base/158312214246zajiqdm1/text.html на raw.githubusercontent.com

Как скрыть/показать панель задач и ярлыки на рабочем столе

21.02.2012, 23:17. Просмотров 1833. Ответов


Кто знает, как скрыть/показать панель задач и ярлыки на рабочем столе у Visual Basic 2008?
У Visual Basic 6 я пользовался кодом


Option Explicit

 

Private Declare Function ShowWindow& Lib _

        "user32" (ByVal q&, ByVal q1&)

       

Private Declare Function SetWindowPos Lib _

    "user32" (ByVal hwnd As Long, _

     ByVal hWndInsertAfter As Long, _

     ByVal x As Long, ByVal y As Long, _

     ByVal cx As Long, ByVal cy As Long, _

     ByVal wFlags As Long) As Long

     

Private Declare Function FindWindow Lib _

    "user32" Alias "FindWindowA" _

    (ByVal lpClassName As String, _

    ByVal lpWindowName As String) As Long

   

Const SWP_HIDEWINDOW = &H80

Const SWP_SHOWWINDOW = &H40

Dim hPanel As Long

Dim p As Long

 

Private Sub Command1_Click()

' Скрыть панель задач

hPanel = FindWindow("Shell_traywnd", "")

Call SetWindowPos(hPanel, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)

End Sub

 

Private Sub Command2_Click()

' Показать панель задач

hPanel = FindWindow("Shell_traywnd", "")

Call SetWindowPos(hPanel, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)

End Sub

 

Private Sub Command3_Click()

' Скрыть ярлыки

   p = FindWindow("progman", vbNullString)

    Call ShowWindow(p, 0)

End Sub

 

Private Sub Command4_Click()

'Показать ярлыки

   p = FindWindow("progman", vbNullString)

    Call ShowWindow(p, 1)

End Sub

У Visual Basic 2008 этот код не работает.



«Пиксели, поинты, твипы и DPI!»

https://studassistent.ru/vba/pikseli-pointy-tvipy-i-dpi-vba


Private Declare Function ShowWindow& Lib _

        "user32" (ByVal q&, ByVal q1&)

       

Private Declare Function SetWindowPos Lib _

    "user32" (ByVal hwnd As Long, _

     ByVal hWndInsertAfter As Long, _

     ByVal x As Long, ByVal y As Long, _

     ByVal cx As Long, ByVal cy As Long, _

     ByVal wFlags As Long) As Long

     

Private Declare Function FindWindow Lib _

    "user32" Alias "FindWindowA" _

    (ByVal lpClassName As String, _

    ByVal lpWindowName As String) As Long

   

Const SWP_HIDEWINDOW = &H80

Const SWP_SHOWWINDOW = &H40

Dim hPanel As Long

Dim p As Long

 

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function ReleaseDC Lib "user32" ( _

    ByVal hwnd As Long, _

    ByVal hDC As Long) As Long

Private Declare Function GetDeviceCaps Lib "gdi32" ( _

    ByVal hDC As Long, _

    ByVal nIndex As Long) As Longhttps://studassistent.ru/vba/pikseli-pointy-tvipy-i-dpi-vba

 

Const LOGPIXELSX = 88

Const LOGPIXELSY = 90

Const TWIPSPERINCH = 1440

 

Private Declare Function GetSystemMetrics Lib "user32" ( _

    ByVal nIndex As Long) As Long

 

Private Const SM_CXFULLSCREEN = 16

Private Const SM_CYFULLSCREEN = 17

 

Sub ConvertPixelsToPoints(ByRef x As Single, ByRef y As Single)

    Dim hDC As Long

    Dim RetVal As Long

    Dim XPixelsPerInch As Long

    Dim YPixelsPerInch As Long

 

    hDC = GetDC(0)

    XPixelsPerInch = GetDeviceCaps(hDC, LOGPIXELSX)

    YPixelsPerInch = GetDeviceCaps(hDC, LOGPIXELSY)

    RetVal = ReleaseDC(0, hDC)

    x = x * TWIPSPERINCH / 20 / XPixelsPerInch

    y = y * TWIPSPERINCH / 20 / YPixelsPerInch

End Sub

 

Sub Move()

    Dim Wt As Single

    Dim Ht As Single

Stop

    Wt = GetSystemMetrics(SM_CXFULLSCREEN)

    Ht = GetSystemMetrics(SM_CYFULLSCREEN)

    With UserForm1

        ConvertPixelsToPoints Wt, Ht

        .Left = Wt - .Width

        .Top = Ht - .Height  ' 1-ый вариант (выше)

       .Top = Ht               ' 2-ой вариант (ниже)

       .Show vbModeless

    End With

   

End Sub

 

Private Sub UserForm_Initialize()

    Call Move

End Sub

Так же в этом разделе:
 
MyTetra Share v.0.65
Яндекс индекс цитирования