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.

309 lines
7.1 KiB

  1. #include "precomp.h"
  2. #include "resource.h"
  3. #include "nmakwiz.h"
  4. #include "wndprocs.h"
  5. LRESULT CALLBACK RestrictAvThroughputWndProc( HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
  6. {
  7. switch( iMsg )
  8. {
  9. case WM_VSCROLL:
  10. {
  11. OnMsg_VScroll( hwnd, wParam );
  12. return 0;
  13. break;
  14. }
  15. case WM_HSCROLL:
  16. {
  17. TCHAR szPos[ MAX_DIGITS ];
  18. DWORD dwPos = SendMessage( GetDlgItem( hwnd, IDC_SLIDE_AV_THROUGHPUT), TBM_GETPOS, 0, 0);
  19. wsprintf( szPos, "%d", dwPos );
  20. Static_SetText( GetDlgItem( hwnd, IDC_STATIC_MAX_AV_THROUGHPUT), szPos );
  21. return 0;
  22. break;
  23. }
  24. case WM_COMMAND:
  25. {
  26. return 0;
  27. break;
  28. }
  29. }
  30. return( DefWindowProc( hwnd, iMsg, wParam, lParam ) );
  31. }
  32. LRESULT CALLBACK wndProcForCheckTiedToEdit( HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
  33. {
  34. PSUBDATA pSubData = (PSUBDATA)GetWindowLong( hwnd, GWL_USERDATA );
  35. WNDPROC proc = pSubData->proc;
  36. switch( iMsg )
  37. {
  38. case WM_ENABLE:
  39. {
  40. if( Button_GetCheck( hwnd ) )
  41. {
  42. list< HWND >::const_iterator it;
  43. for( it = pSubData -> list . begin(); it != pSubData -> list . end(); ++it )
  44. {
  45. ::EnableWindow( (HWND)(*it), (BOOL)wParam );
  46. }
  47. }
  48. break;
  49. }
  50. case BM_SETCHECK:
  51. {
  52. if( IsWindowEnabled( hwnd ) )
  53. {
  54. list< HWND >::const_iterator it;
  55. for( it = pSubData -> list . begin(); it != pSubData -> list . end(); ++it )
  56. {
  57. ::EnableWindow( (HWND)(*it), (BOOL)wParam );
  58. }
  59. }
  60. break;
  61. }
  62. case WM_NCDESTROY:
  63. {
  64. delete pSubData;
  65. break;
  66. }
  67. }
  68. return( CallWindowProc( proc, hwnd, iMsg, wParam, lParam ) );
  69. }
  70. int _ControlIsObscured( HWND parentControl, HWND hwndControl );
  71. int _ControlIsObscured( HWND parentControl, HWND hwndControl )
  72. {
  73. RECT rectControl;
  74. GetWindowRect( hwndControl, &rectControl );
  75. RECT rectParent;
  76. GetWindowRect( parentControl, &rectParent );
  77. if( rectControl . top < rectParent . top )
  78. {
  79. // Scroll
  80. return -1;
  81. }
  82. else if( rectControl . bottom > rectParent . bottom )
  83. {
  84. // Scroll
  85. return 1;
  86. }
  87. else
  88. {
  89. return 0;
  90. }
  91. }
  92. enum tagCategoryButtonStates
  93. {
  94. STATE_UNSELECTED,
  95. STATE_SELECTED,
  96. STATE_SELECTED_VIS,
  97. STATE_CHECKED,
  98. STATE_CHECKED_VIS
  99. };
  100. LRESULT CALLBACK CatListWndProc( HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
  101. {
  102. switch( iMsg )
  103. {
  104. case WM_CREATE:
  105. {
  106. // Note - this should be set to the top check box
  107. PostMessage( hwnd, WM_COMMAND, MAKEWPARAM( IDC_SET_CALLING_OPTIONS, BN_CLICKED ), 0L );
  108. break;
  109. }
  110. case WM_COMMAND:
  111. {
  112. UINT uHiword = GET_WM_COMMAND_CMD(wParam, lParam);
  113. UINT uLoword = GET_WM_COMMAND_ID(wParam, lParam);
  114. switch( uHiword )
  115. {
  116. case BN_DOUBLECLICKED:
  117. case BN_CLICKED:
  118. {
  119. HWND hwndButton = GetDlgItem(hwnd, uLoword);
  120. ULONG uState = GetWindowLong( hwndButton, GWL_USERDATA );
  121. switch( uState )
  122. {
  123. case STATE_UNSELECTED:
  124. {
  125. if (Button_GetCheck(hwndButton))
  126. {
  127. SetWindowLong(hwndButton, GWL_USERDATA, STATE_CHECKED_VIS );
  128. }
  129. else
  130. {
  131. SetWindowLong(hwndButton, GWL_USERDATA, STATE_SELECTED_VIS );
  132. }
  133. g_pWiz->m_SettingsSheet.ShowWindow(uLoword, TRUE);
  134. break;
  135. }
  136. case STATE_SELECTED:
  137. case STATE_SELECTED_VIS:
  138. {
  139. if ((uHiword == BN_DOUBLECLICKED) && (STATE_SELECTED_VIS != uState))
  140. {
  141. break;
  142. }
  143. Button_SetCheck( hwndButton, TRUE );
  144. g_pWiz -> m_SettingsSheet . EnableWindow( uLoword, TRUE );
  145. g_pWiz->m_SettingsSheet.SetFocus( uLoword );
  146. SetWindowLong( hwndButton, GWL_USERDATA, STATE_CHECKED );
  147. break;
  148. }
  149. case STATE_CHECKED:
  150. case STATE_CHECKED_VIS:
  151. {
  152. if ((uHiword == BN_DOUBLECLICKED) && (STATE_CHECKED_VIS != uState))
  153. {
  154. break;
  155. }
  156. Button_SetCheck( hwndButton, FALSE );
  157. g_pWiz -> m_SettingsSheet . EnableWindow( uLoword, FALSE );
  158. SetWindowLong( hwndButton, GWL_USERDATA, STATE_SELECTED );
  159. break;
  160. }
  161. }
  162. return 0;
  163. break;
  164. }
  165. case EN_SETFOCUS:
  166. case BN_SETFOCUS:
  167. {
  168. return 0;
  169. }
  170. }
  171. }
  172. case WM_VSCROLL:
  173. {
  174. OnMsg_VScroll( hwnd, wParam );
  175. return 0;
  176. }
  177. }
  178. return( DefWindowProc( hwnd, iMsg, wParam, lParam ) );
  179. }
  180. enum { SCROLL_JUMP = 20 };
  181. void OnMsg_VScroll( HWND hwnd, WPARAM wParam )
  182. {
  183. int nPosition;
  184. int nHorzScroll = 0;
  185. int nVertScroll = 0;
  186. SCROLLINFO ScrollInfo;
  187. WORD wScrollCode = (WORD)LOWORD(wParam);
  188. // Get current scroll information.
  189. ScrollInfo.cbSize = sizeof(SCROLLINFO);
  190. ScrollInfo.fMask = SIF_ALL;
  191. GetScrollInfo(hwnd, SB_VERT, &ScrollInfo);
  192. nPosition = ScrollInfo.nPos;
  193. // Modify scroll information based on requested
  194. // scroll action.
  195. RECT rectWindow;
  196. GetClientRect( hwnd, &rectWindow );
  197. int iDelta;
  198. switch (wScrollCode)
  199. {
  200. case SB_LINEDOWN:
  201. iDelta = -SCROLL_JUMP;
  202. ScrollInfo.nPos += SCROLL_JUMP;
  203. break;
  204. case SB_LINEUP:
  205. iDelta = SCROLL_JUMP;
  206. ScrollInfo.nPos -= SCROLL_JUMP;
  207. break;
  208. case SB_PAGEDOWN:
  209. iDelta = -ScrollInfo.nPage;
  210. ScrollInfo.nPos += ScrollInfo.nPage;
  211. break;
  212. case SB_PAGEUP:
  213. iDelta = ScrollInfo.nPage;
  214. ScrollInfo.nPos -= ScrollInfo.nPage;
  215. break;
  216. case SB_TOP:
  217. iDelta = rectWindow . top - rectWindow . bottom;/*170;*/
  218. ScrollInfo.nPos = ScrollInfo.nMin;
  219. break;
  220. case SB_BOTTOM:
  221. iDelta = rectWindow . top - rectWindow . bottom;/*170;*/
  222. ScrollInfo.nPos = ScrollInfo.nMax;
  223. break;
  224. // Don't do anything.
  225. case SB_THUMBPOSITION:
  226. case SB_THUMBTRACK:
  227. iDelta = -(ScrollInfo.nTrackPos - ScrollInfo.nPos);
  228. ScrollInfo.nPos = ScrollInfo.nTrackPos;
  229. break;
  230. case SB_ENDSCROLL:
  231. default:
  232. return;
  233. }
  234. // Make sure that scroll position is in range.
  235. if (0 > ScrollInfo.nPos)
  236. {
  237. ScrollInfo.nPos = 0;
  238. }
  239. else if (ScrollInfo.nMax - (int) ScrollInfo.nPage + 1 < ScrollInfo.nPos)
  240. {
  241. ScrollInfo.nPos = ScrollInfo.nMax - ScrollInfo.nPage + 1;
  242. }
  243. // Set new scroll position.
  244. ScrollInfo.fMask = SIF_POS;
  245. SetScrollInfo(hwnd, SB_VERT, &ScrollInfo, TRUE);
  246. // Scroll window.
  247. nVertScroll = nPosition - ScrollInfo.nPos;
  248. ScrollWindowEx(hwnd, nHorzScroll, nVertScroll, NULL, NULL,
  249. NULL, NULL, SW_ERASE | SW_INVALIDATE | SW_SCROLLCHILDREN);
  250. //InvalidateRect( hwnd, NULL, TRUE );
  251. if( 0 < iDelta )
  252. {
  253. iDelta += 1;
  254. SetRect( &rectWindow, rectWindow . left, rectWindow . top , rectWindow . right, rectWindow . top + iDelta /*164, 200, 164 + 375, 200 + iDelta */ );
  255. }
  256. else if( 0 > iDelta )
  257. {
  258. iDelta -= 1;
  259. SetRect( &rectWindow, rectWindow . left, rectWindow . bottom + iDelta , rectWindow . right, rectWindow . bottom /*164, 200 + 170 + iDelta, 164 + 375, 200 + 170*/ );
  260. }
  261. else
  262. {
  263. return;
  264. }
  265. MapWindowPoints( hwnd, GetParent( hwnd ), (LPPOINT) &rectWindow, 2 );
  266. RedrawWindow( GetParent( hwnd ), &rectWindow, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW | RDW_UPDATENOW | RDW_ALLCHILDREN );
  267. return;
  268. }