Question for adeyblue

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
deltarho[1859]
Posts: 4313
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Question for adeyblue

Post by deltarho[1859] »

@adeyblue

I have often been referred to as a 'nosy parker' so feel free to ignore the following question.

What is your coding background?

The reason I ask is that you have posted stuff here very few are capable of doing and also at the PowerBASIC forum where there are more Windows GUI coders per square foot. :)
adeyblue
Posts: 300
Joined: Nov 07, 2019 20:08

Re: Question for adeyblue

Post by adeyblue »

It isn't a queston of 'skill' or even experience really (though that helps), it's a matter of curiosity and knowing 'how to know'.

Here's a walkthrough of what happened (RE: this thread - viewtopic.php?t=32246).
I saw your thread and thought "Hmm, yeah. I wonder how you do that properly? There's got to be some way."
Then I remembered that I've seen something like IShellIcon when searching for things in the index of the help I mainly use

And sure enough there are four of them
Image
IShellIcon is if you're writing your own extension, so not that
IShellIconOverlay is also for your own extensions, not that
I'm not entirely sure what the difference between the other two is, but the blurb for Identifier has a link to what is now this page https://learn.microsoft.com/en-us/windo ... y-handlers but with more information. And that says Identifier as the one to use. Bingo, probably.

Supposedly with the method to change or at least add the little icons, I went and looked at icon 55 in shell32 (the one your hack replaced the shortcut arrow with) and sure enough it's one that's completely transparent. If Explorer can handle transparent overlays, then we have a solution. Take over processing for shortcuts and tell explorer to use a completely transparent overlay, which'll look like they've been turned off.

If I'd have written a COM dll in FreeBasic before, I'd have stopped there, wrote it in a post and left it up to you.

But I haven't, so what's that look like? Is it even possible? I've written COM dlls in other languages so even if I don't remember exactly what to do outright, I probably remember the project it was for or IClassFactory or DllCanUnloadNow or some other part of the machinery that I can search my old code for.
Great, except FreeBasic doesn't work like C++ does ("Type MyClassFactory extends IClassFactory" doesn't work) so I DuckDuckGo-ed "FreeBasic IClassFactory" and it brought up a post from superman himself, Jose Roca. Having acquired a template for laying out a COM object, it's a simple matter of adding and adapting it to the functions IShellIconOverlayIdentifier requires.

GetPriority
The priority value set by GetPriority is not a reliable way to resolve conflicts between unrelated icon overlay handlers. There is no way for your handler to determine what priority values other handlers are using. Normally, you should set the value to zero
So that's easy, just return 0.

GetOverlayInfo
This method is first called during initialization. The method returns the fully qualified path of the file containing the icon overlay image, and its zero-based index within the file.
That's easy enough too. At least it would've been if the "zero-based index" part was also on the documentation page for the function itself rather than just the overview linked above. I had the index as 1 at first and thought this whole method didn't work any more.

IsMemberOf
The Shell calls this method to determine whether it should display a handler's icon overlay for a particular object. It specifies the object by passing its name to the method. If a handler wants to have its icon overlay displayed, IsMemberOf returns S_OK. If not, it returns S_FALSE.
The doc page for this function has a link to IShellFolder::GetAttributesOf to tell you what the attribute values can be. I already knew that SGFAO_LINK is the attribute for shortcuts, but if not, it's in the list on that page. So this seemed pretty simple to implement

Code: Select all

Return IIf(attributes And SGFAO_LINK, S_OK, S_FALSE)
And it didn't work.

Happily I'd put logging in to see what file name and attributes it was sending (that's the experience part) and SGFAO_LINK was never among the attributes. That's where the extension check came from, the file name is already sent so checking that's a pretty quick way to catch the vast majority of them. That's not the 'proper' way though so if both of those say no, the file's proper attributes are queried. If you previously didn't know of SHGetFileInfo, you do know from the IsMemberOf docs that you can get attributes with IShellFolder::GetAttributesOf.

And then it worked.

There you go. Nothing in any of that required skill or hard work. Luck in remembering the IShellIcon thing, but if remembering tangentially related things you've seen was a skill I'd put 'identifying my cousins' on my C.V.
For everything else: everybody can google, everybody (that's programming) can read. It's playing with Lego via reading and typing. You find Brick A from your old stash of parts, nab Brick B from down someone else's settee, find instructions for making Brick C and before you know it, The Commodores have written a song about your brick house. It's ingenuity and imagination at best.

Thank you for attending my TedX talk. Now listen to Art of Noise - The Holy Egoism of Genius
Last edited by adeyblue on Nov 10, 2023 0:50, edited 1 time in total.
deltarho[1859]
Posts: 4313
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Question for adeyblue

Post by deltarho[1859] »

@adeyblue

Thanks for that.
It's ingenuity and imagination at best.
It is having an open mind with unbounded thoughts. It is vertical thinking and lateral thinking, rational and irrational, giving both an equal opportunity to express themselves.

Now listen to Pink Floyd - Sorrow.
adeyblue
Posts: 300
Joined: Nov 07, 2019 20:08

Re: Question for adeyblue

Post by adeyblue »

I swear. there's some sort of law that says if you're British and you were alive in the 60's, you have to love The Beatles. And the same in the 70's for Pink Floyd. I'm pretty sure I spent an afternoon once listening to three or four albums of theirs and while they're not bad by any means, I don't remember anything about it. OK that's not true, everybody knows the video to Another Brick In The Wall, but who knew there were two more parts to song/theme/story whatever you want to call it.

As for The Beatles, where I listened to one album (one of the later ones, can't remember which) and the best parts were
a) The Paul is Dead conspiracy theory
b) Eric Clapton's utter indifference in the face of Paul's best work
Which is to say, I wasn't particularly enamoured.

Then again, I like Russ Abbott's Atmosphere so what do I know about music
deltarho[1859]
Posts: 4313
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Question for adeyblue

Post by deltarho[1859] »

adeyblue wrote:Then again, I like Russ Abbott's Atmosphere so what do I know about music
I have just listened to that and find myself asking the same question: “What do you know about music?” :)

At the end of the day, it is whatever 'floats our boat'. For me, it is violin concertos.

Added: Here is a version of Floyd's Shine On You Crazy Diamond you may not have heard.
thrive4
Posts: 72
Joined: Jun 25, 2021 15:32

Re: Question for adeyblue

Post by thrive4 »

So let's throw a curve ball between
Russ Abbott's - Atmosphere and
Floyd's - Shine On You Crazy Diamond

Nick Drake - Riverman
https://duckduckgo.com/?kl=us-en&q=nick ... dcaRTg4-fM
https://en.wikipedia.org/wiki/Five_Leaves_Left

Quintessential British... ?

Code: Select all

Betty came by, on her way 
Said she had a word to say
'Bout things today
And fallen leaves

Said she hadn't heard the news
Hadn't had the time to choose
A way to lose
But she believes
deltarho[1859]
Posts: 4313
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Question for adeyblue

Post by deltarho[1859] »

Yours truly wrote:At the end of the day, it is whatever 'floats our boat'.
Sorry, thrive4 but after about a minute of River Man my boat started to take in water rapidly and eventually sank.
thrive4
Posts: 72
Joined: Jun 25, 2021 15:32

Re: Question for adeyblue

Post by thrive4 »

deltarho[1859] wrote: Nov 06, 2023 19:42 Sorry, thrive4 but after about a minute of River Man my boat started to take in water rapidly and eventually sank.
Alas... :wink:

Code: Select all

If he tells me all he knows
'Bout the way his river flows
I don't suppose
It's meant for me

Oh, how they come and go
Oh, how they come and go
Musical preferences aside,
nice little thread thank you for initiating it.
deltarho[1859]
Posts: 4313
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Question for adeyblue

Post by deltarho[1859] »

thrive4 wrote:...thank you for initiating it.
This place would benefit greatly from occasional remarks such as that.

Thank you. :wink:
adeyblue
Posts: 300
Joined: Nov 07, 2019 20:08

Re: Question for adeyblue

Post by adeyblue »

And to prove that everything old comes around again
adeyblue wrote: Nov 03, 2023 22:50 IsMemberOf
The Shell calls this method to determine whether it should display a handler's icon overlay for a particular object. It specifies the object by passing its name to the method. If a handler wants to have its icon overlay displayed, IsMemberOf returns S_OK. If not, it returns S_FALSE.
The doc page for this function has a link to IShellFolder::GetAttributesOf to tell you what the attribute values can be. I already knew that SGFAO_LINK is the attribute for shortcuts, but if not, it's in the list on that page. So this seemed pretty simple to implement

Code: Select all

Return IIf(attributes And SGFAO_LINK, S_OK, S_FALSE)
And it didn't work.
Today I bumped into IShellIconOverlayManager and learned why this didn't work.
https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-ishelliconoverlaymanager-getreservedoverlayinfo wrote: IShellIconOverlayManager::GetReservedOverlayInfo
Parameters:
pwszPath
[in] The full path of the file.
dwAttrib
[in] The attributes of the file. This parameter can be a combination of any of the file attribute flags (FILE_ATTRIBUTE_*) defined in the Microsoft Windows header files
The IsMember docs for what the attributes passed to that function are, are wrong. They're not shell attributes (SFGAO_COMPRESSED, SFGAO_LINK etc), they're the normal FILE_ATTRIBUTE_ type of attributes (FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_HIDDEN). That's why I was getting weird attributes of 0x2000 (SFGAO_ENCRYPTED) when I don't have any NTFS encrypted files, because 0x2000 is FILE_ATTRIBUTE_NOT_CONTENT_INDEXED which is far more sensical.

Solving mysteries I didn't even know I was solving, I bet this is how Jessica Fletcher started.
Post Reply