//**************************************************************************** int CTerminal::copy_selected_rows(void) { // termout(this_port, "C pressed") ; uint elements_found = 0 ; // uint selcount = ListView_GetSelectedCount(this_port->hwndRxData) ; uint selcount = get_selected_count(); int result = 0 ; int nCurItem = -1 ; while (1) { // nCurItem = ListView_GetNextItem(this_port->hwndRxData, nCurItem, LVNI_SELECTED); nCurItem = get_next_listview_index(nCurItem) ; if (nCurItem < 0) break; // syslog("mark %d\n", nCurItem) ; mark_element(nCurItem) ; elements_found++ ; } if (elements_found == selcount) { copy_elements_to_clipboard() ; termout("%u rows copied", selcount) ; // with TabControl, this does not work... // syslog("%u rows copied", selcount) ; result = selcount ; } else { // errout("found %u of %u elements", elements_found, selcount) ; // oops... these depend upon CommPort !! // termout("found %u of %u elements", elements_found, selcount) ; result = -(int)elements_found ; } clear_marked_elements() ; return result; }
//*********************************************************************** static void do_init_dialog(HWND hwnd) { char msgstr[81] ; // hwndTopLevel = hwnd ; // do I need this? wsprintfA(msgstr, "%s", Version) ; SetWindowTextA(hwnd, msgstr) ; SetClassLongA(hwnd, GCL_HICON, (LONG) LoadIcon(g_hinst, (LPCTSTR)WINWIZICO)); SetClassLongA(hwnd, GCL_HICONSM, (LONG) LoadIcon(g_hinst, (LPCTSTR)WINWIZICO)); hwndMain = hwnd ; set_up_working_spaces(hwnd) ; // do this *before* tooltips !! //*************************************************************************** // add tooltips and bitmaps //*************************************************************************** hToolTip = create_tooltips(hwnd, 150, 100, 10000) ; add_main_tooltips(hwnd, hToolTip) ; // RECT rWindow; // unsigned stTop ; RECT myRect ; // GetWindowRect(hwnd, &myRect) ; GetClientRect(hwnd, &myRect) ; cxClient = (myRect.right - myRect.left) ; cyClient = (myRect.bottom - myRect.top) ; center_window() ; //**************************************************************** // create/configure status bar //**************************************************************** MainStatusBar = new CStatusBar(hwnd) ; MainStatusBar->MoveToBottom(cxClient, cyClient) ; // re-position status-bar parts { int sbparts[3]; sbparts[0] = (int) (6 * cxClient / 10) ; sbparts[1] = (int) (8 * cxClient / 10) ; sbparts[2] = -1; MainStatusBar->SetParts(3, &sbparts[0]); } //**************************************************************** // create/configure terminal //**************************************************************** uint ctrl_bottom = get_bottom_line(hwnd, IDC_MAP_AREA) ; uint lvdy = cyClient - ctrl_bottom - MainStatusBar->height() ; myTerminal = new CTerminal(hwnd, IDC_TERMINAL, g_hinst, 0, ctrl_bottom, cxClient-1, lvdy, LVL_STY_VIRTUAL | LVL_STY_NO_HEADER | LVL_STY_PAGE_TO_END ) ; myTerminal->set_terminal_font("Courier New", 100, EZ_ATTR_BOLD) ; myTerminal->lview_assign_column_headers() ; set_local_terminal_colors() ; // should this be wrapped in the terminal module? // Subclass the terminal ListView // wpOrigTermProc = (WNDPROC) SetWindowLongPtr(term->hwndSelf, GWL_WNDPROC, (LONG) TermSubclassProc); wpOrigTermProc = (WNDPROC) myTerminal->terminal_lview_subclass((LONG) TermSubclassProc); // SetClassLong(this_port->cpterm->hwndSelf, GCL_HCURSOR,(long) 0); // disable class cursor // termout("terminal size: columns=%u, screen rows=%u", term->cols, term->rows) ; termout("terminal size: columns=%u, screen rows=%u", myTerminal->get_term_columns(), myTerminal->get_term_rows()) ; //**************************************************************** main_timer_id = SetTimer(hwnd, IDT_TIMER_MAIN, 100, (TIMERPROC) NULL) ; }
//******************************************************************* // this uses default font and color //******************************************************************* void put_message(char *msgstr) { termout(msgstr) ; }
//**************************************************************************** int CTerminal::save_terminal_contents(char *outfile, file_type_e file_type) { FILE *fd = NULL ; int lcount = 0 ; term_lview_item_p lvptr ; char msgstr[260] ; char dbuffer [9]; char tbuffer [9]; _strdate( dbuffer ); _strtime( tbuffer ); switch (file_type) { case FTYP_TEXT: fd = fopen(outfile, "a+t") ; if (fd == NULL) { return -(int)GetLastError(); } fseek(fd, 0, SEEK_END) ; fprintf(fd, "***********************************************************************\n") ; fprintf(fd, "Date/Time of report: %s, %s\n", dbuffer, tbuffer) ; for (lvptr = tlv_top; lvptr != NULL; lvptr = lvptr->next) { lcount++ ; fprintf(fd, "%s\n", lvptr->msg) ; } break; case FTYP_HTML: if (file_exists(outfile)) { // from January 1999 MSDN: // When a file is opened with the "a" or "a+" access type, // all write operations occur at the end of the file. // The file pointer can be repositioned using fseek or rewind, // but is always moved back to the end of the file before any // write operation is carried out. // Thus, existing data cannot be overwritten. // syslog("appending to existing file\n") ; fd = fopen(outfile, "r+t") ; if (fd == NULL) { return -(int)GetLastError(); } fseek(fd, 0, SEEK_END) ; // back up pointer to over-write closing HTML tags fseek(fd, (long) -16, SEEK_CUR) ; } else { // syslog("writing to html file\n") ; fd = fopen(outfile, "wt") ; if (fd == NULL) { return -(int)GetLastError(); } fprintf(fd, "<html><head><title>%s</title>" // STYLE was not needed once I converted to using PRE tag. // "<STYLE type='text/css'>\n" // "* { font-family: Courier, monospace }\n" // "</STYLE>\n" "</head><body>\n", outfile) ; } fprintf(fd, "<pre>\n") ; html_output(fd, WIN_BGREEN, WIN_GREY, "***********************************************************************") ; sprintf(msgstr, "Date/Time of report: %s, %s", dbuffer, tbuffer) ; html_output(fd, WIN_BGREEN, WIN_GREY, msgstr) ; for (lvptr = tlv_top; lvptr != NULL; lvptr = lvptr->next) { lcount++ ; // fprintf(fd, "%s\n", lvptr->msg) ; html_output(fd, lvptr->fgnd, lvptr->bgnd, lvptr->msg) ; } fprintf(fd, "</pre>\n") ; fprintf(fd, "</body></html>\n") ; break; // default: // return -(int)ERROR_INVALID_DATA; // break; } if (fd != NULL) { fflush(fd) ; fclose(fd) ; clear_message_area(); return lcount ; } termout("invalid file_type [%u]", (uint) file_type) ; return -(int) ERROR_INVALID_DATA; }