Silverfrost Forums

Welcome to our forums

Windows 7 Taskbar

26 Jun 2013 8:02 #12505

Any plans to add support for the Windows 7 taskbar?

I am not a big fan of OOP style of proramming, but luckily COM object stuff involved for the simple Windows 7 taskbar support is quite simple to do in the 'old school style'.

Steps involved (in MiniBASIC syntax):

First we need to define some GUIDs:

GUID CLSID_TaskbarList
DEFINE_GUID(CLSID_TaskbarList,0x56FDF344,0xFD6D,0x11D0,0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90)
GUID IID_ITaskbarList3
DEFINE_GUID(IID_ITaskbarList3,0xEA1AFB91,0x9E28,0x4B86,0x90,0xE9,0x9E,0x9F,0x8A,0x5E,0xEF,0xAF)

Then we register a window message to inform us when the taskbar is created. we also declare a pointer to taskbar list COM object:

uint WM_TASKBARBUTTONCREATED = -1
WM_TASKBARBUTTONCREATED = RegisterWindowMessage('TaskbarButtonCreated')

pointer pTaskBar

Next, in window procedure we handle the 'TaskbarButtonCreated' message by initializing the taskbarlist COM object:

CoInitialize(NULL)
' Next get the pointer to taskbar list COM object
CoCreateInstance(&CLSID_TaskbarList,0, CLSCTX_INPROC_SERVER, &IID_ITaskbarList3, &pTaskBar)
' Next initialize taskbar list COM object 
M_CALL(pTaskBar, 12, hwnd)   ' call taskbar list HrInit method

Now we have a pointer to the COM object and you probably noticed the M_CALL() function and wonder what it does?

It turns out we can do COM method calls using the COM object pointer and the offset of a method:

func M_CALL(pointer ObjPtr, uint moffset, opt uint v1, opt uint v2, opt uint v3, opt uint v4, opt uint v5), int
	int ret = 0
##asm
	push dword [ebp+32]
	push dword [ebp+28]
	push dword [ebp+24]
	push dword [ebp+20]
	push dword [ebp+16]
	mov ecx, [ebp+12]
	mov eax, [ebp+8]
	push eax
	mov eax, [eax]
	call dword [eax+ecx]
	mov [ebp-4], eax
##endasm

	return ret

endf

You probably wonder, how we know the method offsets and why the HrInit method is located at offset 12? I am no expert at COM, but I think it's because the first three members of the VTable must be: QueryInterfacePtr, AddRefPtr and ReleasePtr. As each member takes up four bytes, the first real method is located at offset 12. You can just look at the interface definition and do the math to figure out the offsets for the rest of the available methods.

If there is interest, I can write a full featured sample demoing the Windows 7 taskbar progress bar in action...

27 Jun 2013 6:11 #12506

Jalih

There are no plans at the moment to support the Windows 7 taskbar.

Note that all future development will aim to avoid assembler code in order to reduce the hassle of maintaining both 32 and 64 bit architecture.

27 Jun 2013 10:25 #12507

Paul, Jalih,

I must admit that Jalih's post took me to a new area that I didn't know existed in terms of taskbar functionality. It does seem a shame not to have things available when someone offers to develop them, and someone else might gratefully use them, even if there are limits to that functionality.

Is not one answer to this to have a new section of the forum where users could post interesting (and working!) subroutines etc to do things that Clearwin+ does not do? (Like Jalih's suggestions for the taskbar)? (Simdem / Simfit is a bit like this).

I'm using a terrific routine of this sort that controls the opacity of a window which someone posted years ago. I make my startup 'splash' gradually fade away with it.

However, perhaps it would need to allow longer messages than the forum does currently.

Jalih, Do you do assembly programming inline with your Fortran using CODE ... EDOC?

Eddie

27 Jun 2013 3:46 #12516

Eddie

My apologies but my reply was not intended to restrict Jalih in any way but just to be open about our involvement at the present time. We have many demands on our time and we need to be realistic about priorities and when we can deliver.

28 Jun 2013 7:41 #12532

Quoted from LitusSaxonicum

Jalih, Do you do assembly programming inline with your Fortran using CODE ... EDOC?

No, I usually write my external routines in MiniBASIC as it's using the NASM assembler for inline assembly.

I decided to write a simple FTN95 callable Windows 7 Taskbar library. All methods in the ITaskbarList3 interface will simply be callable as functions and take the pointer to taskbar list COM object as the first parameter.

28 Jun 2013 9:29 #12533

Paul,

I didn't think that you meant to discourage Jalih, so no apology needed - I'm sure that he appreciates how much your team have on their plate already (I do).

My suggestions were offered, as always and perhaps naively, in the hope that we can all benefit from the inventiveness and generosity of other forum users.

Eddie

30 Jun 2013 9:24 #12536

I have been making some progress. Most of the ITaskBarList3 methods have now been wrapped into flat interface as simple functions.

Below is a picture to demonstrate the Taskbar progress bar in action. I added progress counter as icon overlay and it's created dynamically.

Taskbar progress bar in action

30 Jun 2013 5:57 #12539

I made a simple FTN95 example project to play with...

Available here

Please login to reply.