Change dock icon?

maybe ?

Dim droppedReviewImage as Picture droppedReviewImage = Picture.Open(obj.FolderItem)

OK - thanks guys, but I have now tried all the advice and I simply cannot get it to work.
Every time I try I get a different error!

I will give up for now, as I cannot work out the correct syntax.
I appreciate all your help anyway :slight_smile:

Thank you.

[quote=107991:@Richard Summers]OK - thanks guys, but I have now tried all the advice and I simply cannot get it to work.
Every time I try I get a different error!

I will give up for now, as I cannot work out the correct syntax.
I appreciate all your help anyway :slight_smile:

Thank you.[/quote]

Come on, Richard. Just a little effort … Axel gave you the cheat sheet … You can’t simply give up after so little time !

Michel - I have trying this for HOURS before I even posted here :frowning:

I really thought my code below would work - but it didn’t:

[code]if obj.FolderItemAvailable then

Dim droppedReviewImage as Picture
droppedReviewImage = Picture.Open(obj.FolderItem)

Dim g As Graphics = App.DockItem.Graphics
g.ClearRect (0, 0, g.Width, g.Height)
g.DrawPicture (droppedReviewImage, 0, 0)

App.DockItem.UpdateNow

End if[/code]

I simply cannot understand this concept - and I am getting angry with myself.

[quote=107996:@Richard Summers]Michel - I have trying this for HOURS before I even posted here :frowning:

I really thought my code below would work - but it didn’t:

[code]if obj.FolderItemAvailable then

Dim droppedReviewImage as Picture
droppedReviewImage = Picture.Open(obj.FolderItem)

Dim g As Graphics = App.DockItem.Graphics
g.ClearRect (0, 0, g.Width, g.Height)
g.DrawPicture (droppedReviewImage, 0, 0)

App.DockItem.UpdateNow

End if[/code]

I simply cannot understand this concept - and I am getting angry with myself.[/quote]

Richard, I know you often spend time on things and get frustrated. It happens to all programmers. But if you know something is possible and give up prematurely, you give no chance to yourself to attain your goals, and if I know something about you, is that you have ambition and curiosity.

Calm down, go dunk a crumpet in tea, watch TV, sleep on it, then come back to your project and you will be surprised how simple it was. All of us, hobbyists and professionals alike in this forum, experience that. Don’t suppose it is easy for anybody. It may look that way because some of us where here during the dinosaurs era, but we did stumble into hurdles the same way before, and will again eventually.

I notice you now share what you can in the forum. It means you have passed the total newbie stage. And it is commendable. Now you need to learn being easy on yourself and take time to achieve your goals. Put away for tomorrow what cannot be completed today. I know it sounds lazy, but it is wise when it comes to coding.

Now, I just tested your code and guess what ? It is valid. What you need is to insure your app can actually receive the file you are throwing at it :

  • Set the canvas or whatever you drop into with Acceptfocus and use UseFocusRing if available
  • add this :

Sub Open() me.AcceptFileDrop(FileTypes1.any) End Sub

And make sure the picture is 128x128 minimum in size otherwise your icon will simply disappear.

Forgot to mention you need to add a filetype from the library , and into it add the “any” file type. Otherwise the Open will generate an error and you will get angry :wink:

Michel - I have already added that, and I still get the same error?

Michel - thank you for your post and advice :slight_smile:

I actually think my iMac is acting erratic again.
I have now noticed that my segmented controls all have what looks like a double focus ring around them?

Every so often, I need to clear out my system and reset the PRAM.
I will do that and then try again.

Thank you for all your help :slight_smile:
I really appreciate it.

If you cared to post the exact error, then you could get more adequate help…

My post above explains it.
I will sort my system out and then retry.

i made an example with your code, it works
dockicon

Nope. It cannot be “you must use the value returned by this function” anymore.

Ok,
I deleted my cache files, and reset the PRAM, and my code now works.
I can’t believe I spent hours on this and my original code was correct!!!

Stupid Computer.
The only problem I have now is that my code (and Axel’s example) only shows a tiny dock icon?

If you download Axel’s example, and then drop a 512 x 512 png file onto it - you will see what I mean.
I even modified the code to that below - but still only a tiny icon:

[code]if obj.FolderItemAvailable then

Dim droppedReviewImage as Picture
droppedReviewImage = Picture.Open(obj.FolderItem)

Dim g As Graphics = App.DockItem.Graphics
g.ClearRect (0, 0, g.Width, g.Height)
g.DrawPicture (droppedReviewImage, 0, 0, 512, 512, 0, 0, 512, 512)

App.DockItem.UpdateNow

End if[/code]

I am now not sure if it is my computer which is causing the problem, or the code?

Try

g.DrawPicture (droppedReviewImage, 0, 0, g.width, g.height, 0, 0, droppedReviewImage.width, droppedReviewImage.height)

It should work fine for square images. Rectangular ones will be stretched to fit the square.

Those are the worst! I’ve had that happen, makes you think you’re insane :slight_smile:

Michel - that worked - thank you VERY much!

Will - I presumed it was because I am only a novice and that my code must be wrong.
Then I changed my code so much, that it got all muddled up.

I never expected it to be my computer which was the cause.
So annoying!

:slight_smile: :slight_smile:

[quote=108018:@Richard Summers]Michel - that worked - thank you VERY much!

Will - I presumed it was because I am only a novice and that my code must be wrong.
Then I changed my code so much, that it got all muddled up.

I never expected it to be my computer which was the cause.
So annoying!

:slight_smile: :)[/quote]

In the 80s, there was a universal remedy for PC ailments : switch off, wait three seconds, and reboot.

For some reason, this good old medicine still works wonders for all things electronic :wink:

Richard, if you have the next time problems with the code.
Video

Video2

Maybe the problem can be found here. :stuck_out_tongue:

http://archive.wired.com/wired/archive/3.04/pear_pr.html

As a side note, resetting the PRAM hasn’t been required as a “generic” troubleshooting action for years. It’s useful in very few, very specific scenarios.

It’s not that it’s bad, since it’s inocuous to do if nothing is broken anyway, but including it in your troubleshooting efforts along with a bunch of other things ensures that you won’t be able to isolate whatever might’ve been failing, which in turn means next time you’ll have to try everything again.

Your best bet is to try each of the things you would normally try for troubleshooting and check if the error persists. This helps you isolate the issue in the future and, eventually, fix it (assuming it’s an error related to the troubleshooting actions).