• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

"Of The Bay" Version 2.00

Started by Patrice Terrier, October 22, 2008, 08:43:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

This is a GDImage project to emulate the MAC OS X dockbar in Windows VISTA and XP.

It is a rather complex project, however i like the result:



Note: You must use at least a 1280x1024 resolution and your display must run in 32-bit mode.

I did put many tricks in this code, and the most trivial is that there is absolutly no API child controls  ;D

Looking forward for your feedback.

8)

Added:
To close the DockBar and restore the default Windows desktop, select the AERO DockBar and press the ESCAPE key.


History:

  • 08-06-2011 V 2.00 - compatible 32/64-bit.
  • 12-17-2008 V 1.60 - With embedded OTB config file generator to customize the shortcuts.
  • 12-15-2008 V 1.57 - Right mouse button to display the "shorcut target path".
  • 11-28-2008 V 1.56 - With new utility to create custom OTB file.
  • 11-23-2008 V 1.54 - With custom icon set + new multiple display detection.
  • 11-21-2008 V 1.51 - New menu option to change the desktop wallpaper.
  • 11-20-2008 V 1.50 - Another major revision with full customization (OTB file).
  • 11-19-2008 V 1.30 - This is a major revision (see details in thread).
  • 11-17-2008 V 1.25 - WindowAnimate + new text location.
  • 11-16-2008 V 1.24 - Center common dialog in multiple display mode.
  • 11-15-2008 V 1.23 - Official logo + OTB icon + minor changes.
  • 11-13-2008 V 1.22 - Better text contrast while hover a white background.
  • 11-09-2008 V 1.21 - Support for embedded desktop subfolders.
  • 11-04-2008 V 1.20 - Drag and drop + smooth scrolling.
  • 11-03-2008 V 1.10 - Several new icon frames and backgrounds + subtile changes.
  • 10-31-2008 V 1.05 - "Of The Bay" with new features and further CPU % reduction.
  • 10-30-2008 V 1.04 - With flare effect and new menu options.
  • 10-29-2008 V 1.03 - Shortcut detection has been enhanced to resolve missing virtual lnk files.
  • 10-28-2008 V 1.02 - Changing icon frame from popup menu (use right mouse click to popup).
  • 10-27-2008 V 1.01 - Added popup menu (use right mouse click to popup).
  • 10-26-2008 V 1.00 - Initial version 1.00.


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Carlo Pagani

Always like your demos Patrice!
16 - 20% on P4 3GHz and GForce 2

Patrice Terrier

I have updated the zip file, to further reduce the CPU %.

Now if the mouse is outside of the DockBar or if it is not moving hover it, then CPU % should be close to zero.

Thanks for your feedback.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

Very little cpu usage 0-6%.
====================
CPU
====================
Number of CPU(s)   One Physical Processor / One Core / 2 Logical Processors
Vendor   GenuineIntel
CPU Full Name   Intel Pentium 4 HT
CPU Name   Intel(R) Pentium(R) 4 CPU 3.00GHz
CPU Code Name   Prescott
Technology   0.09µ
Platform Name   Socket 478
Type   Original OEM processor
FSB Mode   QDR
Platform ID   2
Microcode ID   17
Type ID   0
CPU Clock   2957.27
System Bus Clock   -1.0
System Clock   197.15
Multiplier   15.00
Original Clock   3000.00
Original Bus Clock   800.00
Original System Clock   200.00
Original Multiplier   15.00
L2 Cache Speed   2957.27 MHz
L2 Cache Speed   Full
CPU Family / Model / Stepping   F / 3 / 4
HyperThreading   2
Cache   12 KµOps L1 T-Cache, 16 KB L1 D-Cache, 1024 KB L2 Cache
Instructions   MMX, SSE, SSE2, SSE3, HT, HTT, MSR
Architecture   x86
=====================================
Video
=====================================
Property   Value
Number of GPUs   2
Number of GPUs in SLI mode   206
Display Adapter   RADEON X850 Series
Video Processor   ATI display adapter AGP (0x4B4B)
Video memory size   256 MBytes
Adapter DAC Type   Internal DAC(400MHz)
BIOS Date   02/08/05
Display Drivers   ati2dvag.dll
Driver Version   6.14.10.6505
Driver Date   2004-12-22 02:33:13
Inf File Name   oem0.inf
Inf Section   ati2mtag_R481
   
