Question

Currently I'm developing a deskband using c++. Now I'm able to draw things within the taskband window and I would like to draw a taskbar button like icon. I believe it won't be too complex since the default touch keyboard and the TouchMousePointer already made it.

I first create a blank window and use the theme api to draw the background. But I really don't know how to make a taskbar button. Currently only static icon or half transparent button (only the words on it are transparent) works.

In this post How do you draw a Taskbar button using visual styles? they mentioned something by using .net but I really don't want to do that. Just trying to keep everything simple.(no mfc or .net)

There's also some info in this post How to draw Windows 7 taskbar like Shaded Buttons but not really usefull.

I also checked the import functions of TipBand.dll(default touch keyboard)

   UxTheme.dll
         18000D088 Import Address Table
         18000D668 Import Name Table
                 0 time date stamp
                 0 Index of first forwarder reference

                       9 CloseThemeData
                      11 DrawThemeParentBackground
                       D DrawThemeBackground
                      50 SetWindowTheme
                      4D OpenThemeData

COMCTL32.dll
         18000D0B8 Import Address Table
         18000D698 Import Name Table
                 0 time date stamp
                 0 Index of first forwarder reference

                      7C InitCommonControlsEx

GDI32.dll
         18000D358 Import Address Table
         18000D938 Import Name Table
                 0 time date stamp
                 0 Index of first forwarder reference

                     2D4 SelectObject
                      4C CreatePen
                      56 CreateSolidBrush
                     10E DeleteObject
                     261 LineTo
                     26F MoveToEx

He also used the DrawIconEx in user32.dll, I tried that but just a static icon.

I also tried the theme api drawicon but nothing happened just blank. Please guide me........

Was it helpful?

Solution

1) Your deskband must implement IOleCommandTarget. When shell call IOleCommandTarget.Exec with DBID_SETWINDOWTHEME you must store theme name in variable WindowThemeSubClass.

2) Open theme (code from my Shell Ace lib):

FToolBarTheme := IntOpenThemeData(Handle, 'TOOLBAR', WindowThemeSubClass)

...

class function TdecShellExplorerForm.IntOpenThemeData(AWnd: HWND; const AClass, ASubClass: UnicodeString): HTHEME;
var
  Temp: TForm;
begin
  if ASubClass = '' then
    Result := OpenThemeData(AWnd, PWideChar(AClass))
  else
    if IsWindowsVistaOrLater then
      begin
        Result := OpenThemeData(AWnd, PWideChar(ASubClass + '::' + AClass));
        if Result = 0 then
          Result := OpenThemeData(AWnd, PWideChar(AClass));
      end
    else
      begin
        Temp := TForm.Create(Application);
        try
          SetWindowTheme(Temp.Handle, PWideChar(ASubClass), nil);
          Result := OpenThemeData(Temp.Handle, PWideChar(AClass));
          if Result = 0 then
            Result := OpenThemeData(AWnd, PWideChar(AClass));
        finally
          Temp.Free;
        end;
      end;
end;

XP does not support OpenTheme with parameter like 'SubClass::Class'!

3) Draw button only in cases when mouse over your button or user press your button:

DrawThemeBackground(FToolBarTheme, Canvas.Handle, TP_BUTTON, State, Rec.Rect, nil);

where state is TS_HOT when user mouse over your button or is TS_PRESSED when user press your button.

Result:

Mouse over MS Tablet PC Input panel: enter image description here

Mouse over my extension: enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top