How to add right click menu to IE? - c#

I have done some research and the way to do it use to add it to the registry, but I want to it only appear when the user opens my program which uses the webrowser control. What is the best way to go about doing this?

When you press right mouse click than oncontextmenu event is created by browser,
if browser not found any user attached event with this event than it'll disaply its own menu.
but you want to disply your own menu
than use following code
YOUR_ELEMENT.AttachEvent('oncontextmenu', INVOKE_METHOD_WHEN_EVENT_OCCURED);
function INVOKE_METHOD_WHEN_EVENT_OCCURED(e)
{
...
var menu = document.getElementById('popupmenu');
menu.style.display='block'; //Showing the menu
menu.style.left = latlong.x + x; //Positioning the menu
menu.style.top = latlong.y + y;
...
do you othre stuff
...
}
and also use of HTML5 you can do same thing easily.

Related

How can I wait for the result of menu opened manually?

Normally a menu is opened by click right mouse button(this part is handled easily),yet sometimes I need to open the menu automatically and wait for the user to choose an item. My approach like this:
//let menu be a ContextMenuStrip
//newlyCreatedObject be a object set by menu's click event handler
public Object createNewObject()
{
menu.show(); //this line should block until menu close,but it didn't
return newlyCreatedObject; //ERROR:immediately return before event handler run
}
Ideally the menu.show() part should act like a MFC Dialog's DoModal() that handle all the menu's interaction and return when menu is closed. After that i can get the newlyCreatedObject and do whatever i want with it.
So my question is how can i wait the menu to finish,before return newlyCreatedObject?
PS:I am trying to write a UE4 blueprint like application. In UE4 Blueprint you could either click right mouse button to show up a menu and choose what to add or drag a link out of a pin and release button to show up a menu and link the newly added function automatically(this part is what I want to achieve). I guess it would be possible to break up the create part and link part, but this must lead to a lot of state condition.

Create a Checkbox for a Winform

I searched myself through for about 1 hour only to realise that I might be the biggest beginner, but since everybody must have been at that point in a time, i hope for your patience.
My question: i have an empty Winform which is opened after a button is pressed on a custom created outlook properties button.
the button code:
private void FensterOeffnen(object sender, IRibbonControl control, bool pressed)
{
EinstellungenFenster fenster = new EinstellungenFenster();
fenster.ShowDialog();
}
the Winform code:
public partial class EinstellungenFenster : Form
{
public EinstellungenFenster()
{
InitializeComponent();
Text = "Outlook Add-in Einstellungen";
}
}
the Reason i need a checkbox:
i want to implement a popup (Debug so to say) window on each and every method that i have on my Outlook Add-in if the button is checked, so that if the code stopps working at a certain point after deployment, i can still easily tell where the problem is.
Thanks a lot!
Open the toolbox on vs by going to view and toolbox then expand all windows forms and scroll down to check-box and drag it on to the form.
and then implement the checked procedure by adding on the button clicked
if (Checkboxname.Checked = true)
{
// Do Stuff when checked
}
hope this helps

Create GUI windows like wizard windows for windows form in c#

I like to create GUI like wizard for my program. I don't know how to explain. But the user just click "next" for next process and end with "Done" button at the last process. How do i can create this on in Windows Form C#?
eg:
You just stack a bunch of panels on top of each other and place the content of each step in separate panels. Then, as the users clicks Next or Prev, you show/hide the different steps by setting the .Visible property of the panels accordingly.
For each of your wizard page, you can create a user control, for instance page1, page2, etc.
you can then add them into a collection:
List<Page> allPages= new List<Page>();
foreach( var page in allPages)
page.hide();
And when you click "Next", you increment the counter:
void onNextClicked(...)
{
current++;
allPages[current].Show();
}
That is it. Of course, the above is the pseudo code. Cheers!

Delete Tree child node in Window application

I am working on a Windows application where I am showing logs using a treeview as shown below, here nodes are created dynamically on the basis of daily logs
Logs -
+ 12-02-2001
+ 12-02-2001
+ 12-02-2001
+ 12-02-2001
but I want to add delete button with each node as shown below
Logs -
+ 12-02-2001 Delete
+ 12-02-2001 Delete
+ 12-02-2001 Delete
+ 12-02-2001 Delete
Thanks.
You can make it easier using ContextMenuStrip.
http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip.aspx
//event handler for menuItem Click
private void mnuDelNode_Click(object sender,EventArgs e)
{
//better confirm before delete using a message box
DeleteRecursive(listView.SelectedNode);
}
private void DeleteRecursive(TreeNode root)
{
//your delete logic here
}
If you are using WindowsForms, you would need to implement custom drawing of the TreeView and do hit testing on the Click event to see if the button was clicked. The TreeView was not really designed to add in buttons, so you may wish to consider an alternative design, say adding in a right menu, a toolbar, and/or right click menu with the Delete command on it, as that would be significantly less work and more in line with how the standard Windows controls work (you don't see a bunch of buttons behind folder names in Windows Explorer's TreeView for instance).

Watin script for handling Ajax popup

I'm using WatiN testing tool and i'm writing c#.net scripts. I've a scenario where i need to change the theme of my web page, so to do this i need to click on a image button which opens a ajax popup with the image and "Apply Theme" button which is below the image now i need to click on the button so how to do this please suggest some solution.
So first click your button that throws up the popup, and .WaitUntilExists() for the button inside the popup.
IE.Button("ShowPopup").click()
IE.Button("PopupButtonID").WaitUntilExists()
IE.Button("PopupButtonID").click()
This may not work in the case the button on the popup exists but is hidden from view. In that case you could try the .WaitUntil() and specify an attribute to look for.
IE.Button("ButtonID").WaitUntil("display","")
The Ajax pop-up itself shouldn't pose a problem if you handle the timing of the control loading asynchronously. If you are using the ajax control toolkit, you can solve it like this
int timeout = 20;
for (i=0; i < timeout; i++)
{
bool blocked = Convert.ToBoolean(ie.Eval("Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack();"));
if (blocked)
{
System.Threading.Thread.Sleep(200);
}
else
{
break;
}
}
With the control visible you then should be able to access it normally.
Watin 1.1.4 added support for WaitUntil on controls as well, but I haven't used it personally.
// Wait until some textfield is enabled
textfield.WaitUntil("disable", false.ToSting, 10);
I'm not using any ajax control toolkit and in the popup there is no text field as i've mentioned there is only a image and a button below it, which i need to click in order to apply that image as theme.
I wrote a post about how I do ajax synchronization, since I was having problems with WaitUntilExists: http://lebobitz.wordpress.com/2011/03/06/synchronizing-watin-and-ajax-with-jquery/

Categories

Resources