Posts

Showing posts from December, 2012

Donate

How To Get Textbox Or RichtextBox Value Using pInvoke In Windows API C#

Assuming you already get the pointer handle of the textbox/richtextbox control from source calling function, the snippet to get the content of the edit control is as follows. public const int GWL_ID = -12; public const int WM_GETTEXT = 0x000D; [DllImport("User32.dll")] public static extern int GetWindowLong(IntPtr hWnd, int index); [DllImport("User32.dll")] public static extern IntPtr SendDlgItemMessage(IntPtr hWnd, int IDDlgItem, int uMsg, int nMaxCount, StringBuilder lpString); [DllImport("User32.dll")] public static extern IntPtr GetParent(IntPtr hWnd); private StringBuilder GetRichEditText(IntPtr hWndRichEdit) { Int32 dwID = GetWindowLong(hWndRichEdit, GWL_ID); IntPtr hWndParent = GetParent(hWndRichEdit); StringBuilder title = new StringBuilder(128); SendDlgItemMessage(hWndParent, dwID, WM_GETTEXT, 128, title); return title; } Greg

WPF Webbrowser Loop Through Html Elements And Submit

A question was raised on vbforums on how to invoke click a button using WPF webbrowser control. This sample loads google.com page and writes a sample text on the textbox and then invoking the click button. HTMLDocument document = (HTMLDocument)wbGetHost.Document; foreach (IHTMLElement myelem in document.getElementsByTagName( "input" )) { if (myelem.id != null ) { if (myelem.id.Equals( "lst-ib" ) && myelem.className.Equals( "lst lst-tbb" ) && !document.documentElement.innerHTML.ToLower().Contains( "wikipedia" )) { HTMLInputElement el = myelem as HTMLInputElement; el. value = "Bill Gates" ; HTMLInputElement searchButton = (HTMLInputElement)document.all.item( "btnK" , 0); searchButton.click(); break ; } } } Greg

The Controller For favicon.ico Does Not Implement IController

In an application using Controller factory, i encountered an error as stated in the title. My MVC does not have a favicon.ico. The solution is to add a parameter constraint that does not allow .ico filenames in your routes. I got the solution from forums.asp.net routes.MapRoute( "Default" , // Route name "{controller}/{action}/{id}" , // URL with parameters new { controller = "ProductView" , action = "Index" , id = "" }, // Parameter defaults new { controller = @"[^\.]*" } // Parameter constraints (regex/string expression) );

How To Count Duplicate Or Repeating Records From Union All Query In SQL

Here's a query to count number of repeating records based from union all query. Union all query does not remove duplicate records. Here's a sample script: select resultsduplicate.url as job_item, count (resultsduplicate.url) as repeat_occurence from ( SELECT url FROM mainTable where id = 47 and url like '%testsite.com%' and _active = 1 UNION ALL SELECT url FROM detailTable where id = 47 and url like '%testsite.com%' and _active = 1 )resultsduplicate group by resultsduplicate.url having ( count (resultsduplicate.url) >1); Original Source From (Stackoverflow.com)

Content Types Or MIME Types List In ASP.NET MVC

I have searched for content types which is suitable for ASP.NET or ASP.NET MVC applications using the HttpResponse class ContentType property. Here's the website with the MIME list: Mime Type List Here's a sample asp.net/mvc snippet. HttpResponseBase response = context.HttpContext.Response; response.ContentType = "application/pdf" ; Greg

Donate