|
I am converting some code written by someone else in VB(.NET?) to Visual C#. I have figured out most of the weird language, but I am stuck on one problem. Here is the VB code (you may recognize it from MSDN):
Private Sub ConfigureContextMenu(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Popup<br />
Dim ctl As TextBox = CType(Me.SourceControl, TextBox)<br />
MenuItems .Enabled = ctl.CanUndo<br />
MenuItems(7).Enabled = (ctl.SelectedText <> ctl.Text)<br />
MenuItems(2).Enabled = (ctl.SelectionLength > 0) ' cut<br />
... (continues)<br />
How do I translate the usage of the Handles keyword in VB to C#. I know there is no handles keyword.
Thanks in advance for any help,
Josh Koppang
There's a fine line between confidence and arrogance.
|
|
|
|
|
Josh,
I am unfamiliar with the rest of the code...so please take this with the appropriate grain of salt.
It looks like you want your method (ConfigeContextMenu) to handle the Popup event on MyBase (a ContextMenu?)
In C# you do would something like:
MyBase.Popup+=new EventHandler(ConfigContextMenu);
Bill
|
|
|
|
|
Is their any way to return the url the moment the user type it in the browser?
or
Is their any way to return the url typed in the current instance of the browser?
====================
I am sorry, really I did not get you enough information.
I am developping a software (windows appication) with C# that enables users to connect to the internet. I want to restrict the sites that the user can enter by preventing him from accessing a specified web sites that is determine in the database. So I need to know what the user type in the browser or what is typed in the browser assuming that this site is opened from a link.
Also I need to restrict what the user can download from the internet.
can any one help me?
Thank You.
|
|
|
|
|
Return it to where?
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
Yes there is, but as Colin was getting at, from what do you want to get the URL? From a BHO? A separate program? What?
If you already have an instance of the InternetExplorer out-of-process automation server (or for the WebBrowser ActiveX control that can be interop'd for use with .NET), you can simply get this using the LocationURL property of the IWebBrowser2 interface that the WebBrowser control and InternetExplorer automation server implement.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am sorry, really I did not get you enough information.
I am developping a software (windows appication) with C# that enables users to connect to the internet. I want to restrict the sites that the user can enter by preventing him from accessing a specified web sites that is determined in the database. So I need to know what the user type in the browser or what is typed in the browser assuming that this site is opened from a link.
Also I need to restrict what the user can download from the internet.
can any one help me?
Thank You.
|
|
|
|
|
Hi,
I would appreciate if you could help me with my source code.
I want to create web user controls dynamically each time i press the button.
But i only get one control each time. If i use a 'for'-loop then it is no problem.
public Control c1;
private void Button1_Click(object sender, System.EventArgs e)
{
c1 = LoadControl("WebUserControl1.ascx");
((WebUserControl1)c1).Color="green";
FindControl("WebForm1").Controls.Add(c1);
FindControl("WebForm1").Controls.Add(new HtmlGenericControl("hr"));
}
Yours sincerely
Andla
|
|
|
|
|
I'm not sure I fully understand what you are looking for, but here's my best shot at the information you might find useful.
Because ASP.NET is stateless it doesn't remember from one page request to the next what happened. That is why there are various mechanisms to help it remember. (like Viewstate, Session and Application variables).
When you create any control dynamically on a page you have to manually create a mechanism to remember it was created, so than on the postback you can dynamically re-create it again. (This sounds like a real pain - and believe me it can be a great source of bugs if care is not taken).
So, what can you do? One way might be to store the information about the control in to the Session object, then in the page load you can extract that information and recreate all the dynamic controls you created the last time so that the page is back to the way it was before. Then when the button click event is fired and you go to create a new dynamic control all the other previously created dynamic controls are already there so you get the effect that it is adding more controls.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
To get the URL that is currently beign typed into the Address Bar ? Did you mean that ? I think by normal methods it's not possible. Maybe only by scanning keyboard input when Address Bar is focused (if you can determine witch control of an application is being focused).
|
|
|
|
|
Sorry, I posted this accedentaly to a wrong thread. I ment to post this to a thread above "Is there a way to ....". Sorry.
|
|
|
|
|
hi
i make a win app , iwant to make the action of enter press in keyboard as the action of button OK in my form i dont Know how;)
|
|
|
|
|
Hi,
The Form has an "AcceptButton" property that will do let you this.
Viewing the form in Design mode, look at the properties window. The AcceptButton property will have a list of all the buttons on the form. Pick you one you want.
Or you can set it in code:
<br />
Button MyButton=new Button();<br />
...<br />
Form.AcceptButton=MyButton<br />
According to the Help: "You can use this property to allow the user to quickly navigate a simple form by allowing them to simply press the ENTER key when they are finished instead of manually clicking the accept button with their mouse."
In a nutshell, when the user hits enter, the Click event on the specified button is fired.
Hope this helps,
Bill
ps: there is a CancelButton property that sets a default button for ESC.
|
|
|
|
|
I've made an implementation of WH_KEYBOARD_LL, however this is only supported in the NT side of windows. I need compatibility with 9x so I'll have to go with WH_KEYBOARD. However, the WH_KEYBOARD isn't system-wide by deafult and has to reside in a seperate library. Would it be a good idea to do this in C# and are there any suggestion and pointers to examples/articles on this?
|
|
|
|
|
There's several articles on hooks here on CodeProject. Just search.
Using a system hook is never a good idea unless you really need to. Using .NET is probably not a good idea either, especially for keyboard and mouse hooks because of the sheer volume of messages posted. If you only need this for an application, take a look at the IMessageFilter interface and the Application.AddMessageFilter method for a much easier, application-specific means.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm developing a utility/accessibility application that needs to monitor the keyboard system wide. If it was a simple application-specific thing it wouldn't be a problem. My problem is getting the hook installed. It just doesn't work.
|
|
|
|
|
Again, there are plenty of articles on CodeProject regarding this topic. You just have to search[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Any articles on saving delta values (only what was changed - much as Visual Source Safe's history) and then reconstructing the two?
As a brief example:
ORGINAL: The cow jumped over the moon.""
NEW: "The horse jumped over the moon."
DELTA would be "horse" - no need to save the entire ORGINAL.
This can become complicated over revisions and I would rather not recreate fire when others already offer matches.
Thanks!
|
|
|
|
|
You can always take a look at CVS and RCS sources and documentation, as they are open source and accomplish the same things.
Perl combines all the worst aspects of C and Lisp: a billion different sublanguages in one monolithic executable. It combines the power of C with the readability of PostScript. -- Jamie Zawinski
|
|
|
|
|
In addition, the source code to WinDiff is available.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Hi
Another question today, I'm trying to make a web service client in windows form. I add the web reference and I made the instance of the class, but I don't know how I add the argument to the instance???
Thanks
----
hxxbin
|
|
|
|
|
Add a constructor to your web serive with that argument, then in the client you can do it. Its the same as other object oriented you do in your regular coding.
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
I'm playing with COM again, and i've managed to obtain an ItemIDList and marshal it to an ItemID structure i've built in C# that contains a pointer to a SHItemID.
However, I'm slightly confused as the ItemIDList does not actualy contain an array, but rather a single instance of SHItemID, which in turn contains a single ItemID value. So for a start, i'm confused as to where the <italic>list element of this is.
However, I do have a pointer from the ItemIDList, and i'm trying to marshal it to a C# version of ItemID.
The problem is, it's having none of it. I'm getting a shell error (no error message, so i assume it's in the shell). I believe this to be caused by the SHItemID being of varying size (the byte array?), and i'm absoloutely clueless as to how to marshal it.
So how do I marshal an unmanaged structure based on the size of it's memory allocation, when all I have is a C# template and an IntPtr to it?
Regards
Cata
|
|
|
|
|
The Catalyst wrote:
So how do I marshal an unmanaged structure based on the size of it's memory allocation, when all I have is a C# template and an IntPtr to it?
Check out Marshal.PtrToStructure[^] method, that's exactly what this does.
- Nick Parker My Blog
|
|
|
|
|
Hi
Any idea or info on how to map a network drive in C#. A code example or a pointer to a web site with info would be appreciated.
Thanks
|
|
|
|
|
Do you want to map the drive...or just access a file on a network share?
|
|
|
|