📄 dlg_newshell_tabs.c
字号:
/* * mShell * Copyright 2006, Julien Lecomte * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the * use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in a * product, an acknowledgment in the product documentation would be appreciated * but is not required. * 2. Altered source versions must be plainly marked as such, and must not * be misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * * $Id: dlg_newshell_tabs.c,v 1.1 2006/04/05 11:25:23 julienlecomte Exp $ */#include "mshell_preconfig.h"#define WIN32_LEAN_AND_MEAN#include <windows.h>#include <commctrl.h>#include "mshell_resource.h"#include "mshell.h"#include "dlg_newshell_tabs.h"static HWND tabhwnds[HWND_TAB_TOTAL];static HIMAGELIST hTabImgList;INT_PTR CALLBACK NewShellTabProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){ switch (msg) { case WM_INITDIALOG: { RECT rectTab; InitDlgFont (hWnd); GetClientRect (GetParent(hWnd), &rectTab); TabCtrl_AdjustRect (GetParent(hWnd), FALSE, &rectTab); MoveWindow (hWnd, rectTab.left, rectTab.top, rectTab.right - rectTab.left, rectTab.bottom - rectTab.top, FALSE); return TRUE; } default: return FALSE; }}static HWND AddTab (HWND hTabCtrl, HWND hTabChild, int iRes, LPTSTR pszText, WORD wBitmap){ HINSTANCE hInst = (HINSTANCE) GetModuleHandle (NULL); unsigned int iIndex = TabCtrl_GetItemCount(hTabCtrl); iIndex += 1; TCITEM titem; titem.mask = TCIF_TEXT; titem.pszText = pszText; titem.cchTextMax = strlen (pszText); /* Do we have an bitmap icon ? */ if (wBitmap) { /* Do we have an image list */ HIMAGELIST hImgLst = TabCtrl_GetImageList(hTabCtrl); if (hImgLst) { /* Load bitmap */ HBITMAP hBmpIcon = (HBITMAP) LoadImage (hInst, MAKEINTRESOURCE(wBitmap), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE); if (hBmpIcon) { /* Add icon */ titem.iImage = ImageList_AddMasked (hImgLst, hBmpIcon, CLR_TRANSPARENT); if (titem.iImage != -1) titem.mask |= TCIF_IMAGE; DeleteObject (hBmpIcon); } } } if (TabCtrl_InsertItem (hTabCtrl, iIndex, &titem) == -1) return NULL; hTabChild = CreateDialog (hInst, MAKEINTRESOURCE(iRes), hTabCtrl, NewShellTabProc); return hTabChild;}void CreateNewShellTabbar (HWND hTabCtrl){ /* Create an imagelist for the tab control */ hTabImgList = ImageList_Create (CX_ICON, CY_ICON, ILC_COLOR24 | ILC_MASK, 3, 0); if (hTabImgList) { ImageList_SetBkColor (hTabImgList, CLR_NONE); TabCtrl_SetImageList (hTabCtrl, hTabImgList); } /* Add the tabs */ tabhwnds[HWND_TAB_ENVIRON] = AddTab (hTabCtrl, tabhwnds[HWND_TAB_ENVIRON], TAB_ENVIRON, STR_ENVIRON, BMP_SETTINGS);}void DeleteNewShellTabbar (void){ unsigned int i; for (i = 0; i < HWND_TAB_TOTAL; i++) DestroyWindow (tabhwnds[i]); if (hTabImgList) ImageList_Destroy (hTabImgList);}#if 0void HideTab (HWND hTabCtrl){ int iIndex = TabCtrl_GetCurSel (hTabCtrl); if (iIndex != -1) ShowWindow (tabhwnds[iIndex], SW_SHOW);}void ShowTab (HWND hTabCtrl){ int iIndex = TabCtrl_GetCurSel (hTabCtrl); if (iIndex != -1) ShowWindow (tabhwnds[iIndex], SW_HIDE);}#endifHWND GetNewShellTabDlgItem (int nIDDlgItem){ return (GetDlgItem (tabhwnds[HWND_TAB_ENVIRON], nIDDlgItem));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -