有请专家:如何编程实现桌面动画?(200分)

  • 主题发起人 IoveDelphi
  • 开始时间
I

IoveDelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
右键桌面-属性-web-选中〔按web方式....〕-新建-.....选一个gif动画,就可以在桌面上播放动画了,这个如何编程实现?要用delphi
 
就是那个桌面项
我不懂vc,好像下面的翻译成delphi差不多........
网址是:http://www.funducode.com/weeklyupdate/Aug_25_01/Aug_25.htm
=================
Continued from last week?/font>
Last week we had added the OnActive( ) handler for the check box. In this function, by calling UpdateData ( FALSE ) we have obtained the state of the check box. If the user has checked the check box we have stored TRUE in the fActiveDesktop and fEnableComponents elements of the COMPONENTSOPT structure to enable the Active Desktop. Otherwise we have initialized these elements with FALSE to disable the Active Desktop. To notify the new desktop items option we have called a function IActiveDesktop::SetDesktopItemOptions( ). The new settings would not be effective unless we call IActiveDesktop::ApplyChanges( ) function. We have called the ApplyChanges( ) function with a flag AD_APPLY_REFRESH which specifies to refresh the desktop items.
Add handler for 'Add' button and add the code in it as given below:
void CActivedeskDlg::OnAdd( )
{
CFileDialog fd ( TRUE, NULL, NULL, NULL, "ActiveDesktop Files(*.htm,*.jpg,*.gif,*.bmp)|*.htm;*.jpg;*.gif;*.bmp||" )
if ( fd.DoModal( ) == IDCANCEL )
return
CString fname = fd.GetPathName( )
COMPONENT comp = { 0 }
comp.dwSize = sizeof ( comp )
comp.fChecked = 1
comp.fNoScroll = 0
comp.fDirty = 0
COMPPOS pos = { 0 }
pos.dwSize = sizeof ( pos )
pos.dwHeight = 250
pos.dwWidth = 250
pos.fCanResize = 1
pos.fCanResizeX = 1
pos.fCanResizeY = 1
pos.iLeft = 200
pos.iPreferredLeftPercent = 60
pos.iPreferredTopPercent = 30
pos.iTop = 50
pos.izIndex = 0
comp.cpPos = pos
if ( fd.GetFileExt( ) == "htm" )
comp.iComponentType = COMP_TYPE_WEBSITE
else

comp.iComponentType = COMP_TYPE_PICTURE

USES_CONVERSION
wcscpy ( comp.wszSource, T2OLE ( ( LPCTSTR ) fname ) )
wcscpy ( comp.wszSubscribedURL, T2OLE ( ( LPCTSTR ) fname ) )
wcscpy ( comp.wszFriendlyName, T2OLE ( ( LPCTSTR ) fd.GetFileName( ) ) )
HRESULT hr = pad -> AddDesktopItem ( &comp, 0 )
if ( FAILED ( hr ) )
MessageBox ( "Cannot add item" )
else

{
pad -> ApplyChanges ( AD_APPLY_SAVE | AD_APPLY_REFRESH | AD_APPLY_FORCE )
m_list.AddString ( fname )
}
}
Here, we have displayed standard 'Open' dialog box from which user can select the file to be shown on the desktop. Next, we have initialized various elements of the COMPONENT structure. The meaning of these elements is shown below:
dwSize : Size of the structure.
dwID : Reserved. Must be set to zero.
iComponentType : Item type. Specifies whether the item is HTMLdo
cument, website or picture.
fChecked : Specifies whether the component is enabled.
fDirty : Specifies whether the component has been modified, but has not been saved.
fNoScroll : Indicates whether the component is scrollable.
cpPos : Object of the COMPPOS structure. We have specified the size, position of the item on the desktop and also whether the item should be resizable or not.
wszFriendlyName : Contains the friendly name of the item.
wszSource : Contains the URL of the item.
wszSubscribedURL : Contains subscribed URL of the item.
We have used the ATL conversion macro T2OLE to convert the CString object 'fname' in wide character strings. To use this macro we have written the statements USES_CONVERSION. To add the item to the Active Desktop we have used IActiveDesktop::AddDesktopItem( ) function. We have passed the pointer to the object of COMPONENT structure to the AddDesktopItem( ) function. We have then
called the ApplyChanges( ) function to save and refresh the desktop items and force to reflect the desktop changes. The file name is then
listed in the list box.
Add a handler for the 'Remove' button and add code in it as shown below:
void CActivedeskDlg::OnRemove( )
{
CString fname
int index = m_list.GetCurSel( )
if ( index == -1 )
return
m_list.GetText ( index, fname )
COMPONENT comp = { 0 }
comp.dwSize = sizeof ( comp )
USES_CONVERSION
pad -> GetDesktopItemBySource ( T2OLE ( ( LPCTSTR ) fname ), &comp, 0 )
HRESULT hr = pad -> RemoveDesktopItem ( &comp, 0 )
if ( FAILED ( hr ) )
MessageBox ( "Cannot delete item" )
else

{
pad -> ApplyChanges ( AD_APPLY_SAVE | AD_APPLY_REFRESH | AD_APPLY_FORCE )
m_list.DeleteString ( index )
}
}
In this function, firstly, we have obtained the selected item to be removed from the desktop. Next, we have retrieved the information of the item by calling the IActiveDesktop::GetDesktopItemBySource( ) function. The GetDesktopItemBySource( ) function fills the elements of the COMPONENT structure with the information of the specified item. We have removed the desktop item by calling the IActiveDesktop::RemoveDesktopItem( ) function. We have again called ApplyChanges( ) function and deleted the string from the list box by calling the CListBox::DeleteString( ) function. Run the program. Enable the Active Desktop and add few items
 
关注。。
 

Similar threads

回复
0
查看
827
不得闲
X
回复
0
查看
575
xalion
X
D
回复
0
查看
755
DelphiTeacher的专栏
D
D
回复
0
查看
750
DelphiTeacher的专栏
D
顶部