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

📄 win_mdimain.c

📁 very famous terminal, i use it test cli in vxworks many times, very useful
💻 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: win_mdimain.c,v 1.4 2006/04/06 14:45:12 julienlecomte Exp $ */#include "mshell_preconfig.h"#define WIN32_LEAN_AND_MEAN#include <windows.h>#include <commctrl.h>#include "mshell_resource.h"#include "mshell.h"HWND hMDIWindow  = NULL;HWND hMDIClient  = NULL;LRESULT CALLBACK MDIWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){  switch (msg)  {    case WM_COMMAND:      switch (LOWORD (wParam))      {        case MENU_FILE_NEW_WND:          DialogBox (GetModuleHandle (NULL), MAKEINTRESOURCE(DLG_NEWSHELL), hMDIWindow, NewShellDlgProc);          return 0;        case MENU_FILE_PREV_WND:        case MENU_FILE_NEXT_WND:        {          HWND hChild = (HWND) SendMessage (hMDIClient, WM_MDIGETACTIVE, 0, 0);          if (IsWindow (hChild))            SendMessage (hMDIClient, WM_MDINEXT, (WPARAM) hChild, MENU_FILE_NEXT_WND - LOWORD (wParam));          return 0;        }        case MENU_FILE_CLOSE_WND:        {          HWND hChild = (HWND) SendMessage (hMDIClient, WM_MDIGETACTIVE, 0, 0);          if (IsWindow (hChild))            SendMessage (hChild, WM_CLOSE, 0, 0);          return 0;        }        case MENU_FILE_EXIT:          DestroyWindow (hMDIWindow);          return 0;        case MENU_WND_TILEH:          SendMessage (hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0);          return 0;        case MENU_WND_TILEV:          SendMessage (hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0);          return 0;        case MENU_WND_CASCADE:          SendMessage (hMDIClient, WM_MDICASCADE, 0, 0);          return 0;        case MENU_HELP_ABOUT:          DialogBox (GetModuleHandle (NULL), MAKEINTRESOURCE(DLG_ABOUT), hMDIWindow, AboutDlgProc);          return 0;        /* Send these to the child */        case MENU_EDIT_CUT:        case MENU_EDIT_COPY:        case MENU_EDIT_PASTE:        {          HWND hChild = (HWND) SendMessage (hMDIClient, WM_MDIGETACTIVE, 0, 0);          if (IsWindow (hChild))            SendMessage (hChild, WM_COMMAND, wParam, lParam);          return 0;        }      }      return DefFrameProc (hWnd, hMDIClient, msg, wParam, lParam);    case WM_CREATE:    {      CLIENTCREATESTRUCT cs;      cs.hWindowMenu  = GetSubMenu (GetMenu (hWnd), 2);      cs.idFirstChild = ID_MDI_CHILD_0;      hMDIClient = CreateWindowEx (WS_EX_CLIENTEDGE, "MDICLIENT", "",        WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL,        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,        hWnd, (HMENU) MENU_MAIN, GetModuleHandle (NULL), &cs);      if (!hMDIClient)        return -1;      return 0;    }    case WM_DESTROY:      PostQuitMessage (0);      return 0;    default:      return DefFrameProc (hWnd, hMDIClient, msg, wParam, lParam);  }}void LoadMDIWindow (void){  INITCOMMONCONTROLSEX iccs;  WNDCLASSEX wincl;  MSG msg;  BOOL bRet;  /* Initialize common controls (*maybe* required) */  iccs.dwSize = sizeof (INITCOMMONCONTROLSEX);  iccs.dwICC  = ICC_TAB_CLASSES;  if (!InitCommonControlsEx (&iccs))  {    MessageBox (NULL, TEXT("Could not initialize common controls."), TEXT(PACKAGE_NAME), MB_OK | MB_ICONERROR | MB_SETFOREGROUND);    return;  }  /* Prepare the main window class */  wincl.cbSize        = sizeof (WNDCLASSEX);  wincl.hInstance     = GetModuleHandle (NULL);  wincl.lpszClassName = WNDCLASS_MDIPARENT;  wincl.lpfnWndProc   = MDIWndProc;  wincl.style         = CS_HREDRAW | CS_VREDRAW;  wincl.hIcon         = (HICON) LoadImage (wincl.hInstance, MAKEINTRESOURCE(ICO_MSHELL),    IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);  wincl.hIconSm       = (HICON) NULL; /* loads thee above */  wincl.hCursor       = LoadCursor (NULL, IDC_ARROW);  wincl.lpszMenuName  = (LPCTSTR) MENU_MAIN;  wincl.cbClsExtra    = 0;  wincl.cbWndExtra    = 0;  wincl.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);  if (!RegisterClassEx (&wincl))  {    MessageBox (NULL, TEXT("Could not register mdi parent window class."), TEXT(PACKAGE_NAME), MB_OK | MB_ICONERROR | MB_SETFOREGROUND);    return;  }  /* Prepare the mdi child class */  wincl.cbSize        = sizeof (WNDCLASSEX);  wincl.hInstance     = GetModuleHandle (NULL);  wincl.lpszClassName = WNDCLASS_TERMINAL;  wincl.lpfnWndProc   = TerminalWndProc;  wincl.hIcon         = (HICON) NULL;  wincl.hIconSm       = (HICON) NULL;  wincl.hCursor       = LoadCursor (NULL, IDC_ARROW);  wincl.lpszMenuName  = (LPCTSTR) MENU_MAIN;  wincl.style         = CS_HREDRAW | CS_VREDRAW;  wincl.cbClsExtra    = 0;  wincl.cbWndExtra    = 0;  wincl.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);  if (!RegisterClassEx (&wincl))  {    MessageBox (NULL, TEXT("Could not register mdi child window class."), TEXT(PACKAGE_NAME), MB_OK | MB_ICONERROR | MB_SETFOREGROUND);    return;  }  /* Load MDI window */  hMDIWindow = CreateWindowEx (WS_EX_RIGHTSCROLLBAR,    WNDCLASS_MDIPARENT, STR_MSHELL,    WS_TILEDWINDOW | WS_CLIPCHILDREN ,    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,    HWND_DESKTOP, NULL, GetModuleHandle (NULL), NULL);  if (!hMDIWindow)  {    MessageBox (NULL, TEXT("Could not create main window."), TEXT(PACKAGE_NAME), MB_OK | MB_ICONERROR | MB_SETFOREGROUND);    return;  }  ShowWindow (hMDIWindow, SW_SHOW);  while ((bRet = GetMessage (&msg, NULL, 0, 0)) != 0)  {    if (bRet != TRUE)    {      /* handle the error and possibly exit */    }    else if (!TranslateMDISysAccel (hMDIClient, &msg))    {      TranslateMessage (&msg);      DispatchMessage (&msg);    }  }  ExitProcess (msg.wParam);}

⌨️ 快捷键说明

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