// Binary value has changed static int UpdateEaValueText(HWND hDlg) { LPTSTR szTextValue; LPTSTR szBinValue; LPBYTE pbBinValue; HWND hSrcEdit = GetDlgItem(hDlg, IDC_DATA_VALUE_BIN); HWND hTrgEdit = GetDlgItem(hDlg, IDC_DATA_VALUE_TEXT); int nTextLength = GetWindowTextLength(hSrcEdit); int nBinLength; szTextValue = new TCHAR[nTextLength * 4 + 1]; szBinValue = new TCHAR[nTextLength + 1]; pbBinValue = new BYTE[nTextLength + 1]; GetWindowText(hSrcEdit, szBinValue, nTextLength + 1); _tcsupr(szBinValue); // Process the binary buffer and convert it to the binary data nChangingEdit++; nBinLength = BinTextToBinArray(szBinValue, pbBinValue); if(nBinLength != -1) { BinArrayToCText(pbBinValue, nBinLength, szTextValue); SetWindowText(hTrgEdit, szTextValue); } else SetWindowTextRc(hTrgEdit, IDS_CONVERSION_ERROR); nChangingEdit--; delete [] pbBinValue; delete [] szBinValue; delete [] szTextValue; return TRUE; }
static void OnNotify(HWND hDlg, NMHDR * pNMHDR) { if(pNMHDR->code == DEN_EXCEPTION) { PDTE_EXCEPTION_DATA pExceptionData = (PDTE_EXCEPTION_DATA)pNMHDR; HWND hWndChild = GetDlgItem(hDlg, IDC_INFORMATION); if(hWndChild != NULL) { SetWindowTextRc(hWndChild, IDS_DATA_EXCEPTION, pExceptionData->WriteOperation ? _T("writing") : _T("reading"), pExceptionData->ExceptionAddress); } } }
static int OnInitDialog(HWND hDlg, LPARAM lParam) { PFILE_FULL_EA_INFORMATION * ppEaItem = (PFILE_FULL_EA_INFORMATION *)lParam; PFILE_FULL_EA_INFORMATION pEaItem = *ppEaItem; HWND hWndChild; // Configure the dialog SetWindowLongPtr(hDlg, DWLP_USER, lParam); SetDialogIcon(hDlg, IDI_FILE_TEST); CenterWindowToParent(hDlg); // Set the dialog title to "Insert" or to "Edit" SetWindowTextRc(hDlg, pEaItem ? IDS_EDIT_EA_TITLE : IDS_INSERT_EA_TITLE); // Set the name and value limit hWndChild = GetDlgItem(hDlg, IDC_DATA_NAME); if(hWndChild != NULL) Edit_LimitText(hWndChild, (BYTE)-1); // Fill the dialog nChangingEdit++; CheckDlgButton(hDlg, IDC_RADIO1, BST_CHECKED); if(pEaItem != NULL) { if(hWndChild != NULL) SetWindowTextA(hWndChild, pEaItem->EaName); SetDlgItemCText(hDlg, IDC_DATA_VALUE_TEXT, (LPBYTE)pEaItem->EaName + pEaItem->EaNameLength + 1, pEaItem->EaValueLength); SetDlgItemBin(hDlg, IDC_DATA_VALUE_BIN, (LPBYTE)pEaItem->EaName + pEaItem->EaNameLength + 1, pEaItem->EaValueLength); } UpdateDialog(hDlg); nChangingEdit--; return TRUE; }
// Arranging the dialog layout for empty dialogs, where the controls need to be created static void CreateDialogLayout_Empty(TFlagDialogData * pData) { TFlagInfo * pFlags; HWND hWndGroup = GetDlgItem(pData->hDlg, IDC_GROUPBOX); HWND hWndFirst = GetDlgItem(pData->hDlg, IDC_CHILD_MUSTER); HWND hWndChild = hWndFirst; RECT DialogRect; // Rectangle of the dialog (screen-relative) RECT ParentRect; // Rectangle of the dialog's parent (screen-relative) RECT ClientRect; // Rectangle of the dialog client area (screen-relative) RECT GroupRect; // Rectangle of the group box RECT CheckBoxRect; // Rectangle of the checkbox DWORD dwFlags = pData->dwFlags; int nChecked = BST_UNCHECKED; int x, y, cx, cy; // Get the size of the parent if(pData->hWndParent != NULL) GetWindowRect(pData->hWndParent, &ParentRect); else SystemParametersInfo(SPI_GETWORKAREA, 0, &ParentRect, FALSE); // Set the dialog title SetWindowTextRc(pData->hDlg, pData->nIDTitle); // Get the size of the dialog and the "master" settings GetWindowRect(pData->hDlg, &DialogRect); GetClientRect(pData->hDlg, &ClientRect); pData->hFont = (HFONT)SendMessage(hWndChild, WM_GETFONT, 0, 0); // Get the position of the groupbox and the child muster GetWindowRect(hWndGroup, &GroupRect); ScreenRectToClientRect(pData->hDlg, &GroupRect); GetWindowRect(hWndChild, &CheckBoxRect); ScreenRectToClientRect(pData->hDlg, &CheckBoxRect); // Get the settings of the "master" checkbox pData->dwExStyle = GetWindowLong(hWndChild, GWL_EXSTYLE); pData->dwStyle = GetWindowLong(hWndChild, GWL_STYLE) & ~(WS_TABSTOP | WS_GROUP); // Create all switch items for(pFlags = pData->pFlags; pFlags->szFlagText != NULL; pFlags++) { // Create the (next) switch item hWndChild = CreateSwitchItem(pData, pFlags, CheckBoxRect, hWndChild); nChecked = BST_UNCHECKED; // Check/uncheck the box if(pFlags->dwValue != FLAG_SEPARATOR) { // Do we have radio buttons? if(pData->IsValueDialog) { if(dwFlags == pFlags->dwValue) { nChecked = BST_CHECKED; dwFlags = 0; } } else { if((dwFlags & pFlags->dwMask) == pFlags->dwValue) { nChecked = BST_CHECKED; dwFlags = dwFlags & ~pFlags->dwValue; } } // Check or uncheck the button Button_SetCheck(hWndChild, nChecked); } // The next control will be created dynamically, 6 dialog units lower hWndChild = NULL; } // If there is at least one flag unused, we need to create an extra button if(dwFlags != 0) { LoadString(g_hInst, IDS_CUSTOM_VALUE, pData->szCustomValue, _maxchars(pData->szCustomValue)); pData->ExtraFlag.dwValue = dwFlags; pData->ExtraFlag.dwMask = 0xFFFFFFFF; pData->ExtraFlag.szFlagText = pData->szCustomValue; hWndChild = CreateSwitchItem(pData, &pData->ExtraFlag, CheckBoxRect, hWndChild); Button_SetCheck(hWndChild, BST_CHECKED); } // Resize the group box so it covers all buttons cx = (GroupRect.right - GroupRect.left); cy = (GroupRect.bottom - GroupRect.top) + pData->nDeltaY; SetWindowPos(hWndGroup, NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); // Move the buttons ArrangeDialogButton(pData->hDlg, ClientRect, IDC_SELECT_ALL, pData->nDeltaY); ArrangeDialogButton(pData->hDlg, ClientRect, IDC_CLEAR_ALL, pData->nDeltaY); ArrangeDialogButton(pData->hDlg, ClientRect, IDOK, pData->nDeltaY); // Resize and center the dialog cx = (DialogRect.right - DialogRect.left); cy = (DialogRect.bottom - DialogRect.top) + pData->nDeltaY; x = ParentRect.left + ((ParentRect.right - ParentRect.left) - cx) / 2; y = ParentRect.top + ((ParentRect.bottom - ParentRect.top) - cy) / 2; SetWindowPos(pData->hDlg, NULL, x, y, cx, cy, SWP_NOZORDER | SWP_NOACTIVATE); }