Display Adapter   RADEON X850 Series - Secondary 
Video Processor   ATI display adapter AGP (0x4B4B)
Video memory size   256 MBytes
Adapter DAC Type   Internal DAC(400MHz)
Display Drivers   ati2dvag.dll
Driver Version   6.14.10.6505
Driver Date   2004-12-22 02:33:13
Inf File Name   oem0.inf
Inf Section   ati2mtag_R481
   
   
Name   RADEON X850 Series
Chip Type   ATI display adapter AGP (0x4B4B)
DAC Type   Internal DAC(400MHz)
Memory   256 MBytes


James


Patrice Terrier

DockBar project status

- I am able to hide all the desktop icons while the DockBar is visible and restore them once the DockBar is closed.

I am trying to figure the best way to retrieve the existing desktop icons to show them on the Dockbar.
I am not sure if the ExtractIconEx API is the best way to do that (on VISTA some icons are indeed PNG).
If you have any suggestions they are welcomed.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

Looks like the best solution is to retrieve the Desktop Listview handle, doing that:

vHandle& = FindWindow("Progman", "Program Manager")
vHandle& = FindWindowEx(vHandle&, 0, "SHELLDLL_DefView", "")
vHandle& = FindWindowEx(vHandle&, 0, "SysListView32", "FolderView")

'// Here we display the number of icons shown onto the desktop
msgbox str$(SendMessage(vHandle&, %LVM_GETITEMCOUNT, 0, 0))

The problem now is to retrieve each icon using the %LVM_GETIMAGELIST and to figure which icon match a specific shortcut.lnk ...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Petr Schreiber

Hi Patrice,

example runs fine on AMD Sempron 3400+ @ onboard GeForce6, CPU usage is usually 0% with maximum of 14% when I click on it like mad.


Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Emil Weiss

On XP Professional svp2
GForce 7800 AMD64 4000+ running with 0 to 3% when click on a entry

greets Emil

Patrice Terrier

Thanks to those who gave me a feedback.

I am still working on it, and i am learning several "under the hood" things about the desktop.

Example:


LOCAL hListView, dwProcessId, hProcess, dwSize, lpData AS DWORD
LOCAL nItemCount AS LONG

hListView = FindWindow("Progman", "Program Manager")
hListView = FindWindowEx(hListView, 0, "SHELLDLL_DefView", "")
hListView = FindWindowEx(hListView, 0, "SysListView32", "FolderView")

CALL GetWindowThreadProcessId(hListView, dwProcessId)
hProcess = OpenProcess(%PROCESS_VM_OPERATION OR %PROCESS_VM_READ OR %PROCESS_VM_WRITE, %FALSE, dwProcessId)
IF hProcess THEN
  '// Compute the size of our reserved memory buffer
  dwSize = sizeof(POINTAPI) + sizeof(LVITEM) + %MAX_PATH * 2

  lpData = VirtualAllocEx(hProcess, BYVAL %NULL, dwSize, %MEM_COMMIT, %PAGE_READWRITE)
  IF lpData THEN
     '// Setup pointers
     LOCAL lpPosition, lpItem, lpText AS LONG  
     lpPosition = lpData
     lpItem = lpData + sizeof(POINTAPI)
     lpText = lpData + sizeof(POINTAPI) + sizeof(LVITEM)

     DIM lvi AS LVITEM
     LOCAL szText AS ASCIIZ * (%MAX_PATH * 2)  ' Allow room for unicode
     LOCAL i AS LONG
     nItemCount = SendMessage(hListView, %LVM_GETITEMCOUNT, 0, 0)
     FOR i = 0 TO nItemCount - 1
         '// Init LVITEM structure and copy it to our reserved memory buffer
         lvi.mask       = %LVIF_TEXT
         lvi.iItem      = i
         lvi.iSubItem   = 0
         lvi.pszText    = lpText
         lvi.cchTextMax = %MAX_PATH * 2
         CALL WriteProcessMemory(hProcess, lpItem, lvi, sizeof(LVITEM), 0)
         '// Get text label and x,y location
         CALL SendMessage(hListView, %LVM_GETITEMTEXT, i, lpItem)
         CALL SendMessage(hListView, %LVM_GETITEMPOSITION, i, lpPosition)
         '// Copy from process memory to local variables
         szText = ""
         CALL ReadProcessMemory(hProcess, lpText, szText, %MAX_PATH * 2, 0)
         LOCAL p AS POINTAPI
         CALL ReadProcessMemory(hProcess, lpPosition, p, SIZEOF(POINTAPI), 0)

         Af$ += str$(p.X)+str$(p.Y) + " " + szText + $CR          
   
     NEXT
   
     '// Freeup memory
     CALL VirtualFreeEx(hProcess, lpData, 0, %MEM_RELEASE)
  END IF  

  '// Close process
  CALL CloseHandle(hProcess)
