/* * DoDigit - process a digit typed in */ vi_rc DoDigit( void ) { vi_rc rc; if( LastEvent == '0' && RepeatDigits == 0 ) { LeftTopPos.column = 0; GoToColumnOK( 1 ); DCDisplayAllLines(); return( ERR_NO_ERR ); } if( RepeatDigits == MAX_REPEAT_STRING - 1 ) { DoneRepeat(); return( ERR_REPEAT_STRING_TOO_LONG ); } if( repeatWindow == NO_WINDOW && EditFlags.RepeatInfo ) { rc = NewWindow2( &repeatWindow, &repcntw_info ); if( rc != ERR_NO_ERR ) { DoneRepeat(); return( rc ); } WindowTitle( repeatWindow, "Repeat Count" ); } RepeatString[RepeatDigits++] = LastEvent; RepeatString[RepeatDigits] = 0; if( repeatWindow != NO_WINDOW ) { UpdateRepeatString( RepeatString ); } return( GOT_A_DIGIT ); } /* DoDigit */
vi_rc GetNewValueDialog( char *value ) { bool ret; vi_rc rc; char st[MAX_STR]; window_id clw; static char prompt[] = "New:"; rc = NewWindow2( &clw, &setvalw_info ); if( rc != ERR_NO_ERR ) { return( rc ); } WPrintfLine( clw, 1, "Old: %s", value ); ret = ReadStringInWindow( clw, 2, prompt, st, MAX_STR - 1, NULL ); CloseAWindow( clw ); SetWindowCursor(); KillCursor(); if( !ret ) { return( NO_VALUE_ENTERED ); } if( st[0] == 0 ) { return( NO_VALUE_ENTERED ); } Expand( st, NULL ); strcpy( value, st ); return( ERR_NO_ERR ); } /* GetNewValueDialog */
vi_rc PromptForString( char *prompt, char *buffer, int buffer_length, history_data *h ) { window_id wid; vi_rc rc; if( !EditFlags.NoInputWindow ) { rc = NewWindow2( &wid, &cmdlinew_info ); if( rc != ERR_NO_ERR ) { return( rc ); } } else { wid = NO_WINDOW; } if( !EditFlags.NoInputWindow && strlen( prompt ) >= WindowAuxInfo( wid, WIND_INFO_TEXT_COLS ) ) { rc = ERR_PROMPT_TOO_LONG; } else { rc = NO_VALUE_ENTERED; if( ReadStringInWindow( wid, 1, prompt, buffer, buffer_length, h ) ) { rc = ERR_NO_ERR; } } if( !EditFlags.NoInputWindow ) { CloseAWindow( wid ); SetWindowCursor(); } else { EditFlags.NoInputWindow = false; } return( rc ); } /* PromptForString */
/* * EnterExMode - start Ex emulation mode */ vi_rc EnterExMode( void ) { int i; window_id wid; char *st; char *prompt; vi_rc rc; bool ret; if( EditFlags.InputKeyMapMode ) { return( ERR_NO_ERR ); } i = EditVars.WindMaxHeight - 1; exwInfo.area.y1 = exwInfo.area.y2 = i; exwInfo.area.x2 = EditVars.WindMaxWidth - 1; SetPosToMessageLine(); EditFlags.ExMode = true; EditFlags.LineDisplay = true; EditFlags.ClockActive = false; MyPrintf( "\nEntering EX mode (type vi to return)\n" ); rc = NewWindow2( &wid, &exwInfo ); if( rc != ERR_NO_ERR ) { return( rc ); } st = MemAlloc( EditVars.MaxLine ); for( ;; ) { if( EditFlags.Appending ) { prompt = ""; } else { prompt = ":"; } ret = ReadStringInWindow( wid, 1, prompt, st, EditVars.MaxLine, &EditVars.CLHist ); MyPrintf( "\n" ); if( !ret ) { continue; } ScreenPage( 1 ); if( EditFlags.Appending ) { AppendAnother( st ); ScreenPage( -1 ); continue; } rc = RunCommandLine( st ); if( !EditFlags.ExMode ) { break; } if( rc > ERR_NO_ERR ) { Error( GetErrorMsg( rc ) ); } ScreenPage( -1 ); } MemFree( st ); return( ERR_NO_ERR ); } /* EnterExMode */
/* * NewMessageWindow - create a new Message window */ vi_rc NewMessageWindow( void ) { if( !EditFlags.WindowsStarted ) { return( ERR_NO_ERR ); } if( MessageWindow != NO_WINDOW ) { CloseAWindow( MessageWindow ); MessageWindow = NO_WINDOW; } return( NewWindow2( &MessageWindow, &messagew_info ) ); } /* NewMessageWindow */
/* * NewMessageWindow - create a new Message window */ vi_rc NewMessageWindow( void ) { if( !EditFlags.WindowsStarted ) { return( ERR_NO_ERR ); } if( !BAD_ID( message_window_id ) ) { CloseAWindow( message_window_id ); message_window_id = NO_WINDOW; } return( NewWindow2( &message_window_id, &messagew_info ) ); } /* NewMessageWindow */
/* * LineNumbersSetup - set up line number window */ vi_rc LineNumbersSetup( void ) { int j; int x1, x2; window_info wi; vi_rc rc; if( EditFlags.LineNumbers ) { if( editw_info.x2 - editw_info.x1 < EditVars.LineNumWinWidth ) { return( ERR_CANNOT_OPEN_LINENUM_WIND ); } if( !linenumw_info.has_border ) { j = 1; } else { j = 0; } memcpy( &wi, &linenumw_info, sizeof( window_info ) ); x1 = WindowAuxInfo( CurrentWindow, WIND_INFO_X1 ); x2 = WindowAuxInfo( CurrentWindow, WIND_INFO_X2 ); wi.y1 = WindowAuxInfo( CurrentWindow, WIND_INFO_Y1 ); wi.y2 = WindowAuxInfo( CurrentWindow, WIND_INFO_Y2 ); if( !EditFlags.LineNumsOnRight ) { rc = ResizeWindowRelative( CurrentWindow, EditVars.LineNumWinWidth, 0, 0, 0, FALSE ); if( rc != ERR_NO_ERR ) { return( rc ); } wi.x1 = x1; wi.x2 = x1 + EditVars.LineNumWinWidth - 1 - j; } else { rc = ResizeWindowRelative( CurrentWindow, 0, 0, -EditVars.LineNumWinWidth, 0, FALSE ); if( rc != ERR_NO_ERR ) { return( rc ); } wi.x1 = x2 - EditVars.LineNumWinWidth + 1; wi.x2 = x2 - j; } rc = NewWindow2( &CurrNumWindow, &wi ); if( rc != ERR_NO_ERR ) { return( rc ); } } else { CloseAWindow( CurrNumWindow ); rc = ResizeWindow( CurrentWindow, editw_info.x1, editw_info.y1, editw_info.x2, editw_info.y2, FALSE ); if( rc != ERR_NO_ERR ) { return( rc ); } } SetWindowCursor(); DCDisplayAllLines(); return( ERR_NO_ERR ); } /* LineNumbersSetup */
/* * NewStatusWindow - create a new status window */ vi_rc NewStatusWindow( void ) { vi_rc rc = ERR_NO_ERR; if( !EditFlags.WindowsStarted ) { return( ERR_NO_ERR ); } if( !BAD_ID( status_window_id ) ) { CloseAWindow( status_window_id ); status_window_id = NO_WINDOW; } if( EditFlags.StatusInfo ) { rc = NewWindow2( &status_window_id, &statusw_info ); UpdateStatusWindow(); } return( rc ); } /* NewStatusWindow */
/* * NewStatusWindow - create a new status window */ vi_rc NewStatusWindow( void ) { vi_rc rc = ERR_NO_ERR; if( !EditFlags.WindowsStarted ) { return( ERR_NO_ERR ); } if( StatusWindow != NO_WINDOW ) { CloseAWindow( StatusWindow ); StatusWindow = NO_WINDOW; } if( EditFlags.StatusInfo ) { rc = NewWindow2( &StatusWindow, &statusw_info ); UpdateStatusWindow(); } return( rc ); } /* NewStatusWindow */
STDMETHODIMP DuiLib::CWebBrowserUI::Invoke( DISPID dispIdMember, REFIID riid, LCID lcid,WORD wFlags, DISPPARAMS* pDispParams,VARIANT* pVarResult, EXCEPINFO* pExcepInfo,UINT* puArgErr ) { if ((riid != IID_NULL)) return E_INVALIDARG; switch(dispIdMember) { case DISPID_BEFORENAVIGATE2: BeforeNavigate2( pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); break; case DISPID_COMMANDSTATECHANGE: CommandStateChange( pDispParams->rgvarg[1].lVal, pDispParams->rgvarg[0].boolVal); break; case DISPID_NAVIGATECOMPLETE2: NavigateComplete2( pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); break; case DISPID_NAVIGATEERROR: NavigateError( pDispParams->rgvarg[4].pdispVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); break; case DISPID_STATUSTEXTCHANGE: break; // case DISPID_NEWWINDOW2: // break; case DISPID_NEWWINDOW3: NewWindow3( pDispParams->rgvarg[4].ppdispVal, pDispParams->rgvarg[3].pboolVal, pDispParams->rgvarg[2].uintVal, pDispParams->rgvarg[1].bstrVal, pDispParams->rgvarg[0].bstrVal); break; case DISPID_DOCUMENTCOMPLETE: DocmentComplete( pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); break; case DISPID_NEWWINDOW2: NewWindow2(pDispParams->rgvarg[0].pboolVal, pDispParams->rgvarg[5].bstrVal); break; // case DISPID_PROPERTYCHANGE: // if (pDispParams->cArgs>0 && pDispParams->rgvarg[0].vt == VT_BSTR) { // TRACE(_T("PropertyChange(%s)\n"), pDispParams->rgvarg[0].bstrVal); // } // break; default: return DISP_E_MEMBERNOTFOUND; } return S_OK; }
/* * SelectLineInFile - select a line in a given file */ vi_rc SelectLineInFile( selflinedata *sfd ) { int i, winflag; int leftcol = 0, key2; bool done = FALSE, redraw = TRUE; bool hiflag = FALSE, drawbord = FALSE; int farx, text_lines; linenum pagetop = 1, lln = 1; char tmp[MAX_STR]; hilst *ptr; linenum cln; linenum endline; vi_rc rc; vi_key key; /* * create the window */ cln = sfd->cln; endline = sfd->f->fcbs.tail->end_line; farx = sfd->wi->x2; if( sfd->show_lineno ) { farx++; } if( sfd->hilite != NULL ) { hiflag = TRUE; } rc = NewWindow2( &cWin, sfd->wi ); if( rc != ERR_NO_ERR ) { return( rc ); } if( !sfd->is_menu ) { WindowAuxUpdate( cWin, WIND_INFO_HAS_SCROLL_GADGETS, TRUE ); DrawBorder( cWin ); } oWin = sfd->eiw; isMenu = sfd->is_menu; PushMouseEventHandler( SelectLineMouseHandler ); KillCursor(); text_lines = WindowAuxInfo( cWin, WIND_INFO_TEXT_LINES ); sfd->sl = -1; if( sfd->title != NULL ) { WindowTitle( cWin, sfd->title ); } pagetop = text_lines * (cln / text_lines); if( cln % text_lines != 0 ) { pagetop++; } key = 0; if( LastEvent == VI_KEY( MOUSEEVENT ) ) { DisplayMouse( TRUE ); } /* * now, allow free scrolling and selection */ while( !done ) { if( redraw ) { if( sfd->show_lineno ) { MySprintf(tmp, "%l/%l", cln, endline ); i = sfd->wi->x2 - sfd->wi->x1; WindowBorderData( cWin, tmp, i - strlen( tmp ) ); drawbord = TRUE; } if( hiflag ) { ptr = sfd->hilite; ptr += cln - 1; if( ptr->_char == (char)-1 ) { if( cln > lln ) { cln++; } else if( cln < lln ) { cln--; } } } if( drawbord ) { DrawBorder( cWin ); } displayGenericLines( sfd->f, pagetop, leftcol, cln, &(sfd->wi->hilight), sfd->hilite, sfd->vals, sfd->valoff ); } lln = cln; redraw = TRUE; drawbord = FALSE; mouseLine = -1; rlMenu = FALSE; if( key == VI_KEY( MOUSEEVENT ) ) { DisplayMouse( TRUE ); } key = GetNextEvent( TRUE ); if( hiflag && ((key >= VI_KEY( ALT_A ) && key <= VI_KEY( ALT_Z )) || (key >='a' && key <= 'z') || (key >= 'A' && key <= 'Z') || (key >= '1' && key <= '9')) ) { i = 0; if( key >= VI_KEY( ALT_A ) && key <= VI_KEY( ALT_Z ) ) { key2 = key - VI_KEY( ALT_A ) + 'A'; } else if( key >= 'a' && key <= 'z' ) { key2 = key - 'a' + 'A'; } else { key2 = key; } ptr = sfd->hilite; while( ptr->_char != '\0' ) { if( toupper( ptr->_char ) == key2 ) { cln = i + 1; key = VI_KEY( ENTER ); break; } ++i; ++ptr; } } /* * check if a return-event has been selected */ if( sfd->retevents != NULL ) { i = 0; if( key == VI_KEY( MOUSEEVENT ) ) { if( mouseWin == oWin && LastMouseEvent == MOUSE_PRESS ) { DisplayMouse( FALSE ); sfd->event = sfd->retevents[mouseLine]; key = VI_KEY( ENTER ); } } else { while( sfd->retevents[i] != 0 ) { if( key == sfd->retevents[i] ) { sfd->event = key; key = VI_KEY( ENTER ); break; } i++; } } } /* * process key stroke */ switch( key ) { case VI_KEY( MOUSEEVENT ): DisplayMouse( FALSE ); if( hiflag ) { ptr = sfd->hilite; ptr += mouseLine; if( ptr->_char == (char) -1 ) { break; } } if( rlMenu && sfd->allow_rl != NULL ) { *(sfd->allow_rl) = rlMenuNum; done = TRUE; break; } if( mouseScroll != MS_NONE ) { switch( mouseScroll ) { case MS_UP: goto evil_up; case MS_DOWN: goto evil_down; case MS_PAGEUP: goto evil_pageup; case MS_PAGEDOWN: goto evil_pagedown; case MS_EXPOSEDOWN: adjustCLN( &cln, &pagetop, pagetop + text_lines - cln - 1, endline, text_lines ); adjustCLN( &cln, &pagetop, 1, endline, text_lines ); drawbord = TRUE; break; case MS_EXPOSEUP: adjustCLN( &cln, &pagetop, pagetop - cln, endline, text_lines ); adjustCLN( &cln, &pagetop, -1, endline, text_lines ); drawbord = TRUE; break; } break; } switch( LastMouseEvent ) { case MOUSE_DRAG: if( mouseWin != cWin ) { break; } cln = mouseLine + pagetop; break; case MOUSE_RELEASE: if( !sfd->is_menu ) { break; } if( mouseWin == cWin ) { cln = mouseLine + pagetop; if( cln <= endline ) { goto evil_enter; } } break; case MOUSE_DCLICK: if( mouseWin != cWin ) { AddCurrentMouseEvent(); done = TRUE; } else { cln = mouseLine + pagetop; if( cln <= endline ) { goto evil_enter; } } break; case MOUSE_PRESS_R: if( mouseWin != cWin ) { AddCurrentMouseEvent(); done = TRUE; } break; case MOUSE_PRESS: if( mouseWin != cWin ) { AddCurrentMouseEvent(); done = TRUE; } else { cln = mouseLine + pagetop; } break; } break; case VI_KEY( ESC ): done = TRUE; break; evil_enter: case VI_KEY( ENTER ): case ' ': /* * see if we need to do a callback for this */ if( sfd->checkres != NULL ) { line *cline; fcb *cfcb; char data[64]; i = cln - 1; GimmeLinePtr( cln, sfd->f, &cfcb, &cline ); strcpy( data, cline->data ); RemoveLeadingSpaces( data ); winflag = FALSE; strcpy( tmp, sfd->vals[i] ); rc = sfd->checkres( data, tmp, &winflag ); if( winflag ) { if( winflag == 2 ) { winflag = TRUE; } else { winflag = FALSE; } } if( winflag ) { MoveWindowToFront( cWin ); } if( rc == ERR_NO_ERR ) { AddString2( &(sfd->vals[i]), tmp ); redraw = TRUE; } break; /* * no value window, so just return line selected */ } else { if( isMenu && InvokeMenuHook( CurrentMenuNumber, cln ) == -1 ) { break; } sfd->sl = cln; done = TRUE; } break; case VI_KEY( LEFT ): case 'h': if( sfd->allow_rl != NULL ) { *(sfd->allow_rl) = -1; done = TRUE; } break; case VI_KEY( RIGHT ): case 'l': if( sfd->allow_rl != NULL ) { *(sfd->allow_rl) = 1; done = TRUE; } break; evil_up: case VI_KEY( UP ): case 'k': drawbord = adjustCLN( &cln, &pagetop, -1, endline, text_lines ); break; evil_down: case VI_KEY( DOWN ): case 'j': drawbord = adjustCLN( &cln, &pagetop, 1, endline, text_lines ); break; case VI_KEY( CTRL_PAGEUP ): drawbord = adjustCLN( &cln, &pagetop, -cln + 1, endline, text_lines ); break; case VI_KEY( CTRL_PAGEDOWN ): drawbord = adjustCLN( &cln, &pagetop, endline - cln, endline, text_lines ); break; evil_pageup: case VI_KEY( PAGEUP ): case VI_KEY( CTRL_B ): drawbord = adjustCLN( &cln, &pagetop, -text_lines, endline, text_lines ); break; evil_pagedown: case VI_KEY( PAGEDOWN ): case VI_KEY( CTRL_F ): drawbord = adjustCLN( &cln, &pagetop, text_lines, endline, text_lines ); break; case VI_KEY( HOME ): drawbord = TRUE; cln = 1; pagetop = 1; break; case VI_KEY( END ): drawbord = TRUE; cln = endline; pagetop = endline - text_lines + 1; if( pagetop < 1 ) { pagetop = 1; } break; default: redraw = FALSE; break; } } PopMouseEventHandler(); CloseAWindow( cWin ); RestoreCursor(); SetWindowCursor(); return( rc ); } /* SelectLineInFile */
cursorNeedsDisplay = false; } /* SetWindowCursorForReal */ /* * DisplayExtraInfo - display info in extra window */ vi_rc DisplayExtraInfo( window_info *wi, window_id *wn, char _NEAR * _NEAR *data, int numopts ) { int j; vi_rc rc; wi->y2 = wi->y1 + numopts + 1; rc = NewWindow2( wn, wi ); if( rc != ERR_NO_ERR ) { return( rc ); } WindowTitle( *wn, "Special Keys" ); for( j = 0; j < numopts; j++ ) { DisplayLineInWindow( *wn, j + 1, data[j] ); } return( ERR_NO_ERR ); } /* DisplayExtraInfo */ /* * ColumnInWindow - check if a column is in the current window */ bool ColumnInWindow( int col, int *diff )
cursorNeedsDisplay = false; } /* SetWindowCursorForReal */ /* * DisplayExtraInfo - display info in extra window */ vi_rc DisplayExtraInfo( window_info *wi, window_id *wid, char _NEAR * _NEAR *data, int numopts ) { int j; vi_rc rc; wi->area.y2 = wi->area.y1 + numopts + 1; rc = NewWindow2( wid, wi ); if( rc != ERR_NO_ERR ) { return( rc ); } WindowTitle( *wid, "Special Keys" ); for( j = 0; j < numopts; j++ ) { DisplayLineInWindow( *wid, j + 1, data[j] ); } return( ERR_NO_ERR ); } /* DisplayExtraInfo */ /* * ColumnInWindow - check if a column is in the current window */ bool ColumnInWindow( int col, int *diff )
/* * createNewFile - create new file entry */ static vi_rc createNewFile( char *name, bool same_file ) { int height; window_id cw; info *tmp; vi_rc rc; /* * test that we can create this file */ tmp = NULL; if( !same_file ) { rc = FileExists( name ); if( !(rc == ERR_READ_ONLY_FILE || rc == ERR_NO_ERR || rc == ERR_FILE_EXISTS) ) { return( rc ); } } else { if( name != NULL ) { for( tmp = InfoHead; tmp != NULL; tmp = tmp->next ) { if( !strcmp( tmp->CurrentFile->name, name ) ) { break; } } } if( tmp == NULL ) { return( ERR_FILE_NOT_FOUND ); } if( tmp->CurrentFile->dup_count > MAX_DUPLICATE_FILES ) { return( ERR_WIND_NO_MORE_WINDOWS ); } } /* * get new window */ rc = NewWindow2( &cw, &editw_info ); if( rc != ERR_NO_ERR ) { return( rc ); } #ifdef __WIN__ if( !strncmp( name, "untitled", 8 ) ) { // better yet, pass normal/maximize flag to NewWindow2... ShowWindow( cw, SW_SHOWMAXIMIZED ); } #endif SetBorderGadgets( cw, EditFlags.WindowGadgets ); /* * get new file entry, and read the data */ if( same_file ) { CurrentFile = tmp->CurrentFile; CurrentFile->dup_count++; SetFileWindowTitle( CurrentWindow, CurrentInfo, true ); tmp = CurrentInfo; CurrentInfo = MemAlloc( sizeof( *CurrentInfo ) ); FTSRunCmds( name ); rc = ERR_NO_ERR; } else { bool crlf_reached; crlf_reached = false; tmp = CurrentInfo; CurrentInfo = MemAlloc( sizeof( *CurrentInfo ) ); FTSRunCmds( name ); height = editw_info.y2 - editw_info.y1 + 1; CurrentFile = FileAlloc( name ); rc = OpenFcbData( CurrentFile ); for( ; rc == ERR_NO_ERR; ) { rc = ReadFcbData( CurrentFile, &crlf_reached ); if( rc == ERR_NO_ERR && !CurrentFile->is_stdio ) { if( EditFlags.BreakPressed || !EditFlags.ReadEntireFile ) { if( CurrentFile->fcbs.tail->end_line > height ) { break; } } } } if( rc != ERR_NO_ERR && rc != ERR_FILE_NOT_FOUND && rc != END_OF_FILE ) { MemFree( CurrentInfo ); CurrentInfo = tmp; FileFree( CurrentFile ); CloseAWindow( cw ); return( rc ); } if( rc == ERR_FILE_NOT_FOUND ) { rc = NEW_FILE; EditFlags.NewFile = true; CurrentFile->write_crlf = FileSysNeedsCR( CurrentFile->handle ); #ifdef __UNIX__ CurrentFile->attr = PMODE_RW; #endif } else { rc = ERR_NO_ERR; CurrentFile->write_crlf = crlf_reached; EditFlags.NewFile = false; #ifdef __UNIX__ { struct stat sb; stat( name, &sb ); CurrentFile->attr = sb.st_mode & ~S_IFMT; } #endif } CurrentFile->check_readonly = true; } /* * create info entry */ CurrentPos.line = 0; CurrentPos.column = 1; VirtualColumnDesired = 1; LeftTopPos.line = 1; LeftTopPos.column = 0; if( !same_file ) { AllocateUndoStacks(); } AllocateMarkList(); CurrentWindow = cw; CurrentInfo->DuplicateID = CurrentFile->dup_count; CurrentInfo->CurrentWindow = cw; LangInit( CurrentInfo->fsi.Language ); #ifdef __WIN__ { window_data *wd; wd = DATA_FROM_ID( cw ); wd->info = CurrentInfo; } #endif DCCreate(); SetFileWindowTitle( CurrentWindow, CurrentInfo, true ); /* * set current file info */ CurrentFcb = CurrentFile->fcbs.head; CurrentLine = CurrentFcb->lines.head; if( EditFlags.LineNumbers ) { LineNumbersSetup(); } if( tmp != NULL ) { InsertLLItemAfter( (ss **)&InfoTail, (ss *)tmp, (ss *)CurrentInfo ); } else { AddLLItemAtEnd( (ss **)&InfoHead, (ss **)&InfoTail, (ss *)CurrentInfo ); } return( rc ); } /* createNewFile */
STDMETHODIMP DWebBrowserEventsImpl::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { switch (dispIdMember) { ///////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: IDispatch* - Pointer to an IDispatch interface. // You can set this parameter to the IDispatch of // a WebBrowser Control that you've created. When // you pass back an IDispatch like this, MSHTML will // use the control you've given it to open the link. // case DISPID_NEWWINDOW2: { NewWindow2(pDispParams->rgvarg[1].ppdispVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: HTTP headers - VT_BYREF|VT_VARIANT // [2]: Address of HTTP POST data - VT_BYREF|VT_VARIANT // [3]: Target frame name - VT_BYREF|VT_VARIANT // [4]: Option flags - VT_BYREF|VT_VARIANT // [5]: URL to navigate to - VT_BYREF|VT_VARIANT // [6]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // User clicked a link or launched the browser. // case DISPID_BEFORENAVIGATE2: { BeforeNavigate2(pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // Fires after a navigation to a link is completed on either // a window or frameSet element. // case DISPID_NAVIGATECOMPLETE2: { NavigateComplete2(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); // Check if m_lpDocCompleteDisp is NULL. If NULL, that means it is // the top level NavigateComplete2. Save the LPDISPATCH if (!m_lpDocCompleteDisp) { VARIANTARG varDisp = pDispParams->rgvarg[1]; m_lpDocCompleteDisp = varDisp.pdispVal; } } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: New status bar text - VT_BSTR // case DISPID_STATUSTEXTCHANGE: { StatusTextChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Maximum progress - VT_I4 // [1]: Amount of total progress - VT_I4 // case DISPID_PROGRESSCHANGE: { ProgressChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].intVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // Fires when a document has been completely loaded and initialized. // Unreliable -- currently, the DWebBrowserEvents2::DocumentComplete // does not fire when the IWebBrowser2::Visible property of the // WebBrowser Control is set to false (see Q259935). Also, multiple // DISPID_DOCUMENTCOMPLETE events can be fired before the final // READYSTATE_COMPLETE (see Q180366). // case DISPID_DOCUMENTCOMPLETE: { DocumentComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); VARIANTARG varDisp = pDispParams->rgvarg[1]; if (m_lpDocCompleteDisp && m_lpDocCompleteDisp == varDisp.pdispVal) { // if the LPDISPATCH are same, that means // it is the final DocumentComplete. Reset m_lpDocCompleteDisp m_lpDocCompleteDisp = NULL; // Handle new doc. DocumentReallyComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); } } break; /////////////////////////////////////////////////////////// // No parameters // // Fires when a navigation operation is beginning. // case DISPID_DOWNLOADBEGIN: DownloadBegin(); break; /////////////////////////////////////////////////////////// // No parameters // // Fires when a navigation operation finishes, is halted, or fails. // case DISPID_DOWNLOADCOMPLETE: DownloadComplete(); break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Enabled state - VT_BOOL // [1]: Command identifier - VT_I4 // case DISPID_COMMANDSTATECHANGE: { CommandStateChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].boolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Document title - VT_BSTR // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // case DISPID_TITLECHANGE: { TitleChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Name of property that changed - VT_BSTR // case DISPID_PROPERTYCHANGE: { PropertyChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: Child Window (created from script) - VT_BOOL // // case DISPID_WINDOWCLOSING: { WindowClosing(pDispParams->rgvarg[1].boolVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Cancel flag - VT_BYREF|VT_BOOL // // case DISPID_FILEDOWNLOAD: { FileDownload(pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: Error status code - VT_BYREF|VT_VARIANT // [2]: Target frame name - VT_BYREF|VT_VARIANT // [3]: URL where navigate failed - VT_BYREF|VT_VARIANT // [4]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // case DISPID_NAVIGATEERROR: { NavigateError(pDispParams->rgvarg[4].pdispVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); m_lpDocCompleteDisp = NULL; } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Visible - VT_BOOL // case DISPID_ONVISIBLE: { OnVisible(pDispParams->rgvarg[0].boolVal); } break; /////////////////////////////////////////////////////////// // No parameters // // The BHO docs in MSDN say to use DISPID_QUIT, but this is an error. // The BHO never gets a DISPID_QUIT and thus the browser connection // never gets unadvised and so the BHO never gets the FinalRelease(). // This is bad. So use DISPID_ONQUIT instead and everything is cool -- // EXCEPT when you exit the browser when viewing a page that launches // a popup in the onunload event! In that case the BHO is already // unadvised so it does not intercept the popup. So the trick is to // navigate to a known page (I used the about:blank page) that does // not have a popup in the onunload event before unadvising. // case DISPID_ONQUIT: OnQuit(); break; default: { } break; } return NOERROR; }
GrafPortPtr NDAOpen(void) { Pointer pathToSelf; unsigned int oldResourceApp; LevelRecGS levelDCB; unsigned int oldLevel; SysPrefsRecGS prefsDCB; unsigned int oldPrefs; int numOps; int i; Handle opListCtl; if (gCalcActive) return NULL; oldResourceApp = GetCurResourceApp(); ResourceStartUp(gUserId); pathToSelf = LGetPathname2(gUserId, 1); levelDCB.pCount = 2; GetLevelGS(&levelDCB); oldLevel = levelDCB.level; levelDCB.level = 0; SetLevelGS(&levelDCB); prefsDCB.pCount = 1; GetSysPrefsGS(&prefsDCB); oldPrefs = prefsDCB.preferences; prefsDCB.preferences = (prefsDCB.preferences & 0x1fff) | 0x8000; SetSysPrefsGS(&prefsDCB); gResourceId = OpenResourceFile(readEnable, NULL, pathToSelf); gCalcWinPtr = NewWindow2("\p abCalc ", 0, DrawContents, NULL, refIsResource, abCalcWinNum, rWindParam1); SetSysWindow(gCalcWinPtr); ShowWindow(gCalcWinPtr); SelectWindow(gCalcWinPtr); SetPort(gCalcWinPtr); if (gOpList == NULL) { numOps = abCalcOpNumOps(); gOpList = malloc(sizeof(*gOpList) * numOps); for (i = 0; i < numOps; i++) { gOpList[i].memPtr = abCalcOpNth(i)->name; gOpList[i].memFlag = 0; } } opListCtl = (Handle)GetCtlHandleFromID(gCalcWinPtr, abCalcOpList); NewList2(NULL, 1, (Ref)gOpList, 0, numOps, opListCtl); UpdateStack(); gCalcActive = TRUE; prefsDCB.preferences = oldPrefs; SetSysPrefsGS(&prefsDCB); levelDCB.level = oldLevel; SetLevelGS(&levelDCB); SetCurResourceApp(oldResourceApp); return gCalcWinPtr; }