Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
5.6 KiB

  1. /*
  2. +-------------------------------------------------------------------------+
  3. | Initialization Code |
  4. +-------------------------------------------------------------------------+
  5. | (c) Copyright 1993 |
  6. | Microsoft Corp. |
  7. | All rights reserved |
  8. | |
  9. | Program : [mpinit.c] |
  10. | Programmer : Arthur Hanson |
  11. | Original Program Date : [Jul 27, 1993 |
  12. | Last Update : [Jul 30, 1993] Time : 18:30 |
  13. | |
  14. | Version: 0.10 |
  15. | |
  16. | Description: |
  17. | |
  18. | History: |
  19. | arth Jul 27, 1993 0.10 Original Version. |
  20. | |
  21. +-------------------------------------------------------------------------+
  22. */
  23. #include "LogView.h"
  24. CHAR szFrame[] = "mpframe"; // Class name for "frame" window
  25. CHAR szChild[] = "mpchild"; // Class name for MDI window
  26. /*+-------------------------------------------------------------------------+
  27. | InitializeApplication() |
  28. | |
  29. +-------------------------------------------------------------------------+*/
  30. BOOL APIENTRY InitializeApplication() {
  31. WNDCLASS wc;
  32. // Register the frame class
  33. wc.style = 0;
  34. wc.lpfnWndProc = (WNDPROC) MPFrameWndProc;
  35. wc.cbClsExtra = 0;
  36. wc.cbWndExtra = 0;
  37. wc.hInstance = hInst;
  38. wc.hIcon = LoadIcon(hInst,IDLOGVIEW);
  39. wc.hCursor = LoadCursor(NULL,IDC_ARROW);
  40. wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1);
  41. wc.lpszMenuName = IDLOGVIEW;
  42. wc.lpszClassName = szFrame;
  43. if (!RegisterClass (&wc) )
  44. return FALSE;
  45. // Register the MDI child class
  46. wc.lpfnWndProc = (WNDPROC) MPMDIChildWndProc;
  47. wc.hIcon = LoadIcon(hInst,IDNOTE);
  48. wc.lpszMenuName = NULL;
  49. wc.cbWndExtra = CBWNDEXTRA;
  50. wc.lpszClassName = szChild;
  51. if (!RegisterClass(&wc))
  52. return FALSE;
  53. return TRUE;
  54. } // InitializeApplication
  55. /*+-------------------------------------------------------------------------+
  56. | InitializeInstance() |
  57. | |
  58. +-------------------------------------------------------------------------+*/
  59. BOOL APIENTRY InitializeInstance(LPSTR lpCmdLine, INT nCmdShow) {
  60. extern HWND hwndMDIClient;
  61. CHAR sz[80], *pCmdLine, *pFileName, *pChar;
  62. HDC hdc;
  63. HMENU hmenu;
  64. // Get the base window title
  65. LoadString (hInst, IDS_APPNAME, sz, sizeof(sz));
  66. hStdCursor= LoadCursor( NULL,IDC_ARROW );
  67. hWaitCursor= LoadCursor( NULL, IDC_WAIT );
  68. // Create the frame
  69. hwndFrame = CreateWindow (szFrame, sz, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
  70. CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL,
  71. NULL, hInst, NULL);
  72. if ((!hwndFrame) || (!hwndMDIClient))
  73. return FALSE;
  74. // Load main menu accelerators
  75. if (!(hAccel = LoadAccelerators (hInst, IDLOGVIEW)))
  76. return FALSE;
  77. // init.fields of the FINDREPLACE struct used by FindText()
  78. FR.lStructSize = sizeof(FINDREPLACE);
  79. FR.hwndOwner = hwndFrame;
  80. FR.Flags = FR_DOWN | FR_HIDEWHOLEWORD;
  81. FR.lpstrReplaceWith = (LPTSTR)NULL;
  82. FR.wReplaceWithLen = 0;
  83. FR.lpfnHook = NULL;
  84. /* determine the message number to be used for communication with
  85. * Find dialog
  86. */
  87. if (!(wFRMsg = RegisterWindowMessage ((LPTSTR)FINDMSGSTRING)))
  88. return FALSE;
  89. if (!(wHlpMsg = RegisterWindowMessage ((LPTSTR)HELPMSGSTRING)))
  90. return FALSE;
  91. // Display the frame window
  92. ShowWindow (hwndFrame, nCmdShow);
  93. UpdateWindow (hwndFrame);
  94. // If the command line string is empty, nullify the pointer to it else copy
  95. // command line into our data segment
  96. if ( lpCmdLine && !(*lpCmdLine)) {
  97. pCmdLine = NULL;
  98. // Add the first MDI window
  99. AddFile (pCmdLine);
  100. } else {
  101. pCmdLine = (CHAR *) LocalAlloc(LPTR, lstrlen(lpCmdLine) + 1);
  102. if (pCmdLine) {
  103. lstrcpy(pCmdLine, lpCmdLine);
  104. pFileName = pChar = pCmdLine;
  105. while (*pChar) {
  106. if (*pChar == ' ') {
  107. *pChar = '\0';
  108. AddFile(pFileName);
  109. *pChar = ' ';
  110. pChar++;
  111. pFileName = pChar;
  112. } else
  113. pChar++;
  114. }
  115. AddFile(pFileName);
  116. } else
  117. // Add the first MDI window
  118. AddFile (pCmdLine);
  119. }
  120. // if we allocated a buffer then free it
  121. if (pCmdLine)
  122. LocalFree((LOCALHANDLE) pCmdLine);
  123. return TRUE;
  124. UNREFERENCED_PARAMETER(hmenu);
  125. UNREFERENCED_PARAMETER(hdc);
  126. } // InitializeInstance