END IF

msgbox Af$


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

I have updated the first post of this thread with version 1.0 of the GDImage AERO DockBar.

8)
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#10
I found a problem that would not fire the target at the first click, I am working on it...

Added:
I think i have fixed it, the zip file has been updated.

If you want to see what i am doing under the hood to fire the shorcuts, then REM out this part of the code

          '// Hide desktop icons 
         
'CALL ShowDesktopIcons(%FALSE)

          CALL ShowWindow(hMain, %SW_SHOW)

          CALL SetTimer(hMain, 1, %TIMER_Speed, %NULL)
          WHILE GetMessage(Msg, %NULL, 0, 0)
                CALL TranslateMessage(Msg)
                CALL DispatchMessage(Msg)
          WEND
          CALL KillTimer(hMain, 1)

          '// Show desktop icons
          'CALL ShowDesktopIcons(%TRUE)


And to understand what i am doing look at FireApplication:

SUB FireApplication(BYVAL nItem AS LONG)
    'IF ISFILE(gS(nItem).ShellTo) THEN
    '   LOCAL sShellTo, sCmdLine, sFullPath AS STRING
    '   sShellTo = gS(nItem).ShellTo
    '   sFullPath = gS(nItem).WorkDir
    '   IF LEN(sFullPath) = 0 THEN
    '      sFullPath = RTRIM$(PATHNAME$(PATH, gS(nItem).ShellTo), "\")
    '   ELSE
    '      CALL SetCurrentDirectory((sFullPath))
    '   END IF
    '   CALL ShellExecute(0, "open", (sShellTo), (sCmdLine), (sFullPath), gS(nItem).ShowCmd)
    'END IF
   
'   // Here is the magic part!
    CALL PostMessage (ghListView, 513 , 0, gS(nItem).focusXY) '// WM_LBUTTONDOWN
    CALL PostMessage (ghListView, 514 , 0, gS(nItem).focusXY) '// WM_LBUTTONUP

    CALL PostMessage (ghListView, 515 , 0, gS(nItem).focusXY) '// WM_LBUTTONDBLCLK

END SUB

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

Version 1.01 with popup menu has been released (ZIP file attached to the first post of this thread).

By the way this version will show you how to create an ownerdrawn popup menu with text and icon bitmap (png).

1 - %WM_MEASUREITEM
Note: itemWidth must be large enough to hold the largest popup menu string.

CASE %WM_MEASUREITEM                     
     LOCAL lpmis AS MEASUREITEMSTRUCT PTR
     lpmis = lParam                     
     IF wParam = 0 THEN                 
        @lpmis.itemWidth = 120           
        @lpmis.itemHeight = 18           
        FUNCTION = 1: EXIT FUNCTION     
     END IF                             


2 - %WM_DRAWITEM
Note: The %ODT_MENU constant is the place to draw our Menu

