/** set current row **/ void set_current_row( dom::element& table, dom::element& row, UINT keyboardStates, bool dblClick = false ) { if(is_multiple(table)) { if (keyboardStates & SHIFT_KEY_PRESSED) { checkall(table, false); check_range(table,row.index(),TRUE); // from current to new } else { if (keyboardStates & CONTROL_KEY_PRESSED) set_checked_row (table,row, true); // toggle else checkall(table, false); set_anchor(table,row.index ()); } } // get previously selected row: dom::element prev = get_current_row( table ); if( prev.is_valid() ) { if( prev != row ) prev.set_state(0,STATE_CURRENT, false); // drop state flags } row.set_state(STATE_CURRENT); // set state flags row.scroll_to_view(); ::UpdateWindow(row.get_element_hwnd(false)); table.post_event( dblClick? TABLE_ROW_DBL_CLICK:TABLE_ROW_CLICK, row.index(), row); }
void notify(dom::element& el, NMHL_HYPERLINK::type code) { // send notification NMHL_HYPERLINK nm; memset(&nm,0,sizeof(nm)); HWND hwnd = el.get_element_hwnd(true); nm.hdr.code = HLN_HYPERLINK; nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetDlgCtrlID(hwnd); nm.action = code; nm.he = el; dom::element root = el.root(); const wchar_t *pHREF = el.get_attribute("href"); if(pHREF) { if(code == NMHL_HYPERLINK::CLICK && pHREF[0] == '#') // anchor name, this is a local hyperlink { if( pHREF+1 == 0 ) // href='#' case return; dom::element anchor_el = root.find_first("[id='%S'],[name='%S']",pHREF+1,pHREF+1); //find_element_by_name(el.root_element(hwnd), pHREF + 1); if(anchor_el.is_valid()) // found { anchor_el.scroll_to_view(true /* scroll it to top of the view */); return; // shall host be notified about this? } } wcsncpy(nm.szHREF,pHREF,MAX_URL_LENGTH); el.combine_url(nm.szHREF,MAX_URL_LENGTH); } const wchar_t *pszTarget = el.get_attribute("target"); if(pszTarget) { if(code == NMHL_HYPERLINK::CLICK && try_to_load( root, nm.szHREF, pszTarget )) return; wcsncpy(nm.szTarget,pszTarget,MAX_URL_LENGTH); } ::SendMessage(hwnd,WM_BEHAVIOR_NOTIFY,HLN_HYPERLINK,LPARAM(&nm)); }