Leaked source code of windows server 2003
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.

157 lines
4.4 KiB

  1. /* File: D:\WACKER\tdll\property.c (Created: 19-Jan-1994)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 4 $
  7. * $Date: 7/08/02 6:46p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <prsht.h>
  12. #include <commctrl.h>
  13. #include <time.h>
  14. #include <tdll\assert.h>
  15. #include "stdtyp.h"
  16. #include "mc.h"
  17. #include "misc.h"
  18. #include "globals.h"
  19. #include "session.h"
  20. #include "load_res.h"
  21. #include "htchar.h"
  22. #include <emu\emuid.h>
  23. #include <emu\emu.h>
  24. #include <emu\emudlgs.h>
  25. #include "cnct.h"
  26. #include <cncttapi\cncttapi.h>
  27. #include <term\res.h>
  28. #include "property.h"
  29. #include "statusbr.h"
  30. #include "tdll.h"
  31. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  32. * FUNCTION:
  33. * DoInternalProperties
  34. *
  35. * DESCRIPTION:
  36. * Display the property sheet as seen from within an open session, i.e., the
  37. * general tab is not a part of it.
  38. *
  39. * PARAMETERS:
  40. * hSession - the session handle.
  41. * hwnd - window handle.
  42. *
  43. * RETURNS:
  44. * Nothing.
  45. */
  46. void DoInternalProperties(HSESSION hSession, HWND hwnd)
  47. {
  48. TCHAR achName[256];
  49. PROPSHEETHEADER stH;
  50. HPROPSHEETPAGE hP[2];
  51. PROPSHEETPAGE stP;
  52. hP[0] = hP[1] = (HPROPSHEETPAGE)0;
  53. memset(&stP, 0, sizeof(stP));
  54. stP.dwSize = sizeof(PROPSHEETPAGE);
  55. stP.dwFlags = 0;
  56. stP.hInstance = glblQueryDllHinst();
  57. stP.pszTemplate = MAKEINTRESOURCE(IDD_TAB_PHONENUMBER);
  58. stP.pfnDlgProc = NewPhoneDlg;
  59. stP.lParam = (LPARAM)hSession;
  60. stP.pfnCallback = 0;
  61. hP[0] = CreatePropertySheetPage(&stP);
  62. stP.dwSize = sizeof(PROPSHEETPAGE);
  63. stP.dwFlags = 0;
  64. stP.hInstance = glblQueryDllHinst();
  65. stP.pszTemplate = MAKEINTRESOURCE(IDD_TAB_TERMINAL);
  66. stP.pfnDlgProc = TerminalTabDlg;
  67. stP.lParam = (LPARAM)hSession;
  68. stP.pfnCallback = 0;
  69. hP[1] = CreatePropertySheetPage(&stP);
  70. sessQueryName(hSession, achName, sizeof(achName));
  71. memset(&stH, 0, sizeof(stH));
  72. stH.dwSize = sizeof(PROPSHEETHEADER);
  73. stH.hwndParent = hwnd;
  74. stH.hInstance = glblQueryDllHinst();
  75. stH.pszCaption = achName;
  76. stH.nPages = 2;
  77. stH.nStartPage = 0;
  78. stH.phpage = hP;
  79. stH.dwFlags = PSH_PROPTITLE | PSH_NOAPPLYNOW;
  80. PropertySheet(&stH);
  81. }
  82. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  83. * FUNCTION:
  84. * propUpdateTitle
  85. *
  86. * DESCRIPTION:
  87. * When the user changes the name of the session we need to reflect the change
  88. * in the property sheet title. Right now it uses "Property sheet for <lpszStr>".
  89. * in the english version. Since there appears to be no way to dynamically
  90. * change property sheet's title, we implemented this function. We avoid
  91. * placing any part of the title in the resource file to prevent problems with
  92. * international versions, order of words, etc. and most importantly possible
  93. * discrepancy with the title string used by Microsoft in the property sheet.
  94. * Instead we read the current title, match on the old session name and replace
  95. * it with the new session name.
  96. *
  97. * PARAMETERS:
  98. * hSession - the session handle.
  99. * hDlg - handle of the property sheet tab dialog.
  100. * pachOldName - pointer to the old session name.
  101. *
  102. * RETURNS:
  103. * Nothing.
  104. */
  105. void propUpdateTitle(HSESSION hSession, HWND hDlg, LPTSTR pachOldName)
  106. {
  107. HWND hwnd = GetParent(hDlg);
  108. TCHAR acTitle[256], acName[256], acNewTitle[256];
  109. LPTSTR pszStr, pszStr2;
  110. GetWindowText(hwnd, acTitle, sizeof(acTitle));
  111. sessQueryName(hSession, acName, sizeof(acName));
  112. if (acName[0] != TEXT('\0'))
  113. {
  114. TCHAR_Fill(acNewTitle, TEXT('\0'), sizeof(acNewTitle) / sizeof(TCHAR));
  115. // TODO: What if the session name matches title text, eg.
  116. // "Properties for properties"?
  117. // Also, looks like I will have to write my own strstr() but
  118. // let's wait and see what Mircorsoft will tell us...
  119. //
  120. // if ((pszStr = (LPTSTR)strstr(acTitle, pachOldName)) != NULL)
  121. if ((pszStr = StrCharStrStr(acTitle, pachOldName)) != NULL)
  122. {
  123. for (pszStr2 = pszStr;
  124. *pszStr2 || *pachOldName != TEXT('\0');
  125. pszStr2 = StrCharNext(pszStr2),
  126. pachOldName = StrCharNext(pachOldName))
  127. {
  128. continue;
  129. }
  130. *pszStr = TEXT('\0');
  131. StrCharCopyN(acNewTitle, acTitle, sizeof(acNewTitle) / sizeof(TCHAR) );
  132. StrCharCat(acNewTitle, acName);
  133. StrCharCat(acNewTitle, pszStr2);
  134. }
  135. SetWindowText(hwnd, acNewTitle);
  136. }
  137. }