CASE %WM_DRAWITEM                                                                                     
     LOCAL lpdis AS DRAWITEMSTRUCT PTR                                                                 
     lpdis = lParam                                                                                   
     SELECT CASE LONG @lpdis.CtlType                                                                   
                                                                                                       
     CASE %ODT_MENU     ' 1 Owner-drawn menu item                                                     
          LOCAL zTxt AS ASCIIZ * 128, nDrawIt, Img, imgW, imgH, graphics AS LONG                       
                                                                                                       
          zTxt = GetMenuTxt(@lpdis.ItemID, Img)                                                       
          nDrawIt = -1                                                                                 
          IF (@lpdis.itemState AND %ODS_SELECTED) THEN                                                 
             CALL SetTextColor(@lpdis.hDC, 0)                                                         
             CALL SetBkColor(@lpdis.hDC, RGB(218,235,243))                                             
          ELSE                                                                                         
             CALL SetTextColor(@lpdis.hDC, 0)                                                         
             CALL SetBkColor(@lpdis.hDC, RGB(240,240,240))                                             
          END IF                                                                                       
                                                                                                       
          IF (@lpdis.itemState AND %ODS_GRAYED) THEN                                                   
             CALL SetTextColor(@lpdis.hDC, RGB(128,128,128))                                           
             nDrawIt = 0                                                                               
          END IF                                                                                       
                                                                                                       
          CALL ExtTextOut(@lpdis.hDC, 6 + 16 + @lpdis.rcItem.nleft, _                                 
                          @lpdis.rcItem.nTop + 3, %ETO_OPAQUE, _                                       
                          @lpdis.rcItem, zTxt, LEN(zTxt), BYVAL 0)                                     
                                                                                                       
          IF nDrawIt AND GdipCreateFromHDC(@lpdis.hDC, graphics) = 0 THEN                             
             CALL zGetImageSize(Img, imgW, imgH)                                                       
             CALL GdipDrawImageRectRectI(graphics&, Img, _                                             
                                         @lpdis.rcItem.nleft + 1, @lpdis.rcItem.nTop + 1, ImgW, ImgH, _
                                         0, 0, ImgW, ImgH, %UnitPixel, _                               
                                         0)                                                           
             CALL GdipDeleteGraphics(graphics)                                                         
          END IF                                                                                       
                                                                                                       
          FUNCTION = 1: EXIT FUNCTION                                                                 
                                                                                                       
     END SELECT                                                                                       


3 - %WM_RBUTTONDOWN
This is the place to create the popup menu.
Note: Currently there is only one item in the menu to "Close DockBar".

CASE %WM_RBUTTONDOWN                                                                 
     LOCAL hMenu, nChoice AS LONG                                                     
     hMenu = CreatePopupMenu() '// The bitmap popup menu                             
     IF hMenu THEN                                                                   
        CALL AppendMenu(hMenu, %MF_OWNERDRAW, %IDM_Close          , "")               
        'CALL AppendMenu(hMenu, %MF_SEPARATOR, 102                , "")               
        CALL GetCursorPos(p)                                                         
        nChoice = TrackPopupMenuEx(hMenu, %TPM_RETURNCMD, p.X, p.Y, hWnd, BYVAL %NULL)
        CALL DestroyMenu(hMenu)                                                       
        IF nChoice THEN CALL SendMessage(hWnd, %WM_COMMAND, MAKLNG(nChoice, 0), 0)   
                                                                                     
     END IF                                                                           


4 - GetMenuTxt
This is the place where we read the string to display and we load its matching icon.
Note: GetMenuTxt is able to handle multi-languages, at this time English and French.

FUNCTION GetMenuTxt(BYVAL ItemId AS LONG, Img AS LONG) AS STRING
    LOCAL sItem AS STRING
    IF IsFrench() THEN
       SELECT CASE ItemId
       CASE %IDM_Close             : FUNCTION = "Fermer DockBar"

       END SELECT
    ELSE
       SELECT CASE ItemId
       CASE %IDM_Close             : FUNCTION = "Close DockBar"

       END SELECT
    END IF

    SELECT CASE ItemId
    CASE %IDM_Close                : sItem = "Close.png"

    END SELECT
    Img = zAddResource(EXE.Path$ + "Resource\" + sItem)

END FUNCTION


That's all for now.

8)
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Emil Weiss

patrice

thanks for the information
i have test it and can show nothing on the Dockbar.. only menu with "Close Dockbar" are shown

greets Emil

Patrice Terrier

Quotei have test it and can show nothing on the Dockbar.. only menu with "Close Dockbar" are shown

That's very strange, i just checked it on a computer runing XP SP2 and it works the same than on my VISTA Premium laptop.
???
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Bud Meyer

Great job, Patrice. Runs fine here on WinXP SP3. :)