Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendxdiag.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactX Diagnosis Application 00003 * LICENSE: LGPL - See COPYING in the top level directory 00004 * FILE: base/applications/dxdiag/dxdiag.c 00005 * PURPOSE: ReactX diagnosis application entry 00006 * COPYRIGHT: Copyright 2008 Johannes Anderwald 00007 * 00008 */ 00009 00010 #include "precomp.h" 00011 00012 /* globals */ 00013 HINSTANCE hInst = 0; 00014 HWND hTabCtrlWnd; 00015 00016 //--------------------------------------------------------------- 00017 VOID 00018 DestroyTabCtrlDialogs(PDXDIAG_CONTEXT pContext) 00019 { 00020 UINT Index; 00021 00022 /* destroy default dialogs */ 00023 for(Index = 0; Index < sizeof(pContext->hDialogs) / sizeof(HWND); Index++) 00024 { 00025 if (pContext->hDialogs[Index]) 00026 DestroyWindow(pContext->hDialogs[Index]); 00027 } 00028 00029 /* destroy display dialogs */ 00030 for(Index = 0; Index < pContext->NumDisplayAdapter; Index++) 00031 { 00032 if (pContext->hDisplayWnd[Index]) 00033 DestroyWindow(pContext->hDisplayWnd[Index]); 00034 } 00035 00036 /* destroy audio dialogs */ 00037 for(Index = 0; Index < pContext->NumSoundAdapter; Index++) 00038 { 00039 if (pContext->hSoundWnd[Index]) 00040 DestroyWindow(pContext->hSoundWnd[Index]); 00041 } 00042 00043 } 00044 00045 //--------------------------------------------------------------- 00046 VOID 00047 InsertTabCtrlItem(HWND hDlgCtrl, INT Position, LPWSTR uId) 00048 { 00049 WCHAR szName[100]; 00050 TCITEMW item; 00051 00052 /* setup item info */ 00053 memset(&item, 0, sizeof(TCITEM)); 00054 item.mask = TCIF_TEXT; 00055 00056 /* load item name */ 00057 if (!HIWORD(uId)) 00058 { 00059 szName[0] = L'\0'; 00060 if (!LoadStringW(hInst, LOWORD(uId), szName, 100)) 00061 return; 00062 szName[99] = L'\0'; 00063 item.pszText = szName; 00064 } 00065 else 00066 { 00067 item.pszText = uId; 00068 } 00069 00070 00071 SendMessageW(hDlgCtrl, TCM_INSERTITEM, Position, (LPARAM)&item); 00072 } 00073 00074 VOID 00075 TabCtrl_OnSelChange(PDXDIAG_CONTEXT pContext) 00076 { 00077 INT Index; 00078 INT CurSel; 00079 00080 /* retrieve new page */ 00081 CurSel = TabCtrl_GetCurSel(hTabCtrlWnd); 00082 if (CurSel < 0 || CurSel > pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 5) 00083 return; 00084 00085 /* hide all windows */ 00086 for(Index = 0; Index < 5; Index++) 00087 ShowWindow(pContext->hDialogs[Index], SW_HIDE); 00088 00089 for(Index = 0; Index < pContext->NumDisplayAdapter; Index++) 00090 ShowWindow(pContext->hDisplayWnd[Index], SW_HIDE); 00091 00092 for(Index = 0; Index < pContext->NumSoundAdapter; Index++) 00093 ShowWindow(pContext->hSoundWnd[Index], SW_HIDE); 00094 00095 00096 if (CurSel == 0 || CurSel > pContext->NumDisplayAdapter + pContext->NumSoundAdapter) 00097 { 00098 if (CurSel) 00099 CurSel -= pContext->NumDisplayAdapter + pContext->NumSoundAdapter; 00100 ShowWindow(pContext->hDialogs[CurSel], SW_SHOW); 00101 return; 00102 } 00103 00104 if (CurSel -1 < pContext->NumDisplayAdapter) 00105 { 00106 ShowWindow(pContext->hDisplayWnd[CurSel-1], SW_SHOW); 00107 return; 00108 } 00109 00110 CurSel -= pContext->NumDisplayAdapter + 1; 00111 ShowWindow(pContext->hSoundWnd[CurSel], SW_SHOW); 00112 } 00113 00114 VOID 00115 InitializeTabCtrl(HWND hwndDlg, PDXDIAG_CONTEXT pContext) 00116 { 00117 /* get tabctrl */ 00118 hTabCtrlWnd = GetDlgItem(hwndDlg, IDC_TAB_CONTROL); 00119 pContext->hTabCtrl = hTabCtrlWnd; 00120 00121 /* create the dialogs */ 00122 pContext->hDialogs[0] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_SYSTEM_DIALOG), hTabCtrlWnd, SystemPageWndProc, (LPARAM)pContext); 00123 pContext->hDialogs[1] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_MUSIC_DIALOG), hTabCtrlWnd, MusicPageWndProc, (LPARAM)pContext); 00124 pContext->hDialogs[2] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_INPUT_DIALOG), hTabCtrlWnd, InputPageWndProc, (LPARAM)pContext); 00125 pContext->hDialogs[3] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_NETWORK_DIALOG), hTabCtrlWnd, NetworkPageWndProc, (LPARAM)pContext); 00126 pContext->hDialogs[4] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_HELP_DIALOG), hTabCtrlWnd, HelpPageWndProc, (LPARAM)pContext); 00127 00128 /* insert tab ctrl items */ 00129 InsertTabCtrlItem(hTabCtrlWnd, 0, MAKEINTRESOURCEW(IDS_SYSTEM_DIALOG)); 00130 InitializeDisplayAdapters(pContext); 00131 InitializeDirectSoundPage(pContext); 00132 InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 1, MAKEINTRESOURCEW(IDS_MUSIC_DIALOG)); 00133 InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 2, MAKEINTRESOURCEW(IDS_INPUT_DIALOG)); 00134 InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 3, MAKEINTRESOURCEW(IDS_NETWORK_DIALOG)); 00135 InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 4, MAKEINTRESOURCEW(IDS_HELP_DIALOG)); 00136 TabCtrl_OnSelChange(pContext); 00137 } 00138 00139 VOID 00140 InitializeDxDiagDialog(HWND hwndDlg) 00141 { 00142 PDXDIAG_CONTEXT pContext; 00143 HICON hIcon; 00144 00145 pContext = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DXDIAG_CONTEXT)); 00146 if (!pContext) 00147 return; 00148 00149 /* store window handle */ 00150 pContext->hMainDialog = hwndDlg; 00151 00152 /* store the context */ 00153 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext); 00154 00155 /* initialize the tab ctrl */ 00156 InitializeTabCtrl(hwndDlg, pContext); 00157 00158 /* load application icon */ 00159 hIcon = LoadImageW(hInst, MAKEINTRESOURCEW(IDI_APPICON), IMAGE_ICON, 16, 16, 0); 00160 if (!hIcon) 00161 return; 00162 /* display icon */ 00163 SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); 00164 } 00165 00166 00167 INT_PTR CALLBACK 00168 DxDiagWndProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 00169 { 00170 LPNMHDR pnmh; 00171 PDXDIAG_CONTEXT pContext; 00172 00173 pContext = (PDXDIAG_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER); 00174 00175 switch (message) 00176 { 00177 case WM_INITDIALOG: 00178 InitializeDxDiagDialog(hwndDlg); 00179 return TRUE; 00180 case WM_COMMAND: 00181 if (LOWORD(wParam) == IDC_BUTTON_SAVE_INFO) 00182 { 00183 //TODO 00184 /* handle save information */ 00185 return TRUE; 00186 } 00187 00188 if (LOWORD(wParam) == IDC_BUTTON_NEXT) 00189 { 00190 INT CurSel; 00191 00192 /* retrieve current page */ 00193 CurSel = TabCtrl_GetCurSel(hTabCtrlWnd); 00194 CurSel++; 00195 00196 /* enable/disable next button */ 00197 EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_NEXT), 00198 (CurSel != TabCtrl_GetItemCount(hTabCtrlWnd) - 1)); 00199 00200 /* switch to next page */ 00201 SendMessageW(hTabCtrlWnd, TCM_SETCURSEL, CurSel, 0L); 00202 00203 return TRUE; 00204 } 00205 00206 if (LOWORD(wParam) == IDC_BUTTON_HELP) 00207 { 00208 //TODO 00209 /* handle help button */ 00210 return TRUE; 00211 } 00212 00213 if (LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDC_BUTTON_EXIT) { 00214 EndDialog(hwndDlg, LOWORD(wParam)); 00215 return TRUE; 00216 } 00217 break; 00218 00219 case WM_NOTIFY: 00220 pnmh = (LPNMHDR)lParam; 00221 if ((pnmh->hwndFrom == hTabCtrlWnd) && (pnmh->idFrom == IDC_TAB_CONTROL) && (pnmh->code == TCN_SELCHANGE)) 00222 { 00223 INT CurSel = TabCtrl_GetCurSel(hTabCtrlWnd); 00224 00225 /* enable/disable next button */ 00226 EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_NEXT), 00227 (CurSel != TabCtrl_GetItemCount(hTabCtrlWnd) - 1)); 00228 00229 TabCtrl_OnSelChange(pContext); 00230 } 00231 break; 00232 case WM_DESTROY: 00233 DestroyTabCtrlDialogs(pContext); 00234 return DefWindowProc(hwndDlg, message, wParam, lParam); 00235 } 00236 return 0; 00237 } 00238 00239 int APIENTRY wWinMain(HINSTANCE hInstance, 00240 HINSTANCE hPrevInstance, 00241 LPWSTR lpCmdLine, 00242 int nCmdShow) 00243 { 00244 00245 INITCOMMONCONTROLSEX InitControls; 00246 00247 UNREFERENCED_PARAMETER(hPrevInstance); 00248 UNREFERENCED_PARAMETER(lpCmdLine); 00249 UNREFERENCED_PARAMETER(nCmdShow); 00250 00251 InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX); 00252 InitControls.dwICC = ICC_TAB_CLASSES | ICC_LISTVIEW_CLASSES | ICC_STANDARD_CLASSES | ICC_TREEVIEW_CLASSES; 00253 InitCommonControlsEx(&InitControls); 00254 00255 hInst = hInstance; 00256 00257 DialogBox(hInst, MAKEINTRESOURCE(IDD_MAIN_DIALOG), NULL, DxDiagWndProc); 00258 00259 return 0; 00260 } Generated on Sun May 27 2012 04:16:34 for ReactOS by
1.7.6.1
|