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.

228 lines
6.4 KiB

  1. /*---------------------------------------------------------------------------*\
  2. | WINCHAT RESOURCE FILE
  3. | This module defines the resources for the WinChat application
  4. |
  5. | FUNCTIONS
  6. | ---------
  7. | dlgConnectProc
  8. | dlgPreferencesProc
  9. |
  10. |
  11. | Copyright (c) Microsoft Corp., 1990-1993
  12. |
  13. | created: 01-Nov-91
  14. | history: 01-Nov-91 <clausgi> created.
  15. | 29-Dec-92 <chriswil> port to NT, cleanup.
  16. | 19-Oct-93 <chriswil> unicode enhancements from a-dianeo.
  17. |
  18. \*---------------------------------------------------------------------------*/
  19. #include <windows.h>
  20. #include <ddeml.h>
  21. #include <commdlg.h>
  22. #include <winchat.h>
  23. #include "dialogs.h"
  24. #include "globals.h"
  25. #ifdef WIN16
  26. #pragma alloc_text (_DLGS, dlgConnectProc, dlgPreferencesProc)
  27. #endif
  28. /*---------------------------------------------------------------------------*\
  29. | DISPLAY DIALOG BOX
  30. | This is a routine to display a generic modal-dialog box.
  31. |
  32. | created: 29-Dec-92
  33. | history: 29-Dec-92 <chriswil> created.
  34. |
  35. \*---------------------------------------------------------------------------*/
  36. INT_PTR FAR dlgDisplayBox(HINSTANCE hInstance, HWND hWndParent, LPTSTR lpszTemplate, DLGPROC lpfFunction, LPARAM lParam)
  37. {
  38. INT_PTR nRet;
  39. nRet = DialogBoxParam(hInstance,lpszTemplate,hWndParent,lpfFunction,lParam);
  40. return(nRet);
  41. }
  42. /*---------------------------------------------------------------------------*\
  43. | CONNECT DIALOGBOX PROCEDURE
  44. | This routines prompts the connection dialogbox
  45. |
  46. | created: 11-Nov-91
  47. | history: 29-Dev-92 <chriswil> ported to NT.
  48. |
  49. \*---------------------------------------------------------------------------*/
  50. INT_PTR CALLBACK dlgConnectProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  51. {
  52. BOOL bHandled;
  53. bHandled = TRUE;
  54. switch(msg)
  55. {
  56. // result in global szConvPartner (CODEWORK replace lParam)
  57. //
  58. case WM_INITDIALOG:
  59. szConvPartner[0] = TEXT('\0');
  60. break;
  61. case WM_COMMAND:
  62. switch(wParam)
  63. {
  64. case IDOK:
  65. GetDlgItemText(hwnd,IDC_CONNECTNAME,szBuf,SZBUFSIZ);
  66. EndDialog(hwnd,0);
  67. break;
  68. case IDCANCEL:
  69. szConvPartner[0] = TEXT('\0');
  70. EndDialog(hwnd,0);
  71. break;
  72. default:
  73. bHandled = FALSE;
  74. break;
  75. }
  76. break;
  77. default:
  78. bHandled = FALSE;
  79. break;
  80. }
  81. return(bHandled);
  82. }
  83. /*---------------------------------------------------------------------------*\
  84. | PREFERENCES DIALOGBOX PROCEDURE
  85. | This routines prompts the connection dialogbox
  86. |
  87. | created: 11-Nov-91
  88. | history: 29-Dev-92 <chriswil> ported to NT.
  89. |
  90. \*---------------------------------------------------------------------------*/
  91. // context sensitive help array
  92. static const DWORD aHelpIDs[] =
  93. {
  94. ID_TOPANDBOTTOM, IDH_TOPANDBOTTOM,
  95. ID_SIDEBYSIDE , IDH_SIDEBYSIDE,
  96. ID_RECEIVEPFONT, IDH_RECEIVEPFONT,
  97. ID_RECEIVEOFONT, IDH_RECEIVEOFONT,
  98. IDOK , IDH_OKBUTTON,
  99. IDCANCEL , IDH_CANCELBUTTON,
  100. 0, 0
  101. };
  102. INT_PTR CALLBACK dlgPreferencesProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  103. {
  104. BOOL bHandled;
  105. UINT tmp;
  106. bHandled = TRUE;
  107. switch(msg)
  108. {
  109. case WM_INITDIALOG:
  110. CheckDlgButton(hwnd,ID_SIDEBYSIDE ,ChatState.fSideBySide);
  111. CheckDlgButton(hwnd,ID_TOPANDBOTTOM,!ChatState.fSideBySide);
  112. CheckDlgButton(hwnd,ID_RECEIVEOFONT,ChatState.fUseOwnFont);
  113. CheckDlgButton(hwnd,ID_RECEIVEPFONT,!ChatState.fUseOwnFont);
  114. break;
  115. case WM_COMMAND:
  116. switch(wParam)
  117. {
  118. case IDOK:
  119. tmp = (BOOL)SendDlgItemMessage(hwnd,ID_RECEIVEOFONT,BM_GETCHECK,0,0L);
  120. if(tmp != ChatState.fUseOwnFont)
  121. {
  122. ChatState.fUseOwnFont = tmp;
  123. // delete old objects
  124. //
  125. if(hEditRcvFont)
  126. DeleteObject(hEditRcvFont);
  127. if(hEditRcvBrush)
  128. DeleteObject(hEditRcvBrush);
  129. if(ChatState.fUseOwnFont)
  130. {
  131. hEditRcvFont = CreateFontIndirect((LPLOGFONT)&lfSnd);
  132. hEditRcvBrush = CreateSolidBrush(SndBrushColor);
  133. }
  134. else
  135. {
  136. RcvBrushColor = PartBrushColor;
  137. hEditRcvFont = CreateFontIndirect((LPLOGFONT)&lfRcv);
  138. hEditRcvBrush = CreateSolidBrush(RcvBrushColor);
  139. }
  140. if(hEditRcvFont)
  141. {
  142. SendMessage(hwndRcv,WM_SETFONT,(WPARAM)hEditRcvFont,1L);
  143. InvalidateRect(hwndRcv,NULL,TRUE);
  144. }
  145. }
  146. tmp = (BOOL)SendDlgItemMessage(hwnd,ID_SIDEBYSIDE,BM_GETCHECK,0,0L);
  147. if(tmp != ChatState.fSideBySide)
  148. {
  149. ChatState.fSideBySide = tmp;
  150. AdjustEditWindows();
  151. InvalidateRect(hwndApp,NULL,FALSE);
  152. }
  153. EndDialog(hwnd,0);
  154. break;
  155. case IDCANCEL:
  156. EndDialog(hwnd,0);
  157. break;
  158. default:
  159. bHandled = FALSE;
  160. break;
  161. }
  162. break;
  163. case WM_HELP:
  164. {
  165. LPHELPINFO lphi;
  166. lphi = (LPHELPINFO)lParam;
  167. if (lphi->iContextType == HELPINFO_WINDOW) // must be for a control
  168. { WinHelp (lphi->hItemHandle, szHelpFile,
  169. HELP_WM_HELP, (ULONG_PTR)aHelpIDs);
  170. }
  171. return TRUE;
  172. }
  173. break;
  174. case WM_CONTEXTMENU:
  175. {
  176. WinHelp ((HWND)wParam, szHelpFile, HELP_CONTEXTMENU,
  177. (ULONG_PTR)aHelpIDs);
  178. return TRUE;
  179. }
  180. break;
  181. default:
  182. bHandled = FALSE;
  183. break;
  184. }
  185. return(bHandled);
  186. }