First of all, I would like to thank the original author of the post. From http://www.ustcers.com/blogs/devzhao/pages/13027.aspx
Windows CE desktop UI Modification
The desktop UI mainly involves the cshorttopview class. The cshorttopview class inherits from the CDefShellView class. To change the UI representation of the desktop, you only need to start with this class. The cshorttopview class is located in
$ (_ WINCEROOT) \ PUBLIC \ SHELL \ OAK \ HPC \ CESHELL folder.
1. Change the right-click menu option
There are two types of pop-up menus on the desktop: FOLDER_VIEW_MENU_OFFSET popped up by right-clicking the desktop; ITEM_MENU_OFFSET popped up by right-clicking the icon:
/*************************************** ***************
// FOLDER_VIEW_MENU_OFFSET menu
View (pos: FOLDER_VIEW_MENU_OFFSET)
--------------
Icon Arrangement
Refresh
--------------
Paste
Paste shortcuts
--------------
Create folder
--------------
Attribute
**************************************** ***************/
/*************************************** ***************
// ITEM_MENU_OFFSET menu
Open (pos: ITEM_MENU_OFFSET)
----------
Cut
Copy
----------
Delete
Rename
----------
Attribute
**************************************** ***************/
Before the menu is displayed, you must call the csf-topview: handleinitmenupopup () function to build the menu. Therefore, you must change the menu options in this function.
You can use the: removemenu () function to delete the sub-item in the delete menu. The sub-item can be deleted by position (mf_byposition) or command (mf_bycommand ).
For example:
1. Delete the "copy" sub menu:
: Removemenu (hmenu, idc_edit_copy, mf_bycommand );
2. Delete the second sub-menu of the item_menu_offset menu:
: Removemenu (hmenu, item_menu_offset + 1, mf_byposition); // The Position of the subsequent menu item is moved.
The following code folder_view_menu_offset only retains "refresh" and "attribute"; item_menu_offset only retains "open" and "attribute" (included in the Code added by the author between begin and end)
LRESULT csf-topview: HandleInitMenuPopup (HMENU hmenu, PopupMenuInfo * pPopupMenuInfo)
{
LRESULT result = CDefShellView: HandleInitMenuPopup (hmenu, pPopupMenuInfo );
If (0 = result) & (FWF_DESKTOP & m_fFlags ))
{
If (pPopupMenuInfo & (FOLDER_MENU_OFFSET = pPopupMenuInfo-> offset ))
{
: RemoveMenu (hmenu, FOLDER_VIEW_MENU_OFFSET, MF_BYPOSITION); // "View" sub-menu
: RemoveMenu (hmenu, FOLDER_VIEW_MENU_OFFSET, MF_BYPOSITION); // "View" separator
: RemoveMenu (hmenu, FOLDER_VIEW_MENU_OFFSET, MF_BYPOSITION); // "icon Arrangement"
: RemoveMenu (hmenu, FOLDER_VIEW_MENU_OFFSET + 1, MF_BYPOSITION); // separator
: RemoveMenu (hmenu, FOLDER_VIEW_MENU_OFFSET + 1, MF_BYPOSITION); // "Paste"
: RemoveMenu (hmenu, FOLDER_VIEW_MENU_OFFSET + 1, MF_BYPOSITION); // "paste shortcuts"
: RemoveMenu (hmenu, FOLDER_VIEW_MENU_OFFSET + 1, MF_BYPOSITION); // separator
: RemoveMenu (hmenu, FOLDER_VIEW_MENU_OFFSET + 1, MF_BYPOSITION); // "Create a folder"
}
Else if (pPopupMenuInfo & (ITEM_MENU_OFFSET = pPopupMenuInfo-> offset ))
{
: RemoveMenu (hmenu, IDC_EDIT_CUT, MF_BYCOMMAND );
: RemoveMenu (hmenu, IDC_EDIT_COPY, MF_BYCOMMAND );
: RemoveMenu (hmenu, IDC_FILE_DELETE, MF_BYCOMMAND );
: RemoveMenu (hmenu, IDC_FILE_RENAME, MF_BYCOMMAND );
: RemoveMenu (hmenu, ITEM_MENU_OFFSET + 1, MF_BYPOSITION); // separator
: RemoveMenu (hmenu, ITEM_MENU_OFFSET + 1, MF_BYPOSITION); // separator
}
}
- Return result;
}
How to add menu items... Pai_^
2. Do not drag the desktop icon
The drag-and-drop function of cshorttopview directly uses the DoDragDrop () function of the base class CDefShellView. To disable drag-and-drop of desktop icons, you only need to overload the DoDragDrop () function to be empty.
In the override topview. h overload, the Code is as follows:
Protect:
Virtual void DoDragDrop (NMLISTVIEW * pnmListView ){};
3. desktop icon arrangement order
The desktop icons are arranged by name, type, date, size, and automatically. By default, they are arranged by name.
The HandleCommand () function is used to process commands in cshorttopview. It actually calls the HandleCommand () function of CDefShellView. for ease of use, we can call: CDefShellView: HandleCommand (dwCmd );
DwCmd is a command type and has the following macro-defined commands:
IDC_EDIT_COPY: Copy
IDC_EDIT_CUT: Cut
IDC_EDIT_PASTE: Paste
IDC_EDIT_PASTESHORTCUT: paste shortcuts
IDC_EDIT_SELECTALL: select all
IDC_EDIT_UNDO: undo
IDC_FILE_DELETE: Delete
IDC_FILE_NEWFOLDER: Create a folder
IDC_FILE_OPEN: Open
IDC_FILE_PROPERTIES: Properties
IDC_FILE_RENAME: Rename
IDC_FILE_SENDTO_DESKTOP: Send to desktop
IDC_FILE_SENDTO_MYDOCUMENTS: The document sent to me
IDC_HELP_TOPICS: (useless)
IDC_REFRESH: refresh
IDC_ARRANGE_AUTO: Automatic Sorting
IDC_ARRANGE_BYDATE: sort by date
IDC_ARRANGE_BYNAME: sort by name
IDC_ARRANGE_BYSIZE: sort by size
IDC_ARRANGE_BYTYPE: sort by type
IDC_VIEW_DETAILS: View Details
IDC_VIEW_LIST: List View
IDC_VIEW_ICONS: icon view
IDC_VIEW_OPTIONS: view options (?)
IDC_VIEW_TYPE: view type (?)
IDC_GO_MYDOCUMENTS: Go to my documents
IDC_GO_FOLDERUP: Go to the parent folder
ID_ESCAPE: ESC
ID_CONTEXTMENU: Content menu (?)
If you need to initialize the icons by date, you only need to add this statement at the end of the csf-topview: CreateViewWindow () function:
CDefShellView: HandleCommand (IDC_ARRANGE_BYDATE );
4. Change the desktop background
Modify it in csf-topview: PaintBackground.
Modify the background color:
// --- Original code commented out --- //: FillRect (hdc, & rc,: GetSysColorBrush (COLOR_BACKGROUND); // Explicitly set the background color.: FillRect (hdc, & rc,: GetSysColorBrush (RGB (230,150,230 )));Modify the displayed OS version information (similar to "windows ce.net 4.2 ")
/* -- Original code commented out --: wsprintf (wszVersion, L "Microsoft Windows \ CE v % d. % 02d (Build % d on % s) ", VerInfo. dwMajorVersion, VerInfo. dwMinorVersion, VerInfo. dwBuildNumber, TEXT (_ DATE _); * // Display shell name along with Windows CE version information.: wsprintf (wszVersion, L "<
Shell Name> For Microsoft Windows \ CE v % d. % 02d (Build % d on % s) ", VerInfo. dwMajorVersion, VerInfo. dwMinorVersion, VerInfo. dwBuildNumber, TEXT (_ DATE __));
5 ..... To be continued