Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. axWebBrowser focus issue

axWebBrowser focus issue

Scheduled Pinned Locked Moved C#
helpquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arbrsoft
    wrote on last edited by
    #1

    AxSHDocVw.AxWebBrowser axWebBrowser1; I am making a web editor(wysiwyg editor). My program has a toolStrip and axWebBrowser control When I want to change the font of the webbrowser, select my comboBox on toolStrip, it make the font change but the FOCUS Remain in Font ComboBox. I want give the focus to axWebBrowser programmically. here is the code that executed when the ComboBox SelectedIndex changed

    case 32:
    doc1.execCommand("FontSize", false, (object) ((ToolStripComboBox)sender).SelectedItem.ToString().Split('(',')')[1]); //change font it works fine.

    //but next to give focus to axWebBrowser is not working.
    Win32.SetForegroundWindow(axWebBrowser1.Handle); //don't work
    Win32.SetFocus(new System.Runtime.InteropServices.HandleRef(null, axWebBrowser1.Handle)); //don't work

    //mshtml.IHTMLTxtRange txt = (mshtml.IHTMLTxtRange)doc1.selection.createRange();
    //txt.select(); //tried but...

    //axWebBrowser1.Update();
    //axWebBrowser1.Select(); //tried but...

    //tabPage1.SelectNextControl(axWebBrowser1, true, true, true, true); //tried but...
    //axWebBrowser1.Select(); //it is not working...

    please take care of my question. thanks a lot.

    J 1 Reply Last reply
    0
    • A arbrsoft

      AxSHDocVw.AxWebBrowser axWebBrowser1; I am making a web editor(wysiwyg editor). My program has a toolStrip and axWebBrowser control When I want to change the font of the webbrowser, select my comboBox on toolStrip, it make the font change but the FOCUS Remain in Font ComboBox. I want give the focus to axWebBrowser programmically. here is the code that executed when the ComboBox SelectedIndex changed

      case 32:
      doc1.execCommand("FontSize", false, (object) ((ToolStripComboBox)sender).SelectedItem.ToString().Split('(',')')[1]); //change font it works fine.

      //but next to give focus to axWebBrowser is not working.
      Win32.SetForegroundWindow(axWebBrowser1.Handle); //don't work
      Win32.SetFocus(new System.Runtime.InteropServices.HandleRef(null, axWebBrowser1.Handle)); //don't work

      //mshtml.IHTMLTxtRange txt = (mshtml.IHTMLTxtRange)doc1.selection.createRange();
      //txt.select(); //tried but...

      //axWebBrowser1.Update();
      //axWebBrowser1.Select(); //tried but...

      //tabPage1.SelectNextControl(axWebBrowser1, true, true, true, true); //tried but...
      //axWebBrowser1.Select(); //it is not working...

      please take care of my question. thanks a lot.

      J Offline
      J Offline
      jas0n23
      wrote on last edited by
      #2

      Hello, Have you tried:

      axWebBrowser1.Focus();

      It worked for me. :-) Hope it helps. Jason.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups