⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 win32explrentry.c

📁 一个类似于写字板的程序
💻 C
📖 第 1 页 / 共 2 页
字号:
					BeginDrag(hWndListView, (NMLISTVIEW*)lParam);
					hSourceItem = lvItem;
				}

				break;
			}
		}
		break;

	case WM_MOUSEMOVE:
		// if dragging, move the image
		if (g_fDragging)
		{
			tvHit.pt.x = LOWORD(lParam);
			tvHit.pt.y = HIWORD(lParam);

			ImageList_DragEnter( hWnd, tvHit.pt.x , tvHit.pt.y); 

			// drag the item to the current mouse position
			ImageList_DragMove(tvHit.pt.x, tvHit.pt.y); 

			// if the cursor is on an item, hilite it as
			// the drop target

			if ((hTarget = TreeView_HitTest(hWndTreeView, &tvHit)) != NULL)
			{
				TreeView_Select(hWndTreeView, hTarget, TVGN_DROPHILITE);

				TreeView_GetItemRect(hWndTreeView, hTarget, &rect , FALSE);
				InvalidateRect(hWndTreeView, &rect, TRUE);

				if(tvHit.flags & TVHT_ONITEMRIGHT | TVHT_ONITEMBUTTON)
				{
					if(hTarget != hPrevItem)
					{
						TreeView_Expand(hWndTreeView, hTarget, TVE_TOGGLE);
						hPrevItem = hTarget;
					}
				}
			}
		}
		break;

	case WM_LBUTTONUP:
		// If dragging, stop it.
		if (g_fDragging)
		{
			// Process the item drop.
			tvHit.pt.x = LOWORD(lParam);
			tvHit.pt.y = HIWORD(lParam);
			if((hTargetItem = TreeView_HitTest(hWndTreeView, &tvHit)) != NULL)
				DropItem(hSourceItem, hTargetItem);
				
			// Inform the image list that dragging has stopped.
			ImageList_EndDrag();
			ImageList_DragLeave(hWnd);

			// Release the mouse.
			ReleaseCapture();

			// Show the cursor.
			ShowCursor(TRUE);

			// Reset the global Boolean flag to a nondragging state.
			g_fDragging = FALSE;

			GetClientRect(hWndTreeView, &rect);
			InvalidateRect(hWndTreeView, &rect, TRUE);
			
		}
		break;

	case WM_SIZE:
		MoveWindow (hSplitter, 0, TOOLBAR_HT, LOWORD (lParam), HIWORD (lParam) - 46, TRUE);
		MoveWindow (ghToolBar, 0, 0, LOWORD (lParam), TOOLBAR_HT, TRUE);
        MoveWindow (ghStatusBar, 0 , HIWORD (lParam) - STATUSBAR_HT , LOWORD (lParam) , HIWORD (lParam) - STATUSBAR_HT, TRUE);
		break;
    }

    return DefWindowProc (hWnd, uMsg, wParam, lParam);
}


static	void	CreateSplitter(HWND	hParent)		// Parent window handle
{
    // Create the splitter control

    hSplitter = CreateWindowEx (
                             	0,				// Extended window style
	                            WC_CCSPLITTER,			// Window class name
	                            NULL,				// Window name
	                            WS_CHILD|WS_VISIBLE,		// Window style
	                            0, 0, 0, 0,			// Position & size
	                            hParent,			// Parent window handle
	                            (HMENU)ID_SPLITTER,		// Application defined ID
	                            appInstance,			// Application instance
	                            0);				// Parameter

    if (hSplitter == NULL) 
	{
		MessageBox (0, "CreateWindowEx failed in CreateChildWindows", NULL, MB_ICONSTOP|MB_OK);
		exit (1);
    }

}

BOOL WINAPI CreateToolBar (HWND hOwnerWnd) 
{     
#define NUMBER_OF_TB_BUTTONS 6
#define NUMBER_OF_SEPARATORS 1
#define BUTTON_1   0
#define BUTTON_2   1
#define BUTTON_3   2
#define BUTTON_4   3
#define BUTTON_5   4
#define BUTTON_6   5
#define BUTTON_7   6


	// Initialize each of the buttons with the appropiate values     
	TBBUTTON tbButton[NUMBER_OF_TB_BUTTONS] = { 0 };      

	tbButton[BUTTON_1].iBitmap   = VIEW_LARGEICONS;     
	tbButton[BUTTON_1].idCommand = IDM_VIEW_LARGEICONS;     
	tbButton[BUTTON_1].fsState   = TBSTATE_ENABLED;     
	tbButton[BUTTON_1].fsStyle   = TBSTYLE_BUTTON;      
	
	tbButton[BUTTON_2].iBitmap   = VIEW_SMALLICONS;     
	tbButton[BUTTON_2].idCommand = IDM_VIEW_SMALLICONS;     
	tbButton[BUTTON_2].fsState   = TBSTATE_ENABLED;     
	tbButton[BUTTON_2].fsStyle   = TBSTYLE_BUTTON;      

	tbButton[BUTTON_3].iBitmap   = VIEW_LIST;     
	tbButton[BUTTON_3].idCommand = IDM_VIEW_LIST;     
	tbButton[BUTTON_3].fsState   = TBSTATE_ENABLED;     
	tbButton[BUTTON_3].fsStyle   = TBSTYLE_BUTTON;      

	tbButton[BUTTON_4].iBitmap   = VIEW_DETAILS;     
	tbButton[BUTTON_4].idCommand = IDM_VIEW_DETAIL;     
	tbButton[BUTTON_4].fsState   = TBSTATE_ENABLED;     
	tbButton[BUTTON_4].fsStyle   = TBSTYLE_BUTTON;      

	tbButton[BUTTON_5].fsStyle   = TBSTYLE_SEP;     
	
	tbButton[BUTTON_6].iBitmap   = STD_HELP;     
	tbButton[BUTTON_6].idCommand = IDM_HELP_ABOUT;     
	tbButton[BUTTON_6].fsState   = TBSTATE_ENABLED;     
	tbButton[BUTTON_6].fsStyle   = TBSTYLE_BUTTON;      

	// Create the toolbar with the most commonly used functions     

	ghToolBar = CreateToolbarEx (
		hOwnerWnd, 
		WS_CHILD | WS_BORDER | WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT , 
		IDB_TOOLBAR, 
		11, 
		(HINSTANCE)HINST_COMMCTRL, 
		IDB_VIEW_SMALL_COLOR, 
		(LPCTBBUTTON)&tbButton, 
		NUMBER_OF_TB_BUTTONS, 
		0, 0, 0, 0, 
		sizeof (TBBUTTON));

	if (NULL == ghToolBar)     
	{         
	    MessageBox (0, "failed to create ToolBar", NULL, MB_ICONSTOP|MB_OK);
		return FALSE;     
	}     

	return TRUE; 
}  

BOOL WINAPI CreateStatusBar (HWND hOwnerWnd) 
{     
	ghStatusBar = CreateStatusWindow (
		WS_BORDER | WS_CHILD | WS_VISIBLE,
		TEXT("Ready"),
		hOwnerWnd, 
		IDC_STATUSBAR);     

	if (ghStatusBar == NULL)     
	{         
		return FALSE;    
	}     
	
	return TRUE; 
}  

void    SetSplit(HWND hWnd)
{
RECT	rc;			// Window rectangle
CCSPLIT	spx;		// X-split data

    spx.cbSize = sizeof (spx);
    GetClientRect (hWnd, &rc);
    spx.flags  = CCSP_POS;
    spx.pos    = rc.right/3;
    CCsplitter_SetSplit (hSplitter, &spx, NULL);
}

void CreateImageLists()
{
SHFILEINFO  sfi;

	himlSmall = (HIMAGELIST)SHGetFileInfo( TEXT("C:\\"), 
                                       0,
                                       &sfi, 
                                       sizeof(SHFILEINFO), 
                                       SHGFI_SYSICONINDEX | SHGFI_SMALLICON);

	himlLarge = (HIMAGELIST)SHGetFileInfo( TEXT("C:\\"), 
                                       0,
                                       &sfi, 
                                       sizeof(SHFILEINFO), 
                                       SHGFI_SYSICONINDEX | SHGFI_LARGEICON);

	if (himlSmall && himlLarge)
   {
		SendMessage(hWndTreeView, TVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)himlSmall);
		SendMessage(hWndTreeView, TVM_SETIMAGELIST, (WPARAM)LVSIL_STATE, (LPARAM)himlSmall);

		SendMessage(hWndListView, LVM_SETIMAGELIST, (WPARAM)LVSIL_SMALL, (LPARAM)himlSmall);
		SendMessage(hWndListView, LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)himlLarge);
   }
}

void 	BeginDrag(HWND hwndLV, NMLISTVIEW *lvItem)
{
	POINT point;
	HIMAGELIST hIml;
	RECT rcl;
	point.x = point.y = 0;
	GetCursorPos(&point);
	hIml = ListView_CreateDragImage(hwndLV, lvItem->iItem, &point);
	ListView_GetItemRect(hwndLV, lvItem->iItem, &rcl, LVIR_SELECTBOUNDS);

	ImageList_BeginDrag(hIml, 0, 10, -35);
//	ImageList_BeginDrag(hIml, 0, point.x - rcl.left , point.y - rcl.top);

	ShowCursor(FALSE);
	// Capture the mouse.

	SetCapture(GetParent(hwndLV));

	// Set a global flag that tells whether dragging is occurring.
	g_fDragging = TRUE;

}

void 	DropItem(LVITEM hSourceItem, HTREEITEM hTargetItem)
{

}

BOOL MoveImage(POINT point)
{
    return ImageList_DragMove(point.x,  point.y);
}


/********************************************************************************/
/* End of file									*/
/********************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -