I. Dans la liste suivante, quelle technologie d'interface utilisateur a été ajoutée à Windows 7 ?▲
La plateforme de rubans de Windows est un système de présentation de commande riche qui fournit une alternative moderne aux menus et aux barres d'outils traditionnelles de Windows. Similaire aux fonctionnalités et à l'apparence de l'interface utilisateur de Microsoft Office 2007, la plateforme de rubans Windows est composée d'une barre de commandes de rubans qui expose les principales caractéristiques d'une application à travers une série d'onglets en haut de la fenêtre de l'application et un système de menu contextuel.
L'utilisation des rubans, tire profit du modèle MVC (Model View Controler).
En effet, pour profiter des rubans de Windows, il suffit :
- De partir d'un fichier au format XML, décrivant l'interface et les commandes ;
- De le compiler à l'aide d'un outil spécifique, UICC.exe afin de construire un fichier de ressources qui sera à incorporer dans l'application ;
- De construire une classe qui permettra de l'initialiser et de réagir aux évènements.

<Application xmlns='http://schemas.microsoft.com/windows/2009/Ribbon'>
<Application.Commands>
<Command Name="TabAccueil" Symbol="cmdTabAccueil" Id="30000">
<Command.LabelTitle>
<String Id ="200">Accueil</String>
</Command.LabelTitle>
</Command >
<Command Name="GroupPrincipal" Symbol="cmdGroupPrincipal" Id="30001" LabelTitle="Principal"/>
<Command Name="MonBouton" Symbol="cmdMonBouton" Id="30002" LabelTitle="Mon Bouton">
<Command.TooltipTitle>Mon Bouton</Command.TooltipTitle>
<Command.TooltipDescription>Cliquez sur mon Bouton</Command.TooltipDescription>
<Command.LargeImages>
<Image Source="Button_Image.bmp"/>
</Command.LargeImages>
</Command>
</Application.Commands>
<Application.Views>
<Ribbon>
<Ribbon.Tabs>
<Tab CommandName="TabAccueil">
<Group CommandName="GroupPrincipal" SizeDefinition="TwoButtons">
<Button CommandName="MonBouton"/>
<ToggleButton CommandName="MonChoix"/>
</Group>
</Tab>
</Ribbon.Tabs>
</Ribbon>
</Application.Views>
</Application>UICC.exe BalisesRuban.xml BaliseRuban.bml /res:Rubanres.rcclass CApplication
: public CComObjectRootEx<CComMultiThreadModel>
, public IUIApplication
, public IUICommandHandler
{
private:
BOOL _fEnabled;
public:
BEGIN_COM_MAP(CApplication)
COM_INTERFACE_ENTRY(IUIApplication)
COM_INTERFACE_ENTRY(IUICommandHandler)
END_COM_MAP()
STDMETHOD(OnViewChanged)(UINT32 nViewID, __in UI_VIEWTYPE typeID, __in IUnknown* pView, UI_VIEWVERB verb, INT32 uReasonCode)
{
return E_NOTIMPL;
}
STDMETHOD(OnCreateUICommand)(UINT32 nCmdID, __in UI_COMMANDTYPE typeID, __deref_out IUICommandHandler** ppCommandHandler)
{
if (nCmdID == cmdMonBouton || nCmdID == cmdMonChoix )
{
return QueryInterface(IID_PPV_ARGS(ppCommandHandler));
}
return E_NOTIMPL;
}
STDMETHOD(OnDestroyUICommand)(UINT32 commandId, __in UI_COMMANDTYPE typeID, __in_opt IUICommandHandler* pCommandHandler)
{
return E_NOTIMPL;
}
STDMETHODIMP Execute(UINT nCmdID,
UI_EXECUTIONVERB verb,
__in_opt const PROPERTYKEY* key,
__in_opt const PROPVARIANT* ppropvarValue,
__in_opt IUISimplePropertySet* pCommandExecutionProperties)
{
HRESULT hr = S_OK;
switch (verb)
{
case UI_EXECUTIONVERB_EXECUTE:
if (nCmdID == cmdMonBouton)
{
MessageBox(NULL, L"Vous avez cliqué sur mon bouton !",L"La méthode Execute ", MB_OK);
}
break;
}
return hr;
}
HRESULT InitialisationRuban(HWND hWindowFrame)
{
HRESULT hr = CoCreateInstance(CLSID_UIRibbonFramework,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&g_pFramework));
CComObject<CApplication> *pApplication = NULL;
CComObject<CApplication>::CreateInstance(&pApplication);
g_pFramework->Initialize(hWindowFrame, pApplication);
g_pFramework->LoadUI(GetModuleHandle(NULL), L"APPLICATION_RIBBON");
return 0;
}Il est bien évidemment possible de mapper les commandes de rubans, sur les commandes des anciens menus afin d'éviter de tout recoder.
Pour plus d'infos
- Pour découvrir la manière d'ajouter des rubans à son application, n'hésitez pas à suivre le coach Windows 7 http://msdn.microsoft.com/fr-fr/windows/coach-windows-7-differencie-atelier-3
- MSDN : http://msdn.microsoft.com/fr-fr/windows/default.aspx
- Le coach Windows 7 : http://msdn.microsoft.com/fr-fr/windows/msdn.coach.windows7
- Kit de développement pour Windows 7 : http://msdn.microsoft.com/fr-fr/windows/gg398052.aspx





