BBC BASIC for Windows
Programming >> User Interface >> Assigning user icon to title and task bar
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1257284398

Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 3rd, 2009, 8:39pm

Can anyone point me in the right direction for replacing the given BBC icon in a programme? I have done...

SYS "LoadIconA",@hwnd%,@dir$+"LAN_title.ico" TO ret%

but it obviously takes more than that. I got lost on MSDN rather quickly, and Win-API Viewer did not offer any likely (to me!) suggestions. I had no luck on wiki either.

Thanks,
--Grahame
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 3rd, 2009, 9:22pm

I think I have got part way there by reading last what I should have read first: the BB4W Help on API calls.
I've got as far as putting the icon in the system tray, but I really want to replace the BBC icon in the title bar. How would I do that?
--Grahame
Re: Assigning user icon to title and task bar
Post by admin on Nov 3rd, 2009, 9:39pm

Quote:
I've got as far as putting the icon in the system tray, but I really want to replace the BBC icon in the title bar.

Replacing both is simply a case of selecting (or browsing for) the icon in the Compile dialogue, or adding a REM!Icon compiler directive:

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin1.html#executable

Don't attempt to change the icon when running under the IDE - it's BB4W's icon not your program's icon so please leave it alone! To give your program its own icon (and benefit from other Windows features like automatically remembering the folder last opened in a 'file selector') you must compile it. The intention is that you should only run your program under the IDE whilst it is being developed and debugged.

Richard.
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 3rd, 2009, 10:31pm

That's perfect, Richard, thanks very much.

Incidentally, I have been using an icon editor called "Greenfish" which insists that the standard size for Win-XP icons is 20x20 for the window, 24x24 for the toolbar, but that is simply not true. They have to be sourced at 16x16 or they look nasty.

--Grahame
Re: Assigning user icon to title and task bar
Post by admin on Nov 4th, 2009, 08:42am

Quote:
"Greenfish" which insists that the standard size for Win-XP icons is 20x20 for the window, 24x24 for the toolbar, but that is simply not true

There's not really any such thing as a 'standard' size, because it depends on the version of Windows, the selected Theme, the DPI setting etc. etc. That's why, for best results, you have to provide a set of icon images at different sizes (since icons don't scale well).

You can find some of the sizes relevant to your particular system configuration using SYS "GetSystemMetrics" with the SM_CXICON, SM_CYICON, SM_CXSMICON and SM_CYSMICON parameters.

On my XP PC the main icon sizes are:

small: 16x16 (e.g. used for titlebar/taskbar)
medium: 32x32 (e.g. used for desktop shortcuts)
large: 48x48 (e.g. used for explorer's tile view)

You should generally provide these sizes as a minimum, plus 256x256 (compressed) for best results on Vista.

Richard.
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 5th, 2009, 02:53am

Thanks Richard, just the information I needed.

I really missed that early borrowed icon for your magglass.exe programme, though I understand your reasons for not borrowing it for too long. I thought the least I could do was create a |free| one for you to use, so I have uploaded it to the http://tech.groups.yahoo.com/group/bb4w/files/WindowsAPI/ site as GEP_Mag-Icon.ico It was drawn at the four sizes you recommend and looks fine to me on desktop, icon tray, title bar and Explorer thumbnail, tile & icon. I don't have VISTA, but hopefully it would not do anything too bad to it.

It would certainly be a good help to me if you were to rebuild magglass with an active tray icon. I have successfully prototyped -- on a simple test-bed -- your original <rt-click> menu snippets for "&Hide" and "&Show", so hopefully they would work for magglass ( I can't know the answer to that). I find I want to get the glass off the screen quite often, and it is tedious to have to Close and re-Open the programme. A simple icon-tray control would be perfect.

--Grahame
Re: Assigning user icon to title and task bar
Post by admin on Nov 5th, 2009, 10:22am

Quote:
I really missed that early borrowed icon for your magglass.exe programme, though I understand your reasons for not borrowing it for too long.

I don't understand: I am still using that very same icon for the Magnifying Glass! I have no plans to change it. If the icon isn't showing up on your system I have no idea why.

Quote:
It would certainly be a good help to me if you were to rebuild magglass with an active tray icon.

What would you want the SysTray (Notification Area) icon to do? It's normal to have one of those for a program that has no window, yet continues to run 'in the background', but not for a regular 'transient' application like the Magnifying Glass. I suppose it could duplicate the functionality of the right-click context menu, but I can't see any point.

Incidentally, early versions of my Magnifying Glass displayed an icon in the taskbar, which of course they shouldn't have because it doesn't have a minimise capability (or indeed any Windows menu); the taskbar icon simply wasted space with no function. I've fixed that in later versions; the window now has the WS_EX_TOOLWINDOW style which is intended for just this kind of application.

Richard.
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 5th, 2009, 12:13pm

My point would be that a <rt-click> on the tray icon would allow you to 'Hide' -- SYS "ShowWindow", @hwnd%, 0 TO ret% -- or 'Show' -- SYS "ShowWindow", @hwnd%, 1 TO ret% -- the magnifying glass, for those occasions where you wanted it completely off the screen in between active use. This is not possible at present, without Close-ing and re-Opening the task, which is somewhat tedious. I would not suggest to duplicate the window <rt-click> functions in the tray <rt-click> functions, although it might be helpful to add 'Hide' to those options.

--Grahame
wink
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 5th, 2009, 12:38pm

I do not wish to belabour a rather small affair, but there are some operationsl constraints resulting from the lack of an active tray icon, relating to the inability to bring the magnifying glass back into 'focus', i.e. to the top of the z-stack.

While it is easy to "Hide' the glass by bringing the primary application to the top, there is no simple way to put it back below the glass. One has to move the primary application to one side, move the glass away from where one wants the primary application to be, move the primary application back to where one wants it, then move the glass over that window. This method makes it impossible to run the primary application at Maximised, which one often wants to do with pixel-perfecting applications.

Magnifying Glass does not appear in the <Alt><Tab> listing, so one cannot use that method to bring it to the z-top position.

Just based on my usage experience.
--Grahame
Re: Assigning user icon to title and task bar
Post by admin on Nov 5th, 2009, 3:37pm

Quote:
there are some operationsl constraints resulting from the lack of an active tray icon, relating to the inability to bring the magnifying glass back into 'focus', i.e. to the top of the z-stack

The Magnifying Glass is already a 'topmost' window so it will always appear in front of all non-topmost windows. Unless you are in the habit of wanting to magnify the contents of another topmost window (e.g. Task Manager) you should not need to 'bring it to the front'. And if you are routinely creating your own topmost windows - DON'T!!

Quote:
While it is easy to "Hide' the glass by bringing the primary application to the top

There is something seriously wrong if you can do that. As the Magnifying Glass is a topmost window, you can't (or shouldn't be able to) bring another non-topmost window in front of it. Some investigation is required!

Quote:
One has to move the primary application to one side, move the glass away from where one wants the primary application to be, move the primary application back to where one wants it, then move the glass over that window.

If one had to do that it would indeed be completely unacceptable, but I use the Magnifying Glass a lot and I never have to do it.

Quote:
This is not possible at present, without Close-ing and re-Opening the task, which is somewhat tedious.

Do you have a particularly slow PC? On my PC closing the Magnifying Glass (right-click, Exit) is just as fast as hiding it using a Systray menu, and opening it again (double-clicking on its desktop icon) is almost instantaneous. Obviously if you're running a full-screen application (ugh!) you may not be able to get to the icon quite as quickly.

Normally what I would suggest, if you're not satisfied with how my program behaves, is to modify it yourself, because my habit has always been to release source code. However there has been something of a recent trend for other group members to release only compiled executables (often encrypted) so on this occasion I decided to follow suit.

Richard.
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 8th, 2009, 03:36am

Perhaps the inabilityof MagGlass to stay always on top at this location is to do with the NVIDIA drivers I happen to use for my EVGA-NVIDIA cards? I only suggest that because NVIDIA software is, how shall I say, quirky anyway.

I can understand people not wanting to release their source code, everytime.

--G cool

Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 8th, 2009, 03:58am

Since you said that MagGlass should never go behind another, I've checked it out a bit more. It happens with all of 7 applications I tried it on, none of them are supposed to be "always on top" and none of them are. However, bringing them to the top -- on top of MagGlass -- is a bit erratic: Sometimes it only takes one <left-click> on the app.s title bar, sometimes it takes 2 or 3. I find MagGlass may be more likely to disappear behind, with mouse movement at the same time as the title-bar click, it seems to be a phenomenon of statistically linked timing on the IRQ service. (?)

[If the 'test' application window had focus before moving MagGlass over it, it immediately loses focus (as expected).]

Hope this helps a bit.
--G
Re: Assigning user icon to title and task bar
Post by admin on Nov 8th, 2009, 09:40am

Quote:
However, bringing them to the top -- on top of MagGlass -- is a bit erratic: Sometimes it only takes one <left-click> on the app.s title bar, sometimes it takes 2 or 3. I find MagGlass may be more likely to disappear behind, with mouse movement at the same time as the title-bar click

Try it with Task Manager instead: can you move a normal (non-topmost) window on top of that? Another window that should always be on top is BB4W's List Variables window, so you might like to try that one as well.

There's a caveat in the docs for SetWindowPos which suggests that I should be specifying the SWP_NOACTIVATE parameter (I'm not). I've modified the program just in case that's what's causing the anomaly on your system:

http://groups.yahoo.com/group/bb4w/files/Graphics/magglass.exe

Richard.
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 8th, 2009, 6:48pm

That seems analytical.

Using the original version, it seems that the window in focus and being moved has the priority for being on top. I can move task manager or BBCList Variables or MagGlass on top of any other window (including those in its "on top" group) and it will stay on top. When I select (title bar) the now underneath window then that will always come immediately, permanently on top if it is an "on top" window, or it will come on top after 1-3 (varies) title-bar clicks if it is a normal window (there is no way to select MagGlass when it is underneath, because no tray or task bar icon).

If I slide Task Manager across List Variables ( or vice versa) then the window being moved is the one which is immediately on top. The same also applies to moving them over MagGlass. The same applies also to a normal window slide across Task Manager, List Variables or MagGlass: the window being moved - although it has no Z-priority - goes immediately on top.

If I move a normal window over List Variables or Task Manager (but not MagGlass !) and then click the spuriously on top title bar (already in focus) 1 or 2 times, the underlying -- nominally "on top" -- window will resurface. Everything is then as expected.

In the case of a normal window slide across an "on top" window (Task Manager or List Variables but not MagGlass) I can toggle hide/show of the "on top" window just by repeatedly clicking the title bar of the normal window.

It seems to me that this part of Windows XP is a bit flaky (a bit like the "by agreement" multitasking in Windows 3 etc.). It's fairly easy to cope with this when the windows are all smallish and have corners, but almost impossible with MagGlass which has no corners to 'grasp' and is usually used in combination with a large, if not maximised, normal window.

I will download your revised version, see if SWP_NOACTIVATE makes a difference. Thanks for the continued study.
--Grahame

Re: Assigning user icon to title and task bar
Post by admin on Nov 8th, 2009, 9:45pm

Quote:
it will come on top after 1-3 (varies) title-bar clicks if it is a normal window

In that case I'm sorry to say your PC has a serious fault. There should be no way in which you can move a non-topmost window in front of a topmost window.

Quote:
It seems to me that this part of Windows XP is a bit flaky

I have never heard of anybody else being similarly affected, so I have no reason to suspect that a bug in XP is to blame. In your position I would be extremely concerned. I would recommend re-installing Windows to see if that fixes it.

Richard.
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 8th, 2009, 9:59pm

OK, so I have tried out the SWP_NOACTIVATE version, and perhaps it is different, but it is still very easy to lose the MagGlass below a normal window.

In a simple situation where a normal window is dragged over MagGlass, and MagGlass disappears, it may be possible to get it back by <exactly 2x left-click> the title bar of the normal window, and it can be toggled up/down by repeating <exactly 2x left-click> (very non-conformal useage!). I have one app (it's a file backup utility) which never goes spuriously "on top", but when I try to drag its window under the MagGlass AND if it is the title bar of the normal app. which is contingent upon MagGlass, then MagGlass moves off ahead of the app window. Wierd! The workaround is just to drag MagGlass on top of it.

I don't much like these various "workarounds", they strike me as worthy of going in my not-so-sweet cookie jar labelled "devious tricks which work, sometimes".

Personally, I think an icon (your choice wink ) in the icon tray with a <left-click> {send to top} and a <rt-click>{Hide}/{Show}(with implicit "on top"), would solve the users' problems with this obviously tricky Z-listing under Windows.

--Grahame
Re: Assigning user icon to title and task bar
Post by admin on Nov 9th, 2009, 08:29am

Quote:
Personally, I think an icon (your choice ) in the icon tray with a <left-click> {send to top} and a <rt-click>{Hide}/{Show}(with implicit "on top"), would solve the users' problems with this obviously tricky Z-listing under Windows.

You keep repeating the same claim: that the effect you are experiencing is something normal for Windows. IT IS NOT. It is a fault on your particular system which you need to get fixed. It would be crazy for me to make a change to my software simply to workaround a problem unique (as far as I know) to you.

Please take the fault seriously, rather than blaming Windows. I have asked a question on microsoft.public.win32.programmer.ui but so far nobody has come up with any suggestion as to the possible cause.

Have you tried re-installing Windows? Have you checked whether there are any later graphics drivers for your PC?

Richard.
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 9th, 2009, 5:20pm

Thanks for your analysis and concern. It's no fun being an exception, is it? undecided I will take your recommendation to re-install XPsp3 as sound advice but I won't be doing it any time soon, it's less than two months since the last mandatory re-install and it takes me for ever on this heavily loaded machine. I did a Registry Restore just two days ago.

Anyway, thanks for providing MagGlass, it's a really neat app.

--Grahame
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 9th, 2009, 5:22pm

For some reason, your latest reply did not show until after I sent mine. I wholly agree that your code should not be changed to suit some aberrant installation!

--Grahame

Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 9th, 2009, 5:56pm

Well, I have just tried MagGlass on my other Win-XP mahine, and I get the same bizarre results. So my problem is not with a particular system becoming corrupted, it's the software configuration which is incompatible with what Wn-XP requires of its Z-ordering routines. Both PCs have this in common [[ Win-XPsp3, EVGA(NVIDIA)9500 GT graphics card running in dual display mode]]. I am inclined to suspect a problem due to NVIDIA software, and will try to resolve that. For the most part my display drivers work just fine. I am running FP-intensive CUDA number crunchers on both cards with no errors.

I'm sorry that this all seems to be coming incidental to the main purpose of the forum.

--Grahame

Re: Assigning user icon to title and task bar
Post by admin on Nov 10th, 2009, 09:03am

Quote:
Well, I have just tried MagGlass on my other Win-XP mahine, and I get the same bizarre results.

Incredible. The only response I've had from the Microsoft newsgroup is a suggestion that you might not have enabled the Always on Top option in Task Manager!

The only possible explanations I can offer are (1) a fault with the NVIDIA graphics drivers or (2) hallucination! Can you take and upload a screen snapshot irrefutably demonstrating the effect?

Richard.
Re: Assigning user icon to title and task bar
Post by Michael Hutton on Nov 10th, 2009, 09:34am

Quote:
However there has been something of a recent trend for other group members to release only compiled executables (often encrypted)


I am guilty of doing that lately. At the moment it seems to be a bit easier for me to get a 'demo' going, compiling and upload. And I do press the encrypt option. I don't know why, i've tried translating compiled code from an exe before and it is a nightmare. Anyway, please don't think that I am trying to 'hide' code. Well, maybe I am a bit embarrassed by the inefficiency of it...

Sometimes it is also just for the efficiency of getting the demo out with a custom library file rather than uploading a bbc file and uploading the library files separately.

I will stop pressing the encrypt option!

Michael
Re: Assigning user icon to title and task bar
Post by 19Grumpah42 on Nov 10th, 2009, 3:39pm

Thanks for pursuing the windows group as a resource, Richard.

I had never visited the {Task Manager}{Applications}{Options} menu item before, but I note that MagGlass is clocking in as [always on Top] [Minimize on use][NOT hide when minimised]. I also note that some other running tasks were -- apparently randomly -- flagged [Always on Top] but in fact they do not behave that way. So, I query the functionality of this particular Windows setting.

I can make a a movie file showing (a) normal windows sliding |over| MagGlass, (b) normal windows "pushing" MagGlass in front of them. Perhaps I will do that when I have time.

--Grahame
Re: Assigning user icon to title and task bar
Post by admin on Nov 10th, 2009, 4:56pm

Quote:
I had never visited the {Task Manager}{Applications}{Options} menu item before

A slight misunderstanding there, I think. The Options menu refers to Task Manager itself, not to the program selected in the Applications tab!

When Always On Top is ticked, it means that Task Manager is a topmost window.

Richard.