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.

196 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dialogs.c
  5. Abstract:
  6. This file implements the common dialog proc and other
  7. common code used by other dialog procs. All global
  8. data used by the dialog procs lives here too.
  9. Environment:
  10. WIN32 User Mode
  11. Author:
  12. Wesley Witt (wesw) 17-Feb-1996
  13. --*/
  14. #include "faxocm.h"
  15. #pragma hdrstop
  16. static WNDPROC OldEditProc;
  17. LRESULT
  18. CALLBACK
  19. EulaEditSubProc(
  20. IN HWND hwnd,
  21. IN UINT msg,
  22. IN WPARAM wParam,
  23. IN LPARAM lParam
  24. )
  25. /*++
  26. Routine Description:
  27. Edit control subclass routine, to avoid highlighting text when user
  28. tabs to the edit control.
  29. Arguments:
  30. Standard window proc arguments.
  31. Returns:
  32. Message-dependent value.
  33. --*/
  34. {
  35. //
  36. // For setsel messages, make start and end the same.
  37. //
  38. if ((msg == EM_SETSEL) && ((LPARAM)wParam != lParam)) {
  39. lParam = wParam;
  40. }
  41. return CallWindowProc( OldEditProc, hwnd, msg, wParam, lParam );
  42. }
  43. BOOL
  44. DisplayEula(
  45. HWND hwnd
  46. )
  47. {
  48. HGLOBAL hResource;
  49. LPSTR lpResource;
  50. LPSTR p;
  51. BOOL rVal = FALSE;
  52. DWORD FileSize;
  53. PWSTR EulaText = NULL;
  54. hResource = LoadResource(
  55. hInstance,
  56. FindResource( hInstance, MAKEINTRESOURCE(FAX_EULA), MAKEINTRESOURCE(BINARY) )
  57. );
  58. if (!hResource) {
  59. return FALSE;
  60. }
  61. lpResource = (LPSTR) LockResource(
  62. hResource
  63. );
  64. if (!lpResource) {
  65. FreeResource( hResource );
  66. return FALSE;
  67. }
  68. p = strchr( lpResource, '^' );
  69. if (!p) {
  70. //
  71. // the eula text file is corrupt
  72. //
  73. return FALSE;
  74. }
  75. FileSize = (DWORD)(p - lpResource);
  76. EulaText = (PWSTR) MemAlloc( (FileSize+1) * sizeof(WCHAR) );
  77. if (EulaText == NULL) {
  78. goto exit;
  79. }
  80. MultiByteToWideChar (
  81. CP_ACP,
  82. 0,
  83. lpResource,
  84. FileSize,
  85. EulaText,
  86. (FileSize+1) * sizeof(WCHAR)
  87. );
  88. EulaText[FileSize] = 0;
  89. OldEditProc = (WNDPROC) GetWindowLongPtr( hwnd, GWLP_WNDPROC );
  90. SetWindowLongPtr( hwnd, GWLP_WNDPROC, (ULONG_PTR)EulaEditSubProc );
  91. SetWindowText( hwnd, EulaText );
  92. rVal = TRUE;
  93. exit:
  94. MemFree (EulaText);
  95. if (lpResource) {
  96. FreeResource( lpResource );
  97. }
  98. return rVal;
  99. }
  100. INT_PTR
  101. EulaDlgProc(
  102. HWND hwnd,
  103. UINT msg,
  104. WPARAM wParam,
  105. LPARAM lParam
  106. )
  107. {
  108. switch( msg ) {
  109. case WM_INITDIALOG:
  110. DisplayEula( GetDlgItem( hwnd, IDC_LICENSE_AGREEMENT ) );
  111. break;
  112. case WM_COMMAND:
  113. if (HIWORD(wParam) == BN_CLICKED) {
  114. switch (LOWORD(wParam)) {
  115. case IDC_ACCEPT:
  116. PropSheet_SetWizButtons( GetParent(hwnd), PSWIZB_NEXT );
  117. break;
  118. case IDC_DECLINE:
  119. PropSheet_SetWizButtons( GetParent(hwnd), 0 );
  120. break;
  121. }
  122. }
  123. break;
  124. case WM_NOTIFY:
  125. switch( ((LPNMHDR)lParam)->code ) {
  126. case PSN_SETACTIVE:
  127. if (IsDlgButtonChecked( hwnd, IDC_ACCEPT ) == BST_CHECKED) {
  128. PropSheet_SetWizButtons( GetParent(hwnd), PSWIZB_NEXT );
  129. } else {
  130. PropSheet_SetWizButtons( GetParent(hwnd), 0 );
  131. }
  132. if (Upgrade) {
  133. PropSheet_SetWizButtons( GetParent(hwnd), PSWIZB_NEXT );
  134. SetWindowLongPtr(hwnd, DWLP_MSGRESULT ,-1);
  135. return TRUE;
  136. }
  137. break;
  138. default:
  139. break;
  140. }
  141. break;
  142. default:
  143. break;
  144. }
  145. return FALSE;
  146. }