Blog posts tagged: windows
News and other things I find interesting
Mozilla Firefox and silent updates
Last modified: Monday, March 26, 2012
Mozilla's rapid release process allows us to deliver features, speed optimizations, memory reductions, and much more... faster.
Keeping up to date fast is an essential need for the ever changing web.
There is a new release of Firefox every 6 weeks instead of every year. Even with this shortened release cycle, these releases still include major enhancements. These faster updates are possible because Mozilla is growing significantly, and the community of Mozillians at large is growing month over month.
The rapid release process has some very positive side effects, like delivering new web technologies faster, and attracting world class developers who like to see their code ship fast. But rapid releases also have some negative side effects.
One of the negative side effects is that minor annoyances with software updates suddenly become much more noticeable. Most users don't want to think about software updates nor version numbers and now they are being forced to do so every six weeks.
One such minor annoyance is User Account Control (UAC):
Starting with Windows Vista Microsoft introduced UAC, and with it users across the world see this familiar dialog when doing any operation that requires administrative access:

UAC in particular makes every process run with limited permissions, and if you want to do something like write into Program Files, then the user has to give permissions to the application to do this.
This makes things like automated software updates hard to do without user interaction. If we don't have access to write into Program Files to perform an update, then we have to ask for elevated permissions. We ask for elevated permissions today when applying updates.
If a user with administrative access gives permissions to Firefox one time via a UAC prompt, and that user has automatic updates on, then there is no reason we should continue to ask them to elevate the permissions each and every time we want to apply an update. The user has already explicitly given permission to do it.
If this worries you, just remember that you can change your mind at any time by configuring silent updates on the Options > Advanced > Update tab.
The feature page for this task is located here: Remove requirement for the Windows UAC dialog when applying an update. I am the lead developer on this UAC task and the estimated target is the first quarter of 2012.
What's being done to solve the UAC annoyance:
There are several ways to tackle this issue. For example, some browsers that offer silent software updates will install into the user's application data folder and hence do not have this problem. We could do the same, but we chose not to because it can be an administrative headache for some people who manage updates themselves and have to maintain an installation for every user.
We are currently experimenting with a Windows service approach.
This means that an optional component will be installed that automates the software update process better without giving UAC prompts.
Only one Firefox service:
There are four different Firefox development channels you can use. At any time there is a Firefox Release channel, Beta channel, Aurora channel, and Nightly builds channel. These channels give you access to Firefox releases at different stages of the development cycle.
A user can have multiple installations across channels, but only one Firefox service will exist in Windows Services.
Firefox service as an optional component:
The Firefox service will be an optional component. It doesn't need to be installed, and if it is stopped or disabled, updates will work as they did before in every other recent Firefox release.
A user can also uninstall the Firefox service at any time. Updates will continue to occur using the old method.
Other uses of the Firefox service:
Having a Windows service installed means that we can investigate other integration and maintenance points. The possibilities are very exciting.
The Windows service may be used later on for a wider selection of maintenance related things including faster browser startup via prefetching, but initially will be only for software updates.
High level overview of other new Silent update features
Above I mostly talked about silent updates on Windows, but there are other update issues being addressed in several new features across all platforms. This section was originally written by Robert Strong with help from Chris Lee, and Lawrence Mandel and describes these features.
All of the silent update work can be tracked on the wiki.
-
Lessen how often the "What’s New" page is shown
Estimated target: fourth quarter of 2011.
Every six weeks Firefox informs you of what is new in the release. The feedback from our users is that the information is not required and is actually an irritant. We are looking at ways of displaying information only when it provides benefit. The ability to control if the "What’s New" page should be displayed after an update was added to Firefox 4. The server side capability should be completed soon. -
Lessen how often the update user interface is displayed
Estimated target: first quarter of 2012.
After an update is downloaded in the background Firefox waits 12 hours before notifying the user to restart to apply the update and since this can interrupt tasks the wait time is being increased to 24 hours. More details including how we decided upon 24 hours are available on this feature page and the bugs referenced on that page. -
Add-ons Default to Compatible
Estimated target: first quarter of 2012.
By default, Firefox requires consent to update if there are add-ons that are enabled and compatible with the current version of Firefox and are incompatible with the update’s version. With this feature there should be significantly fewer cases where consent is required to update Firefox while keeping your add-ons installed and up-to-date as well. -
Apply updates on shutdown
Estimated target: to be determined.
After an update is downloaded users notice that it takes longer to start up Firefox on the next run. This wait time is due to the installation of the software update. To eliminate the wait time on startup to apply an update the majority of an update’s operations will be performed prior to shutdown and the few remaining operations will be performed after Firefox has exited. This applies to all desktop platforms though on Windows the service that will remove the requirement for the Windows UAC dialog will typically apply the update. -
Improved process flow for updating when there are incompatible add-ons
Estimated target: to be determined.
If an update is declined when there are incompatible add-ons the time to wait until next notification will be increased. This feature is in the planning stage and the amount of time to wait until the next notification hasn’t been decided as of yet.
Other Mozilla products:
Other Mozilla products may use the service described above. We currently plan to have only one Windows service across all products. All supported architectures are also planned to share the same Windows service.
Every feature described in this post either applies to or can be done for other Mozilla based applications such as SeaMonkey, Thunderbird, and SongBird.
Platform Integration team:
Mozilla started a new Platform Integration team which focuses on issues which need Operating System specific solutions.
I am a member of this new team led by Robert Strong. Some of the tasks being worked on by this team are described above.
Tags: uac windows mozilla firefox silent-update
Add a new comment | 39 comment(s)
|
The service is a good solution, but an small advice, Windows permit to add services with different ACLs, for example you can define that it can be started by any user. I did a long time ago an application updater, that worked this way. 1) The application executable downloaded the update files this way the Updater Service is not a long running process, It only runs when the update is being applied |
|
Thanks for the detailed post. It's a shame these things couldn't be taken care of earlier, but I'm very glad to se it happening now. |
|
Can I ask why the service is always running? Could it not be demand start? |
|
Faster launch via prefetching? That sounds suspiciously like those processes Java, Open Office and a million other applications sneakily install to slow down your OS boot (because no one will ever notice that, right, and if they do, they'll just blame Microsoft instead of us), in order to marginally speed up "our" software. Please think thrice before embarking on something like that. It's possible that it could be pulled off without actually slowing down other parts of the OS, but on the surface of it, it sounds like a great way to get binned with Java and all the other crapware that stealthily makes Windows suck just to make their own software load marginally faster. |
|
Thanks for the excellent ideas and comments. Re: Starting the service on demand. That sounds like a great idea and I'll look into doing this. Re jalf on prefetch bloat: Other uses of the service is purely speculative right now and slowing down the system is the absolute last thing we'd ever let ship in the product. Thanks for the insight though, it's appreciated. The thing I wanted to try in particular was loading the DLLs that we're already loading for the service via memory from the app instead of from disk. So a custom built LoadLibrary that works from memory instead of disk. |
|
Actually I've never saw this mechanism behaving like described when I boot into Windows 7. |
|
We will only ask for elevation right now when the user installs into a protected directory that requires elevated permissions like Program Files. Most users install into Program Files today, but if you don't you will not see those prompts. |
|
Update prompts are also worse because of another bug: it will warn you not only if addons *become* incompatible, but also when they *remain* incompatible. So most users will see a warning that several Java Console extensions are incompatible, even though they've been incompatible for ages. |
|
You can also look into what Chrome currently does. They use Windows Scheduler to schedule their update app to run at predefined periods of time. Though it's not ideal either, it's still better than a constantly running service. With sneaky changes like running services and requiring special permissions on mobile(*), FF is rapidly charging into the spayware land. |
|
Thanks for the suggestion Walter, but I don't think it will apply to Firefox. Chrome was mentioned above about how other software does software updates, but it does not apply to us because we install by default into Program Files unlike Chrome. I wouldn't call this a sneaky change as it is a public change, and it is optional. Our intent is only to not annoy users, Mozilla is non-profit organization and the one web browser on the Internet that you can trust above all others. |
|
You've probably already thought of this, but for the update-on-shutdown bit it might be worth it to see if you get any notifications if the whole session is going away (i.e. logout / reboot / poweroff) and avoid it in that case. Having to wait for things as you leave is probably more aggravating... |
|
Mook: Absolutely, good eye. That's on the list already and probably one of the harder parts of that task. |
|
Looks like a great slate of work -- I'm happy to see the UAC prompt finally go away! Random comment on updating on shutdown... It might be interesting to look at ways of applying most of the update _while_ you're running (eg to an inactive staging directory), so that there's just minimal work left to actually apply the update. Then it doesn't really matter if that's done on launch or shutdown, because it would be extremely fast. |
|
Hello. Do you know why Firefox is installed into %userprofile%\Documents\ if the user has no admin-rights (example: on machines at works, the users are no admin)? Is it normal? What about this behaviour and the new Windows service feature? |
|
As always, take care of security issues. Having a new service running is a new door for attackers. |
|
Yeah, faster updates, new releases, new this and that .... sounds great, but .... f.e what about good testings ? What about bugs and why is it necessary to speed up the development ? I´ve enough to work, so i won´t have a new (or only updated) software every few weeks to install, learn what´s new and so on and so on. If every company speed up their release cycles, where shall it go ? More and more things, that changes in shorter and shorter times ? And if the peoples = users can´t get through, sometimes they need to sleep :-), what then ? Speed up things isn´t a good solution. regards |
|
If you are thinking about other uses of this service, try to name it differently. |
|
It's great news that the UAC dialog is finally going away. Thank you! Is there already a project under way for fixing the analogous problem for Mac? Updates don't work smoothly on Mac due to file permissions if Firefox is run by a user who isn't the user who installed Firefox. |
|
> "It might be interesting to look at ways of applying most of the update _while_ you're running" Yup we're talking about this already, thanks for the suggestion. > "Do you know why Firefox is installed into %userprofile%\Documents" I think it will apply there if you install as a limited user account. > "As always, take care of security issues." We will be scheduling a security review this week on the project to ensure we're on the right track and that we're thinking of everything. > what about good testing ? ... I personally believe that the new development channels that we have will ensure a more stable product. More users are using the pre-releases for longer periods of time now who accept that it's not a final release and may have some issues. |
|
> The Windows scheduler cannot be used to automatically gain elevated permissions. This is not correct from what I understand. Scheduled tasks may run with elevation, see http://www.winhelponline.com/blog/run-programs-elevated-without-getting-the-uac-prompt/ for an example or the description of the "Run with highest privileges" option in TechNet (http://technet.microsoft.com/en-us/library/cc722152.aspx) If you made your decision to implement an update service based on the assumption that this was the only way to bypass the UAC prompt, then I'd be glad if you reconsider that decision. Anything that does not rely on yet another update service permanently up and running with full privileges will be much better. |
|
> If you are thinking about other uses of this service, try to name it differently. The name is very much an open question still and won't be as I mentioned above. > Is there already a project under way for fixing the analogous problem for Mac? Please post to https://bugzilla.mozilla.org/enter_bug.cgi?product=Toolkit in the component Application Update to ensure. > ... Scheduled tasks may run with elevation ... Right I didn't say they can't run elevated, just that they can't be used as a trick to run elevated for unelevated processes. > Anything that does not rely on yet another update service permanently up and running with full privileges will be much better. I think we'll only start it when needed and shut it down again right, so it will have no overhead on system performance. |
|
>> "I think it will apply there if you install as a limited user account." Thanks for replying. Don’t you think it's a "largesse" that takes Firefox with the limited Windows user account? Does not Firefox stop the install in such a case? |
|
Concerning starting the Update service on demand (via Task Scheduler): that is how Google's Update Service does it, and it works really well. I would very much prefer this solution over a prcoess running all the time. |
|
> Does not Firefox stop the install in such a case I have never tried it myself but I've heard that it's allowed. |
|
I wonder if and how you ever will make firefox fit into a company's infrastructure. AFAIK there is no real support to deploy FF in an ADS-environment. Same being true for centralized management via GPO. Till some point we were ready to accept all this, but re-installing/patching every 6 weeks in a managed network (i. e. no user ever has an account with admin privs) is simply a waste of time and money. My boss is thinking of switching to chrome, because in his view chrome suits the needs of our it budget. If somehow, someday MS is to make an reasonable secure browser, company it stuff will gladly skip any third party browser. |
|
> I wonder if and how you ever will make firefox fit into a company's infrastructure I think this article may be of interest to you: https://wiki.mozilla.org/Enterprise/Firefox/ExtendedSupport:Proposal |
|
If there is one thing that would get me to drop Fire Fox completely, it would be forced updates. I like fire Fox but I detest the every 6 week updates and the resulting loss of crucial add-ons. I updated to FF 7.1 and lost the ability to reach several websites. Luckily. I still had the 6.0 DMG and was able to reinstall. I will not accept forced updates. |
|
Please enable this as soon as possible. It will protect the majority of layman users and more technical have a option to turn it off so it is a win win situation. |
|
Ahh, not one more boot service please. Would it be possible to integrate with, for example, Google Update Service instead? |
|
> I will not accept forced updates. You can configure updates in the Options. > Ahh, not one more boot service please It will not be a boot service, it will be an on demand service. |
|
Will the enterprise version be available to consumers? I really detest this rapid update cycle. I think once a year is plenty often for Fx to upgrade to a new version. I've been using Mozilla browser from 2001 and then Phoenix, Firebird, Firefox and this is the worst change I have seen in all these years. I very much want to use the Enterprise version. I want to be able to use the Enterprise version although even with it the upgrades are too frequent but a lot more sensible than with the consumer version. |
|
> Mele20: The updates tab in Options is probably your best bet you can turn off checking for updates there. |
|
Yes! A service-based update model will allow co-existence of updating and sandboxing on end-user machines. I prefer to set up friends' WinXP computers with Firefox (because XP does not have the half-decent IE9) and Thunderbird (to avoid migration issues between some of the MS email clients), but also with Sandboxie. At the moment this means having to turn off automatic updates, and give the end-users precise instructions for manual updates (shut down the sandboxed programs, open them normally, and manually trigger the updates). Roll on Q1 2012. |
|
I absolutely needs some extensions (not in AMO) and do not accept to update if they are not compatible to the new release. |
|
> So I don't wish to have an automatic update without my control ! You can configure this to do everything you want already, and in the future via the preferences. |
|
>> ... Scheduled tasks may run with elevation ... > Right I didn't say they can't run elevated, just that they can't be used as a trick to run elevated for unelevated processes. It's not a way for a process to auto-elevate itself, that's right. But nonetheless you should take a look at the schtasks.exe utility coming with Windows Vista and 7. It's able to start a previously defined elevated task from an unelevated process. |
|
Brian- |
|
I wanted to mention this to the developers of the silent update service - if the service ever attempts to connect to the internet, firewalls will block it and it will be unreliable. If the download is done by the browser and then the updating is done by the background service that should work much better. |
|
The browser will do the download, the service will use the already downloaded update. A signature check is done on the downloaded file to ensure it has not been tampered with by the service before applying the update. |
Windows 8 and Thunderbird first looks
Last modified: Thursday, September 15, 2011
I just wanted to post a quick follow up to my Firefox on Windows 8 post on how Thunderbird works with screenshots.
As with Firefox and other applications, as soon as you install Thunderbird it shows up as a Tile in the metro interface.
Clicking on it exits the tablet metro interface and goes into the old interface and launches Thunderbird.
One important thing is that if you click on a mailto: link in Internet Explorer it won't launch the default mail client. Instead it prompts with this error:
Windows Internet Explorer
Could not perform this operation because the default mail client is not properly installed.
Here's a screenshot of that error message:
I assume once this registration problem is fixed it'll launch the Desktop mode and then launch the email client. It would be nice to have a metro interface for Thunderbird as well.
Perhaps even a metro style compose email window application only for when a user is browsing in tablet full screen mode and they click to send an email with their default email client.
Related Bug:
- Bug 686836 - Launching default email client in Windows 8 results in error
Tags: thunderbird windows mozilla windows8
Add a new comment | 2 comment(s)
|
You write so honetlsy about this. Thanks for sharing! |
|
thats it. Im still wondering if there will be a "real" win8 version of thunderbird. would be pretty sad if they would forget about that. it's all about comfort, isn't it? :) |
Windows 8 and Firefox first looks
Last modified: Thursday, September 15, 2011
As you probably already know, Windows 8 introduces the new default Tablet interface, and the old normal Desktop interface. It uses the new tablet interface as the startup interface even on Desktops though. For a good rundown on all of the new features, see here.
When you first boot up into Windows 8, it takes you briefly for about 1/2 of a second to the desktop interface and then switches directly to the tablet interface. I had read previously that the desktop/explorer process was only loaded into memory if you clicked it, but it seems to not be the case for this early pre-beta release.
The next thing you notice is that once in the Desktop interface, the start menu button no longer brings up a menu. It brings you back to the tablet interface. Pressing the Start/Windows keyboard button will take you between the 2 interfaces.
Firefox on Windows 8:
The first thing I did was install Firefox.
After installing Firefox, Windows will ask you which web browser you would like to use by default. It shows you a picture of Firefox and IE and lets you pick. Nice interface. It shows you this dialog even before our process starts. If you change focus to another tab or application though, the dialog goes away forever unless you uninstall and reinstall Firefox.
After installing we show automatically into the tablet interface as a new tile.
But when you click on the Firefox icon in the tablet interface, it takes you directly to the old Desktop environment and loads the Firefox process as normal. I think it'll be possible for integration like IE does into the tablet interface direclty. Although the solution may have to be 'creative'.
Full screen mode in Firefox works the same as previous versions currently. If you start in full screen it will switch you first to the Desktop mode, and then launch full screen. Exiting full screen leaves you at the Desktop interface.
Internet Explorer Tablet Mode:
If you start Internet Explorer from the tablet mode you'll see a full screen app with no switch to Desktop. It has a nice interface and allows you to pin any web page to your Tablet interface as a tile.
The problem with this is that even know I set Firefox as my default browser, through the Windows interface, it still launches IE for these shortcut tiles.
Here is a tile created on the far left from a pinned page in IE of the mozilla.org page:
Work to be done for Firefox on Windows 8:
There's probably a ton, but here are a few things that come to mind:
- We need to support the VS2011 developer tools for MozillaBuild
- It would be nice to not need to switch to Desktop to launch the browser.
- Platform integration for apps seems very important. We should be showing up as tiles for web applications that launch Firefox full screen.
- The Firefox tile can be leveraged to have more functionality built into it.
Related bugs:
- Bug 686835 - Investigate using XPCOM in a metro style application, and providing Firefox as a Metro app
- Bug 686837 - Add VS2011 support for mozilla-build
- Bug 686839 - Investigate Windows 8 metro tile integration
- Bug 686840 - Investigate the ability to toggle between a metro app and a native app
Tags: windows firefox mozilla windows8
Add a new comment | 2 comment(s)
|
firefox not working as in current win 8. Ucant access options panel by touch, also drop down list not working by touch. |
|
i am using windows 8 |
Five Windows 7 taskbar features available to developers
Last modified: Thursday, September 08, 2011
Believe it or not the Windows 1.0 taskbar looked very similar to the Windows 7 taskbar. But it obviously didn't have anywhere near same functionality.
Windows 1.0:
Windows 7:
The Windows 7 taskbar is pretty awesome. And it has some great functionality available to developers who wish to take advantage of it.
The 5 features...
1) Application progress in the taskbar: Progress for anything with visual displays of errors and warnings.
2) Overlay icons: Small icons within your icon for any type of user notification (below shows the online status as an overlay)
3) Custom thumbnail preview groupings: Thumbnail previews across processes or within a single process with tabs
4) Taskbar action buttons (Thumbnail toolbars): Buttons inside the taskbar icon's thumbnail preview
5) Jump lists: Easily create shortcuts to different startup types and other custom actions.
Before you start...
Before jumping into the interesting stuff, you need to get notified that the taskbar button was created.
There is a new message sent to your application called TaskbarButtonCreated, it is sent when Windows creates a taskbar button for your application on your application's behalf.
And once this message is sent to you, you can interact with your taskbar button (Not before!). To get the identifier of the message you need to call RegisterWindowMessage .
The important elements here in a typical MFC application would look like so:
//Get the message identifier
const int TaskBarButtonCreated = RegisterWindowMessage(L"TaskbarButtonCreated");
//Put this in your message map to register a callback
ON_REGISTERED_MESSAGE( TaskBarButtonCreated, CTaskBarTestAppDlg::OnTarbarButtonCreated )
//The actual callback
LRESULT CTaskBarTestAppDlg::OnTarbarButtonCreated(WPARAM wParam, LPARAM lParam)
{
//Custom code here once the taskbar is created
}
1) Application progress in the taskbar
To show progress in your application icon you need to use 2 simple API calls: ITaskbarList3::SetProgressState and ITaskbarList3::SetProgressValue.
Your taskbar icon can have one of the following states:
- No progress (default)
- Intermediate (green and cycles repeatedly along the length of the taskbar button)
- Paused (yellow progress bar)
- error (red progress bar)
- normal (green progress bar)
You can see this in action yourself when Windows explorer is copying a set of files and it encounters a locked file, the windows explorer icon will change to the error progress status which is red.
When you use SHFileOperation or the IFileOperation interface your taskbar icon will automatically update as well with progress.
To get your application icon to show progress for an indeterminate amount of time:
m_pTaskBarlist->SetProgressState(GetSafeHwnd(), TBPF_INDETERMINATE);
To set determinate progress you use one of TBPF_NORMAL, TBPF_ERROR, or TBPF_PAUSED. For example:
m_pTaskBarlist->SetProgressState(GetSafeHwnd(), TBPF_NORMAL);
m_pTaskBarlist->SetProgressValue(GetSafeHwnd(), 10, 100);
//...
m_pTaskBarlist->SetProgressValue(GetSafeHwnd(), 20, 100);
//...
m_pTaskBarlist->SetProgressValue(GetSafeHwnd(), 100, 100);
//...
m_pTaskBarlist->SetProgressState(GetSafeHwnd(), TBPF_NOPROGRESS);
The last parameter of SetProgressValue is the number of steps in your operation total, the second last parameter is the current number of steps already completed.
2) Overlay icons
Icon overlays on the actual taskbar icon can be accomplished by calling TaskbarList3::SetOverlayIcon.
The overlay icon should be a small icon, measuring 16x16 pixels at 96 dpi. In my experience though you can use any icon and Windows will scale it for you. Every time this method is called, the previous icons get removed.
m_pTaskBarlist->SetOverlayIcon(GetSafeHwnd(), hMyIcon, L"Descriptive string for accessibility");
3) Custom thumbnail preview groupings:
A single application which has a single process with tabs (Or an MDI application) can have multiple previews available to it.
Chrome 10 Beta does not take advantage of tab/thumbnail yet; however, IE9 does (as seen in my screenshot above in section #3).
Every time a tab is created you would call both RegisterTab and SetTabOrder like so:
HRESULT hr0 = m_pTaskBarlist->RegisterTab(hTab1, GetSafeHwnd());
m_pTaskBarlist->SetTabOrder(hTab1, NULL);
SetTabOrder can be used to specify the order of previews, passing in NULL appends the tab to the end of the list of previews.
You can remove a tab preview from your taskbar icon by calling UnregisterTab:
m_pTaskBarlist->UnregisterTab(hTab1);
But sometimes applications today span multiple processes. Both IE 9 and Chrome use one process per tab, and I believe that Firefox will eventually go this way too (They already do this for mobile phones).
The Windows 7 taskbar has this architecture covered (People bust Microsoft's ass a lot but in many cases they really deliver).
In this previous blog post, I talked about Sessions, Windows Stations, and Desktops. Well as of Windows 7 there is also something called Application IDs. Application IDs allows Windows to know what you view as an individual application. With multi process applications on the rise this becomes important. Application IDs can be associated with individual Windows. An application ID is a string of up to 128 characters.
The default application ID for a window is the same as the application ID for the process to which the Window belongs. Applications with the same application ID are grouped to the same taskbar icon.
You can set the application ID of a process using the Win32 API SetCurrentProcessExplicitAppUserModelID
You can set the application ID of a window using the Win32 API SHGetPropertyStoreForWindow and then calling functions on the return result which is of type IPropertyStore.
Application IDs are assigned dynamically so they can be changed at any time which means you could do some pretty interesting things.
4) Taskbar action buttons (Thumbnail toolbars):
Thumbnail toolbars allow you to add functionality and buttons available to the user without switching their current application. For example Windows Media Player adds previous, pause, and next button support. To do this you create an array of THUMBBUTTON structures.
When a thumbnail button is clicked you receive a WM_COMMAND message with the high word of the wParam set to THBN_CLICKED and the low word set the button ID.
Each button can have either an individual icon being used or a bitmap from the taskbar's image list which was set through ITaskbarList3::ThumbBarSetImageList.
THUMBBUTTON thbButtons[2];
//Initialize the first button
thbButtons[0].dwMask = THB_BITMAP | THB_TOOLTIP | THB_FLAGS;
thbButtons[0].iId = 0;
thbButtons[0].iBitmap = 0;
wcscpy(thbButtons[0].szTip, L"Button 1");
thbButtons[0].dwFlags = THBF_DISMISSONCLICK;
//Initialize the second button
dwMask = THB_BITMAP | THB_TOOLTIP;
thbButtons[1].dwMask = THB_BITMAP | THB_TOOLTIP;
thbButtons[1].iId = 1;
thbButtons[1].iBitmap = 1;
wcscpy(thbButtons[1].szTip, L"Button 2");
//Add the buttons to the thumbnail window
m_pTaskBarlist->ThumbBarAddButtons(hTab1, _countof(thbButtons), thbButtons);
Each tab thumbnail preview can have its own set of thumbnail buttons.
You may notice that the first button above has the THBF_DISMISSONCLICK flag but the second does not. The difference is that when the first button is clicked the thumbnail preview will be closed, whereas if the second button is clicked, the thumbnail preview remains open.
Other important flags are THBF_HIDDEN, THBF_ENABLED, and THBF_DISABLED.
After the buttons are created, they can be updated by using ITaskbarList3::ThumbBarUpdateButtons. You would want to update an existing button to for example disable it.
Each time a button is clicked the OnCommand virtual function of your dialog is specified:
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
So you simply need to override this function for the window that is associated with the thumbnail preview:
BOOL CTaskBarTestAppDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
UINT cmdID = LOWORD(wParam);
switch(cmdID)
{
case ID_BUTTON1:
MessageBox(_T("Button 1 was clicked"));
break;
case ID_BUTTON2:
MessageBox(_T("Button 2 was clicked"));
break;
default:
return CDialogEx::OnCommand(wParam, lParam);
}
}
5) Jump lists:
There is a great article here on Jump lists, but I will give a quick overview.
Each application is associated with a Jump List.
You can customize the tasks area which is a set of actions. You can also customize the destination area which is a list of Recent items or Frequent items.
The recent items is calculated for you automatically as long as your application is the default handler for the associated document type. If you want to add somethign to the list you can use the Win32 API SHAddToRecentDocs.
You can customize custom areas of the jump list, for example Chrome includes a "Most visited section" and a "Recently closed" section.
Custom destinations are controlled by: ICustomDestinationList.
A couple other things you can do:
You can customize your taskbar thumbnails by specifying a clipped rectangle of your window:
RECT r = {0,0,100,100};
m_pTaskBarlist->SetThumbnailClip(GetSafeHwnd(), &r);
You can set a tooltip for your thumbnail previews as follows:
m_pTaskBarlist->SetThumbnailTooltip(GetSafeHwnd(), L"Test1");
Or if you have multiple tab thumbnail previews:
m_pTaskBarlist->SetThumbnailTooltip(hTab1, L"Test1");
m_pTaskBarlist->SetThumbnailTooltip(hTab2, L"Test1");
What about managed code?
There are a couple of good resources for tying into the taskbar API from managed languages:
- The Windows API Code Pack for the Microsoft .NET Framework: Provides a library that can be used to access new features such as the Taskbar API in Windows 7.
- Windows 7 taskbar Interop Sample library: Supplies more features if not available above
Other reading:
- Introducing the Taskbar APIs (Nice introductory alternative tutorial covering some different things than I have above)
- ITaskbarList3 Interface (The gateway to most of the above features)
- ICustomDestinationList Interface (For Jump lists)
Windows Phone 7 development overview in 2 minutes
Last modified: Thursday, April 28, 2011
For fun I decided to look into Windows Phone 7 (WP7) Operating System (OS) development. Microsoft is definitely trying to reinvent its Mobile image with WP7 and they are spending over $400 million on marketing to do so. WP7 is a fresh platform for Microsoft and competes against iOS, Android, and Blackberry OS.
I currently own an Android HTC phone but I'm not so keen on developing for it since the primary development language is Java. Primarily I'm a Native C++ and .NET developer.
At first I didn't want to even look at WP7, but after spending a few hours reading about it I've changed my initial perception completely. I decided to write my equivalent to "Hello World" which is a Pi Memorize program that I made in MFC around 13 years ago. Pi Memorize is a small tool that helps you learn Pi to 10,000 digits.
WP7 is Microsoft's entirely new mobile OS and it is not compatible with the existing Windows Mobile which was based on Windows CE. WP7 is expected to be released in November of 2010 and unlike iOS and Blackberry OS, it is not a closed platform. Providers of the WP7 OS include HTC, Dell, Samsung, LG, and more. Apps made for Windows Mobile cannot be used directly on WP7.
WP7 development is based on Silverlight 3 (with some features from Silverlight 4), XNA Game Studio, and the .NET Compact Framework 4. I was a little disappointed to see that there is no native development with access to lower level things via writing a hypothetical native VC++ app. Windows Mobile had support for writing native apps with VC++ and also Windows Mobile had support for the .NET Compact Framework. Another missing feature that used to exist is multi-tasking, and finally cut, copy, and paste functionality.
Silverlight is the main way to make an app in WP7 and if you don't already know Silverlight is based on XAML and is similar but has a much nicer development stack (in my opinion) to Adobe's Flash. User interfaces in Silverlight are made in a declarative language called Extensible Application Markup Language (XAML). Silverlight is based on WPF and shares its XAML support.
XNA is familiar to game developers for Xbox and it is also based on the .NET Compact Framework.
To publish your application you need to buy a yearly renewable membership for $119 USD. The submission process works by submitting a .xap package which is just a renamed .zip with all of the application files. In order to successfully submit your app there is a known issue where you need to go to http://xbox.com/live and accept the agreement there first. Otherwise the "Submit a Windows Phone 7" button simply redirects you back to App Hub / create.msdn.com.
To get started in development you can download the WP7 development toolkit which includes an emulator, Visual Studio 2010 Express, XNA Game Studio, and the needed WP7 development tools. If you already have Visual Studio 2010 installed it will install the additional tools needed without installing Visual Studio 2010. From the Visual Studio New Project Window, you will notice you have additional tab pages for "XNA Game Studio 4.0 and "Silverlight for Windows Phone".
I developed only a small application, but from start to finish it only took me 5 hours, including downloading and installation, and I've never used Silverlight before; however, I have developed some apps with WPF.
Surprisingly the hardest part of the whole development was simply figuring out how to restrict a user to only be able to type numbers. To do this you can simply use a Textbox.InputScope element:
<TextBox Name="digitsText" TextWrapping="Wrap" Height="340" HorizontalAlignment="Left" Margin="-5,31,0,0" Text="" VerticalAlignment="Top" Width="460" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" DataContext="{Binding}" KeyDown="digitsKeyDown">
<TextBox.InputScope>
<InputScope>
<InputScopeName NameValue="TelephoneNumber"/>
</InputScope>
</TextBox.InputScope>
</TextBox>
This makes it so the textbox input consists of only the characters which are available to you when entering a phone number.
To restrict the keys in that input scope such as #, *, . and space I had to write some code behind via handling the KeyDown event:
private void digitsKeyDown(object sender, KeyEventArgs e)
{
bool isValid = e.Key >= Key.NumPad0
&& e.Key <= Key.NumPad9;
//Don't allow input if we have # or * or ...
e.Handled = !isValid;
//...
}
To embed the actual digits of Pi I simply added an embedded resource to the project called PiDigits.txt which contained Pi to 10,000 digits.
I loaded that resource at runtime with the following code into a string variable called correctPiDigits.
Assembly asm = this.GetType().Assembly;
Stream stream = asm.GetManifestResourceStream("PiMemorize.PiDigits.txt");
StreamReader reader = new StreamReader(stream);
correctPiDigits = reader.ReadToEnd();
//...
Here are some screenshots of the WP7 app that I made:
Tags: wp7 mobile c-sharp visual-studio windows
Add a new comment