home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / XP_Menu_'268932452002.psc / m_MenuXP.bas < prev    next >
Encoding:
BASIC Source File  |  2002-04-05  |  18.6 KB  |  589 lines

  1. Attribute VB_Name = "m_MenuXP"
  2. Private m_hDC As Long                   'handle na Device Context
  3. Private lItemIndex As Long              'cislo item indexu
  4. Private lOldProc As Long                'pointer na p⌠vodn· funkciu
  5. Private ax As Long
  6.  
  7. Public Caps(1 To 100, 1 To 7) As String 'pro ulozeni informaci o menu
  8.  
  9. '1. dimenze uklada text pre MenuItem, viz 6.
  10. '2. dimenze uklada jmeno ikonky, ukazujici do ImageListu imgMain
  11. '3. dimenze obsahuje cislo Parenta (cislo Menu pod ktere toto menu patri. 0= main menu
  12. '4. dimenze obsahuje zda toto je ci neni Parent obsahuje hodnoty N/A
  13. '5. dimenzia obsahuje skutoΦnΘ hMenuId
  14. '6. dimenzia obsahuje meno na MenuItem
  15. '7. dimenzia obsahuje text pre status riadok
  16.  
  17. Public lArr As Long                    'velikost pole Caps
  18. Public hMainMenu As Long                'handle na Menu
  19.  
  20. Private Const lRightOffset = 3          'sirka praveho okraja menu
  21. Private Const lPicWidth = 21            'sirka obrazku
  22. Private Const lMenuWidth = 100          'sirka menu
  23. Private Const lMenuHeight = 20          'vyska menuitem
  24.  
  25. Public Function CHookWnd(mHwnd As Long, bHook As Boolean) As Long
  26.  
  27.   Dim m_ThreadID As Long
  28.   Static m_HookID As Long
  29.  
  30.     CHookWnd = 0
  31.  
  32.     If bHook = True Then
  33.         
  34.         m_ThreadID = GetWindowThreadProcessId(mHwnd, 0)
  35.         m_HookID = SetWindowsHookEx(WH_CALLWNDPROC, AddressOf lHookProc, 0, m_ThreadID)
  36.         
  37.         lOldProc = SetWindowLong(mHwnd, GWL_WNDPROC, AddressOf lMenuProc)
  38.       Else
  39.       
  40.         SetWindowLong mHwnd, GWL_WNDPROC, lOldProc
  41.         UnhookWindowsHookEx m_HookID
  42.         
  43.     End If
  44.  
  45.     CHookWnd = lOldProc
  46.  
  47. End Function
  48.  
  49. Private Function lMenuProc(ByVal hwnd As Long, ByVal nMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  50.  
  51.   Dim sCommand As String
  52.   Dim lResult As Long
  53.   Dim lIndex As Long, lRet As Long
  54.  
  55.     lRet = 0
  56.  
  57.     Select Case nMsg
  58.  
  59.       Case WM_COMMAND
  60.  
  61.         If lParam = 0 Then
  62.  
  63.             lIndex = (wParam And &HFFFF&)
  64.  
  65.             For ax = 1 To lArr
  66.                 If lIndex = Caps(ax, 5) Then sCommand = Caps(ax, 6)
  67.             Next ax
  68.             Call DoMenuItemClickAction(sCommand)
  69.             ' zmeni¥ caps - prida¥ jednu dimenziu na nßzov menu pre raiseevent
  70.  
  71.         End If
  72.  
  73.       Case WM_ACTIVATEAPP, WM_ACTIVATE
  74.  
  75.         lResult = SetMenu(hwnd, hMainMenu)
  76.  
  77.       Case WM_EXITMENULOOP
  78.       
  79.         lResult = DestroyMenu(hMainMenu)
  80.       
  81.       Case WM_MENUSELECT
  82.  
  83.         lIndex = (wParam And &HFFFF&)
  84.         For ax = 1 To lArr
  85.             If lIndex = Caps(ax, 5) Then sCommand = Caps(ax, 7)
  86.         Next ax
  87.         DoMenuItemOverAction sCommand
  88.         'mozno je odtial volana fukcia pre submenu
  89.  
  90.       Case WM_DRAWITEM
  91.  
  92.         If CItemDrawXP(hwnd, nMsg, wParam, lParam) Then
  93.             lMenuProc = True: Exit Function
  94.         End If
  95.  
  96.       Case WM_MEASUREITEM
  97.  
  98.         If CItemMeasure(hwnd, nMsg, wParam, lParam) Then
  99.             lMenuProc = True: Exit Function
  100.         End If
  101.  
  102.     End Select
  103.  
  104.     lMenuProc = CallWindowProc(lOldProc, hwnd, nMsg, wParam, lParam)
  105.  
  106. End Function
  107.  
  108. Private Function CItemDrawXP(ByVal hwnd As Long, ByVal nMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Boolean
  109.  
  110.   Dim lItemDraw As Long
  111.   Dim tmpRect As RECT
  112.   Dim bDummy As Boolean
  113.   Dim lResult As Long
  114.   Dim iRectOffset As Integer
  115.   Dim MeasureInfo As MEASUREITEMSTRUCT
  116.   Dim DrawInfo As DRAWITEMSTRUCT
  117.   Dim hBr As Long, hOldBr As Long
  118.   Dim hPen As Long, hOldPen As Long
  119.   Dim hPenSep As Long, hOldPenSep As Long
  120.   Dim lTextColor As Long
  121.   Dim hBitmap As Long
  122.   Dim hdc As Long
  123.   Dim lIndex As Long
  124.   Dim sItem As String
  125.   Dim dcTmp As Long
  126.   Dim dm As POINTAPI
  127.   Dim tmpRectS As RECT
  128.   Dim lItem As RECT
  129.   Dim ItemPic As StdPicture
  130.   Dim rHwnd As Long
  131.  
  132.     CItemDrawXP = False
  133.     
  134.     Call CopyMem(DrawInfo, ByVal lParam, LenB(DrawInfo))
  135.     DrawInfo.rcItem.Top = DrawInfo.rcItem.Top + 2
  136.     DrawInfo.rcItem.Left = DrawInfo.rcItem.Left + 2
  137.     DrawInfo.rcItem.Right = DrawInfo.rcItem.Right + 2
  138.     DrawInfo.rcItem.Bottom = DrawInfo.rcItem.Bottom + 2
  139.     
  140.     If DrawInfo.CtlType = ODT_MENU Then
  141.     
  142.         m_hDC = DrawInfo.hdc
  143.         iRectOffset = lPicWidth + 5 'offset pre obrßzok menu
  144.  
  145.         'zmena fontu v menu items
  146.         'OldFont = SelectObject(DrawInfo.hdc, MyFont)
  147.         'MyFont = SendMessage(hwnd, WM_GETFONT, 0&, 0&)
  148.         
  149.         'MyFont = CreateFont(14, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, "Courier")
  150.         'Call SelectObject(DrawInfo.hdc, MyFont)
  151.  
  152.         ' nakreslenie pozadia menu Ütandartne
  153.         'hBrRect = CreateSolidBrush(RGB(223, 219, 215))
  154.         hBrRect = CreateSolidBrush(RGB(231, 227, 219))
  155.         hOldBrRect = SelectObject(DrawInfo.hdc, hBrRect)
  156.         
  157.         tmpRectS = DrawInfo.rcItem
  158.         tmpRectS.Right = tmpRectS.Left + lPicWidth + 5
  159.         
  160.         FillRect m_hDC, tmpRectS, hBrRect
  161.         
  162.         Call SelectObject(DrawInfo.hdc, hOldBrRect)
  163.         Call DeleteObject(hBrRect)
  164.  
  165.         'kreslenie Item - selected/unselected
  166.         If (DrawInfo.itemState And ODS_SELECTED) = ODS_SELECTED Then
  167.             hBr = CreateSolidBrush(RGB(182, 190, 215))  'farba v²beru
  168.             hPen = CreatePen(0, 1, RGB(8, 36, 105))     'farba okraja
  169.             lTextColor = RGB(0, 0, 0)                   'farba pφsma
  170.           Else
  171.             'hBr = CreateSolidBrush(RGB(255, 251, 247))  'farba v²beru
  172.             'hPen = CreatePen(0, 1, RGB(255, 251, 247))  'farba okraja
  173.             hBr = CreateSolidBrush(RGB(246, 246, 246))  'farba v²beru
  174.             hPen = CreatePen(0, 1, RGB(246, 246, 246))  'farba okraja
  175.             lTextColor = RGB(0, 0, 0)                   'farba pφsma
  176.         End If
  177.  
  178.         'ulo₧φme info o starom pere a Ütetci
  179.         hOldBr = SelectObject(DrawInfo.hdc, hBr)
  180.         hOldPen = SelectObject(DrawInfo.hdc, hPen)
  181.  
  182.         With DrawInfo.rcItem
  183.  
  184.             'pozadie menu pod textom menu
  185.             tmpRect = DrawInfo.rcItem
  186.             tmpRect.Left = lPicWidth + 5
  187.             FillRect m_hDC, tmpRect, hBr
  188.  
  189.             lResult = GetMenuState(hMainMenu, DrawInfo.itemID, MF_BYCOMMAND)
  190.             
  191.             'zistenie informßciφ o MenuItem
  192.             For ax = 1 To lArr
  193.                 If DrawInfo.itemID = Caps(ax, 5) Then lItemDraw = ax
  194.             Next ax
  195.  
  196.             If (lResult And MF_POPUP) <> MF_POPUP Then
  197.                 
  198.                 If Caps(DrawInfo.itemID, 1) <> "-" Then
  199.                     
  200.                     If (DrawInfo.itemState And ODS_SELECTED) = ODS_SELECTED Then
  201.                         Rectangle m_hDC, .Left, .Top, .Right, .Bottom
  202.                       Else
  203.                         Rectangle m_hDC, .Left + iRectOffset, .Top, .Right, .Bottom
  204.                     End If
  205.                     CItemText .Left + lPicWidth + 10, .Top + 3, Caps(lItemDraw, 1), lTextColor, .Right, .Bottom
  206.                     
  207.                 End If
  208.                 
  209.               Else
  210.                 
  211.                 If (DrawInfo.itemState And ODS_SELECTED) = ODS_SELECTED Then
  212.                     Rectangle m_hDC, .Left, .Top, .Right, .Bottom
  213.                   Else
  214.                     Rectangle m_hDC, .Left + iRectOffset, .Top, .Right, .Bottom
  215.                 End If
  216.                 CItemText .Left + lPicWidth + 10, .Top + 3, Caps(lItemDraw, 1), lTextColor, .Right, .Bottom
  217.                 
  218.             End If
  219.             
  220.         End With
  221.  
  222.         'nastavenie p⌠vodnΘho pera a Ütetca
  223.         Call SelectObject(DrawInfo.hdc, hOldBr)
  224.         Call SelectObject(DrawInfo.hdc, hOldPen)
  225.  
  226.         'zmazanie nami vytvorenΘho brush a pen
  227.         Call DeleteObject(hBr)
  228.         Call DeleteObject(hPen)
  229.         
  230.         'vykres╛ovanie obrßzku do MenuItem
  231.         With DrawInfo
  232.         
  233.             If (lResult And MF_POPUP) <> MF_POPUP Then
  234.                 
  235.                 'vykreslenie obyΦajnej polo₧ky
  236.                 If (Caps(lItemDraw, 2) <> "") Then
  237.                     
  238.                     Set ItemPic = frmMenuXP.imgMain.ListImages(Caps(lItemDraw, 2)).Picture
  239.                     Call CItemPicture(.hdc, ItemPic, 5, .rcItem.Top + 2, False)
  240.                     
  241.                     'Call m_Paint.PaintDisabledPicture(lHDC, ItemPic(m_tMI(lIndex).lIconIndex), 5, tP.Y + 3, 16, 16, 0, 0, &H808000, 0)
  242.                     'Call m_Paint.PaintTransparentPicture(lHDC, ItemPic(m_tMI(lIndex).lIconIndex), 3, tP.Y + 1, 16, 16, 0, 0, &H808000, 0)
  243.                     
  244.                     ' If DrawInfo.itemState = ODS_SELECTED And (Caps(DrawInfo.itemID, 2) = "Checked") Then
  245.                     ' vykreslenie checked boxu !!!
  246.                     '     Call BitBlt(.hDC, 2, .rcItem.Top + 2, 16, 16, GetImageDCFromRepository("Checked2", "16x16"), 0, 0, vbSrcCopy)
  247.                     ' End If
  248.  
  249.                 End If
  250.                 
  251.                 'vykreslenie separatora
  252.                 If InStr(1, Caps(DrawInfo.itemID, 1), "-") > 0 Then
  253.                 
  254.                     hPenSep = CreatePen(0, 1, RGB(166, 166, 166))
  255.                     hOldPenSep = SelectObject(DrawInfo.hdc, hPenSep)
  256.                         
  257.                     MoveToEx m_hDC, .rcItem.Left + lPicWidth + 10, .rcItem.Top + 1, dm
  258.                     LineTo m_hDC, .rcItem.Right, .rcItem.Top + 1
  259.                         
  260.                     SelectObject m_hDC, hOldPenSep
  261.                     DeleteObject hPenSep
  262.  
  263.                 End If
  264.                 
  265.               Else
  266.               
  267.                 'vykreslenie obyΦajnej polo₧ky
  268.                 If (Caps(lItemDraw, 2) <> "") Then
  269.                 
  270.                     Set ItemPic = frmMenuXP.imgMain.ListImages(Caps(lItemDraw, 2)).Picture
  271.                     Call CItemPicture(.hdc, ItemPic, 5, .rcItem.Top + 2, False)
  272.                     
  273.                 End If
  274.                 
  275.             End If
  276.             
  277.         End With
  278.         
  279.     End If
  280.     
  281.     lItem = DrawInfo.rcItem
  282.     Call ExcludeClipRect(m_hDC, lItem.Left, lItem.Top, lItem.Right, lItem.Bottom)
  283.     
  284.     Call CopyMem(ByVal lParam, DrawInfo, LenB(DrawInfo))
  285.     CItemDrawXP = True
  286.  
  287. End Function
  288.  
  289. Private Function CItemMeasure(ByVal hwnd As Long, ByVal nMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Boolean
  290.  
  291.   Static lPrevId As Long
  292.   Static lItemWidth As Long
  293.   Dim sMenuText As String
  294.   Dim lTextSize As POINTAPI
  295.   Dim nDC As Long, lItemIndex As Long
  296.   Dim bDummy As Boolean
  297.   Dim lResult As Long
  298.   Dim MeasureInfo As MEASUREITEMSTRUCT
  299.  
  300.     CItemMeasure = False
  301.     nDC = GetWindowDC(hwnd)
  302.  
  303.     Call CopyMem(MeasureInfo, ByVal lParam, Len(MeasureInfo))
  304.  
  305.     MeasureInfo.itemWidth = lMenuWidth 'pre nemeranΘ polo₧ky !!!!
  306.  
  307.     For ax = 1 To lArr
  308.         If MeasureInfo.itemID = Caps(ax, 5) Then lItemIndex = ax
  309.     Next ax
  310.  
  311.     If lItemIndex <= lArr Then
  312.  
  313.         sMenuText = IIf(Caps(lItemIndex, 1) = "-", "A", Caps(lItemIndex, 1))
  314.         Call GetTextExtentPoint32(nDC, sMenuText, Len(sMenuText), lTextSize)
  315.  
  316.         If Caps(lItemIndex, 3) <> lPrevId Then lItemWidth = 0
  317.         If lItemWidth < lTextSize.x Then lItemWidth = lTextSize.x + lPicWidth + 5 + lRightOffset
  318.         If lPrevId = 0 Then lPrevId = Caps(lItemIndex, 3)
  319.  
  320.         If (lTextSize.x + lPicWidth + 5 + lRightOffset) >= lItemWidth And Caps(lItemIndex, 3) = lPrevId Then
  321.             lItemWidth = lPicWidth + 5 + lTextSize.x + lRightOffset
  322.         End If
  323.  
  324.         MeasureInfo.itemWidth = lItemWidth
  325.         lPrevId = Caps(lItemIndex, 3)
  326.  
  327.     End If
  328.  
  329.     lResult = GetMenuState(hMainMenu, MeasureInfo.itemID, 0)
  330.     If (lResult And MF_POPUP) <> MF_POPUP Then
  331.         MeasureInfo.itemHeight = IIf(Caps(MeasureInfo.itemID, 1) = "-", 3, lMenuHeight)
  332.       Else
  333.         MeasureInfo.itemHeight = lMenuHeight
  334.     End If
  335.  
  336.     Call CopyMem(ByVal lParam, MeasureInfo, Len(MeasureInfo))
  337.     
  338.     CItemMeasure = True
  339.  
  340. End Function
  341.  
  342. Public Function lHookProc(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  343.  
  344.     Dim CWP As CWPSTRUCT
  345.     Dim lRet As Long
  346.     
  347.     If ncode = HC_ACTION Then
  348.     
  349.         CopyMemory CWP, ByVal lParam, Len(CWP)
  350.          
  351.         Select Case CWP.message
  352.         
  353.             Case WM_CREATE
  354.             
  355.                 If CClassName(CWP.hwnd) = "#32768" Then
  356.                 
  357.                     lFlag = wParam \ &H10000
  358.                     If ((lFlag And MF_SYSMENU) <> MF_SYSMENU) Then
  359.                     
  360.                         lRet = SetWindowLong(CWP.hwnd, GWL_WNDPROC, AddressOf lShadowProc)
  361.                      
  362.                         SetProp CWP.hwnd, "OldWndProc", lRet
  363.                     
  364.                     End If
  365.                     
  366.                 End If
  367.                     
  368.         End Select
  369.          
  370.     End If
  371.      
  372.     lHooklProc = CallNextHookEx(WH_CALLWNDPROC, ncode, wParam, lParam)
  373.      
  374. End Function
  375.  
  376. Public Function lShadowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  377.  
  378.     Dim lTmp As Long
  379.     Dim lRet As Long
  380.     Dim Ret As Long
  381.     Dim Rec As RECT, nRec As RECT
  382.     Static xOrg As Long, yOrg As Long
  383.     Static wOrg As Long, hOrg As Long
  384.     Dim m_DC As Long, Rng As Long
  385.     Dim m_Bmp As Long, hColorFill As Long
  386.     Dim lpwp As WINDOWPOS
  387.  
  388.     lRet = GetProp(hwnd, "OldWndProc")
  389.     
  390.     Select Case uMsg
  391.     
  392.         Case WM_WINDOWPOSCHANGING
  393.             
  394.             CopyMemory lpwp, ByVal lParam, Len(lpwp)
  395.             If lpwp.x > 0 Then xOrg = lpwp.x
  396.             If lpwp.y > 0 Then yOrg = lpwp.y
  397.             If lpwp.cx > 1 Then wOrg = lpwp.cx
  398.             If lpwp.cy > 1 Then hOrg = lpwp.cy
  399.             lpwp.cx = lpwp.cx + 2: lpwp.cy = lpwp.cy + 2
  400.             CopyMemory ByVal lParam, lpwp, Len(lpwp)
  401.             
  402.             'lShadowProc = False
  403.             'Exit Function
  404.         
  405.         Case WM_ERASEBKGND
  406.         
  407.             Call FillRectTmp(hwnd, wParam)
  408.             Call CShadowDraw(hwnd, wParam, xOrg, yOrg)
  409.  
  410.             
  411.             lShadowProc = True
  412.             
  413.             Exit Function
  414.     
  415.         Case WM_CREATE
  416.  
  417.             lTmp = GetWindowLong(hwnd, GWL_STYLE)
  418.             lTmp = lTmp And Not WS_BORDER
  419.                  
  420.             SetWindowLong hwnd, GWL_STYLE, lTmp
  421.                  
  422.             lTmp = GetWindowLong(hwnd, GWL_EXSTYLE)
  423.             lTmp = lTmp And Not WS_EX_WINDOWEDGE
  424.             lTmp = lTmp And Not WS_EX_DLGMODALFRAME
  425.                  
  426.             SetWindowLong hwnd, GWL_EXSTYLE, lTmp
  427.             
  428.         Case WM_DESTROY
  429.             
  430.             RemoveProp hwnd, "OldWndProc"
  431.             SetWindowLong hwnd, GWL_WNDPROC, lRet
  432.              
  433.     End Select
  434.      
  435.     lShadowProc = CallWindowProc(lRet, hwnd, uMsg, wParam, lParam)
  436.     
  437. End Function
  438.  
  439. Public Function CClassName(ByVal hwnd As Long) As String
  440.  
  441.     Dim sClass As String
  442.     Dim nLen As Long
  443.      
  444.     sClass = String$(128, Chr$(0))
  445.     nLen = GetClassName(hwnd, sClass, 128)
  446.      
  447.     If nLen = 0 Then
  448.         sClass = ""
  449.     Else
  450.         sClass = Left$(sClass, nLen)
  451.     End If
  452.      
  453.     CClassName = sClass
  454.      
  455. End Function
  456.  
  457. Private Sub CItemPicture(ByVal hDcTo As Long, ByRef m_Picture As StdPicture, ByVal x As Long, ByVal y As Long, ByVal bShadow As Boolean)
  458.      
  459.     Dim lFlags As Long
  460.     Dim hBrush As Long
  461.          
  462.     Select Case m_Picture.Type
  463.         Case vbPicTypeBitmap
  464.             lFlags = DST_BITMAP
  465.         Case vbPicTypeIcon
  466.             lFlags = DST_ICON
  467.         Case Else
  468.             lFlags = DST_COMPLEX
  469.     End Select
  470.      
  471.     If bShadow Then
  472.         hBrush = CreateSolidBrush(RGB(128, 128, 128))
  473.     End If
  474.     
  475.     DrawState hDcTo, IIf(bShadow, hBrush, 0), 0, m_Picture.Handle, 0, x, y, m_Picture.Width, m_Picture.Height, lFlags Or IIf(bShadow, DSS_MONO, DSS_NORMAL)
  476.  
  477.     If bShadow Then
  478.         DeleteObject hBrush
  479.     End If
  480.      
  481. End Sub
  482.  
  483. Public Function CItemText(ByVal x As Long, ByVal y As Long, ByVal hStr As String, ByVal Clr As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  484.  
  485.   Dim OT As Long
  486.   Dim hRect As RECT
  487.     
  488.     If m_hDC = 0 Then Exit Function
  489.  
  490.     SetBkMode m_hDC, NEWTRANSPARENT 'FontTransparent = True
  491.  
  492.     OT = GetTextColor(m_hDC)
  493.     SetTextColor m_hDC, Clr
  494.     
  495.     With hRect
  496.         .Left = x
  497.         .Right = X2
  498.         .Top = y
  499.         .Bottom = Y2
  500.     End With
  501.  
  502.     hPrint = DrawText(m_hDC, hStr, Len(hStr), hRect, DT_LEFT)
  503.     
  504.     SetTextColor m_hDC, OT 'nastavenie p⌠vodnej farvy textu
  505.  
  506. End Function
  507.  
  508. Public Sub CShadowDraw(ByVal hwnd As Long, ByVal hdc As Long, ByVal xOrg As Long, ByVal yOrg As Long)
  509.      
  510.     Dim hDcDsk As Long
  511.     Dim Rec As RECT
  512.     Dim winW As Long, winH As Long
  513.     Dim x As Long, y As Long, c As Long
  514.      
  515.     GetWindowRect hwnd, Rec
  516.     winW = Rec.Right - Rec.Left
  517.     winH = Rec.Bottom - Rec.Top
  518.      
  519.     hDcDsk = GetWindowDC(GetDesktopWindow)
  520.      
  521.     For x = 1 To 4
  522.         For y = 0 To 3
  523.             c = GetPixel(hDcDsk, xOrg + winW - x, yOrg + y)
  524.             SetPixel hdc, winW - x, y, c
  525.         Next y
  526.         For y = 4 To 7
  527.             c = GetPixel(hDcDsk, xOrg + winW - x, yOrg + y)
  528.             SetPixel hdc, winW - x, y, CShadowMask(3 * x * (y - 3), c)
  529.         Next y
  530.         For y = 8 To winH - 5
  531.             c = GetPixel(hDcDsk, xOrg + winW - x, yOrg + y)
  532.             SetPixel hdc, winW - x, y, CShadowMask(15 * x, c)
  533.         Next y
  534.         For y = winH - 4 To winH - 1
  535.             c = GetPixel(hDcDsk, xOrg + winW - x, yOrg + y)
  536.             SetPixel hdc, winW - x, y, CShadowMask(3 * x * -(y - winH), c)
  537.         Next y
  538.     Next x
  539.      
  540.     For y = 1 To 4
  541.         For x = 0 To 3
  542.             c = GetPixel(hDcDsk, xOrg + x, yOrg + winH - y)
  543.             SetPixel hdc, x, winH - y, c
  544.         Next x
  545.         For x = 4 To 7
  546.             c = GetPixel(hDcDsk, xOrg + x, yOrg + winH - y)
  547.             SetPixel hdc, x, winH - y, CShadowMask(3 * (x - 3) * y, c)
  548.         Next x
  549.         For x = 8 To winW - 5
  550.             c = GetPixel(hDcDsk, xOrg + x, yOrg + winH - y)
  551.             SetPixel hdc, x, winH - y, CShadowMask(15 * y, c)
  552.         Next x
  553.     Next y
  554.      
  555.     ReleaseDC GetDesktopWindow, hDcDsk
  556.  
  557. End Sub
  558.  
  559. Private Function CShadowMask(ByVal lScale As Long, ByVal lColor As Long) As Long
  560.      
  561.     Dim R As Long
  562.     Dim G As Long
  563.     Dim B As Long
  564.     
  565.     CShadowRGB lColor, R, G, B
  566.      
  567.     R = CShadowColor(lScale, R)
  568.     G = CShadowColor(lScale, G)
  569.     B = CShadowColor(lScale, B)
  570.      
  571.     CShadowMask = RGB(R, G, B)
  572.      
  573. End Function
  574.  
  575. Private Function CShadowColor(ByVal lScale As Long, ByVal lColor As Long) As Long
  576.     CShadowColor = lColor - Int(lColor * lScale / 255)
  577. End Function
  578.  
  579. Private Sub CShadowRGB(lColor, rColor, gColor, bColor)
  580.  
  581.     a$ = Hex$(lColor)
  582.     c$ = String$(6 - (Len(a$)), "0")
  583.     a$ = c$ & a$
  584.     rColor = Val("&H" & Mid$(a$, 5, 2))
  585.     gColor = Val("&H" & Mid$(a$, 3, 2))
  586.     bColor = Val("&H" & Mid$(a$, 1, 2))
  587.  
  588. End Sub
  589.