// // Goto VFD web page // void OnUrlClick(HWND hDlg) { CHAR buf[100]; if (GetLocalMessage(MSG_ABOUT_URL, buf, sizeof(buf))) { ShellExecute(hDlg, NULL, buf, NULL, NULL, SW_SHOWNORMAL); } }
void CTGLWin::GLReaction(){ SpaceRectionMsg SRM; if (GetLocalMessage(SRM)) { if (SRM.Msg == WM_SIZE) { DWORD lParam = (DWORD)SRM.lParam; OnGLSceneSize(LOWORD(lParam),HIWORD(lParam)); } } };
// // initialize the drive letter dialog // BOOL OnLetterInit(HWND hDlg, ULONG nDevice) { HANDLE hDevice; CHAR buf[20]; HWND hCombo; DWORD logical; BOOL persistent; // // setup controls text // SetControlText(hDlg, 0, MSG_LETTER_TITLE); SetControlText(hDlg, IDC_LETTER_LABEL, MSG_LETTER_LABEL); SetControlText(hDlg, IDC_PERSISTENT, MSG_PERSISTENT); SetControlText(hDlg, IDOK, MSG_OK_BUTTON); SetControlText(hDlg, IDCANCEL, MSG_CANCEL_BUTTON); // // setup the drive letter combo box // hCombo = GetDlgItem(hDlg, IDC_DRIVE_LETTER); if (hCombo == NULL) { ShowErrorMessage(GetLastError(), 0); return FALSE; } // initialize the list SendMessage(hCombo, CB_RESETCONTENT, 0, 0); // add <none> if (!GetLocalMessage(MSG_GENERIC_NONE, buf, sizeof(buf))) { strcpy(buf, "(none)"); } SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)buf); // add unused drive letters logical = GetLogicalDrives(); if (logical == 0) { ShowErrorMessage(GetLastError(), 0); return FALSE; } strcpy(buf, "A:"); while (buf[0] <= 'Z') { if (!(logical & 0x01)) { SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)buf); } logical >>= 1; buf[0]++; } SendMessage(hCombo, CB_SETCURSEL, 0, 0); // Get the drive letter of the VFD drive hDevice = VfdOpenDevice(nDevice); if (hDevice == INVALID_HANDLE_VALUE) { ShowErrorMessage(GetLastError(), MSG_ERR_APP_INTERNAL); return FALSE; } persistent = TRUE; VfdGetGlobalLink(hDevice, &buf[0]); if (!isalpha(buf[0])) { if (VfdGetLocalLink(hDevice, &buf[0]) == ERROR_SUCCESS && isalpha(buf[0])) { persistent = FALSE; } } CloseHandle(hDevice); if (isalpha(buf[0])) { SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)buf); SendMessage(hCombo, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)buf); } // set the persistent button state CheckDlgButton(hDlg, IDC_PERSISTENT, persistent ? BST_CHECKED : BST_UNCHECKED); // store the device number SetWindowLong(hDlg, GWL_USERDATA, nDevice); // store the current drive letter SetWindowLong(hDlg, DWL_USER, MAKELONG(buf[0], persistent)); return TRUE; }
// // Refresh the Drive dialog // void OnRefreshDialog(HWND hDlg) { DWORD state; HANDLE hDevice; CHAR buf[MAX_PATH]; VFD_DISKTYPE disk_type; VFD_MEDIA media_type; VFD_FLAGS media_flags; VFD_FILETYPE file_type; ULONG image_size; CHAR letter; DWORD attrib; DWORD ret; // get the driver state ret = VfdGetDriverState(&state); if (ret != ERROR_SUCCESS) { return; } if (state != SERVICE_RUNNING) { // the driver is not running // clear all information and disable controls SetDlgItemText(hDlg, IDC_DRIVE_LETTER, NULL); SetDlgItemText(hDlg, IDC_IMAGEFILE, NULL); SetDlgItemText(hDlg, IDC_MEDIATYPE, NULL); EnableWindow(GetDlgItem(hDlg, IDC_CHANGE), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_OPEN), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SAVE), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); return; } // open the device hDevice = VfdOpenDevice(GetWindowLong(hDlg, GWL_USERDATA)); if (hDevice == INVALID_HANDLE_VALUE) { AppendLogMessage(GetLastError(), 0); return; } // get the current drive letter VfdGetGlobalLink(hDevice, &letter); buf[0] = '\0'; if (isalpha(letter)) { sprintf(buf, "%c (", letter); GetLocalMessage(MSG_PERSISTENT, &buf[3], sizeof(buf) - 3); strcat(buf, ")"); } else { VfdGetLocalLink(hDevice, &letter); if (isalpha(letter)) { sprintf(buf, "%c (", letter); GetLocalMessage(MSG_EPHEMERAL, &buf[3], sizeof(buf) - 3); strcat(buf, ")"); } } SetDlgItemText(hDlg, IDC_DRIVE_LETTER, buf); EnableWindow(GetDlgItem(hDlg, IDC_CHANGE), TRUE); // get the current image information ret = VfdGetImageInfo(hDevice, buf, &disk_type, &media_type, &media_flags, &file_type, &image_size); CloseHandle(hDevice); if (ret != ERROR_SUCCESS) { AppendLogMessage(ret, 0); return; } if (media_type == VFD_MEDIA_NONE) { // no media SetDlgItemText(hDlg, IDC_IMAGEFILE, NULL); SetDlgItemText(hDlg, IDC_DESCRIPTION, NULL); SetDlgItemText(hDlg, IDC_MEDIATYPE, NULL); EnableWindow(GetDlgItem(hDlg, IDC_OPEN), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_SAVE), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), FALSE); SendMessage(GetDlgItem(hDlg, IDC_OPEN), BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE); return; } // set image file name if (buf[0]) { attrib = GetFileAttributes(buf); if (attrib == INVALID_FILE_ATTRIBUTES) { attrib = 0; } } else { if (disk_type != VFD_DISKTYPE_FILE) { strcpy(buf, "<RAM>"); } file_type = VFD_FILETYPE_NONE; attrib = 0; } SetDlgItemText(hDlg, IDC_IMAGEFILE, buf); // set description VfdMakeFileDesc(buf, sizeof(buf), file_type, image_size, attrib); SetDlgItemText(hDlg, IDC_DESCRIPTION, buf); // set disk type text // set media type text SetDlgItemText(hDlg, IDC_MEDIATYPE, VfdMediaTypeName(media_type)); // set write protected state // // enable / disable appropriate buttons // EnableWindow(GetDlgItem(hDlg, IDC_OPEN), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SAVE), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CLOSE), TRUE); SendMessage(GetDlgItem(hDlg, IDC_CLOSE), BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE); }