现在 咱也用上Vista 了嘿嘿
Vista 给我感觉真不错 效果挺酷的
特别是侧边栏
但是功能太少了
去网上找了下发现东西挺多得但是没有自己需要的.
怎么办. 又要自己动手了.
首先上MSDN找找资料.
嘿 还真找到了. 开始
先建立配置文件
gadget.xml
- <?xml version="1.0" encoding="utf-8" ?>
- <gadget>
- <name>FxOS</name>
- <namespace>www.0dsoft.com</namespace>
- <version>1.0.0.0</version>
- <author name="FanFan">
- <info url="http://www.0dsoft.com" />
- </author>
- <copyright>©Something 2008/6</copyright>
- <description>FxOS</description>
- <icons>
- <icon height="48" width="48" src="fx.ico" />
- </icons>
- <hosts>
- <host name="sidebar">
- <base type="HTML" apiVersion="1.0.0" src="gadget.html" />
- <permissions>full</permissions>
- <platform minPlatformVersion="1.0" />
- <defaultImage src="images/Background.png" />
- </host>
- </hosts>
- </gadget>
开始写程序吧
创建显示
gadget.html
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>FxOS</title>
- <link href="css/gadget.css" type="text/css" rel="Stylesheet" />
- <script src="scripts/gadget.js" type="text/javascript"></script>
- </head>
- <body onLoad="onloadMain()" style=" background-color:Black">
- <table cellpadding="0" cellspacing="0" border="0">
- <tr>
- <td>
- <object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="player" height="97">
- <param name="URL" value />
- <param name="rate" value="1" />
- <param name="balance" value="0">
- <param name="currentPosition" value="0" />
- <param name="defaultFrame" value />
- <param name="playCount" value="-1" />
- <param name="autoStart" value="0">
- <param name="currentMarker" value="0" />
- <param name="invokeURLs" value="0" />
- <param name="baseURL" valu />
- <param name="volume" value="100" />
- <param name="mute" value="-1">
- <param name="uiMode" value="none" />
- <param name="stretchToFit" value="0" />
- <param name="windowlessVideo" value="0" />
- <param name="enabled" value="-1" />
- <param name="enableContextMenu" value="0" />
- <param name="fullScreen" value="0" />
- <param name="SAMIStyle" value />
- <param name="SAMILang" value />
- <param name="SAMIFilename" value />
- <param name="captioningID" value />
- <param name="enableErrorDialogs" value="0" />
- </object>
- </td>
- </tr>
- <tr>
- <td>
- <img src="images/Background.png" />
- <g:background src="images/Background.png" height="31" border="0"></g:background>
- <img id="prvBtn" onclick="prv()" src="images/prv.png"onmouseover="thisthis.src='images/prv_select.png'" οnmοuseοut="this.src='images/prv.png'"></img>
- <img id="playBtn" src="images/play.png"></img>
- <img id="stopBtn" onclick="player.controls.stop()" src="images/s.png" onmouseover="this.src='images/s_select.png'" onmouseout="this.src='images/s.png'"></img>
- <img id="nextBtn" onclick="next()" src="images/next.png" onmouseover="this.src='images/next_select.png'" onmouseout="this.src='images/next.png'"></img>
- <img src="images/open.png"
- style="top: 107px; left: 104px; position: absolute; height: 9px; width: 9px" onclick="openFileDialog()" />
- </td>
- </tr>
- </table>
- <map name="Map">
- </body>
- </html>
最后是脚本
- var count;
- var musicPathArray;
- var path = "musicPath";
- var index = -1;
- function LoadMusic(){
- var p = System.Gadget.Settings.readString(path);
- if(p){
- var temp = System.Shell.itemFromPath(p);
- musicPathArray = temp.SHFolder.Items;
- if(musicPathArray.count>0){
- player.url = musicPathArray.item(0).path;
- index = 0;
- }
- play();
- player.controls.stop();
- }
- }
- function onloadMain(){
- var defaultFilePath = System.Environment.getEnvironmentVariable("Public//music//Sample Music");
- LoadMusic();
- }
- function openFileDialog(){
- var music = System.Shell.chooseFolder("歌曲目录选择",512);
- if(music){
- System.Gadget.Settings.writeString(path,music.path);
- LoadMusic()
- }
- }
- function next(){
- if(index<musicPathArray.count){
- player.url = musicPathArray.item(index++).path;
- player.controls.play();
- }
- }
- function prv(){
- if(index>0){
- player.url = musicPathArray.item(index--).path;
- player.controls.play();
- }
- }
- function play(){
- if(player.playState==3){
- setPlayBtn("images/stop_select.png","images/stop.png");
- playBtn.onclick = function(){player.controls.pause();play();};
- }else{
- setPlayBtn("images/play_select.png","images/play.png");
- playBtn.onclick = function(){
- if(index>-1){
- player.controls.play();
- play();
- }
- };
- }
- }
- function setPlayBtn(over,out){
- playBtn.οnmοuseοver=function(){
- playBtn.src = over;
- }
- playBtn.onmouseout = function(){
- playBtn.src = out;
- }
- }
好了搞定
看看效果