Search This Blog

Monday, March 30, 2009

Connect to an existing IE Browser in c#

if you like to connect to an existing IE browser and get some events , here is a code snippets to do that .
do not forget to add refrence to SHDocVw .
Yaniv



private void btnConnExisting_Click(object sender, EventArgs e)
{
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();

foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
if (ie.LocationURL.Contains("what ever"))
{
MessageBox.Show("Location:" + ie.LocationURL);
ie.BeforeNavigate2 += new SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(this.ie_BeforeNavigate2);
}
}
}

public void ie_BeforeNavigate2(object pDisp, ref object url, ref object Flags,
ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
{
MessageBox.Show("do what you want!");
}
}

Tuesday, March 24, 2009

WebBrowser control - DocumentCompleted event and Tips

All the developer familiar with the DocumentCompleted event , but you need to be aware of that if you have client side script that handle this event too or do something on the OnLoad event , you will miss the point , we are expecting to get this event after all done , but that the way it is .
i found a solution that works for me - and the credits is not mine , the idea is to call the documentcomplete event later on the same thread after the original call arrived, you can find the solution here :
Triggering DocumentCompleted after the OnLoad event .

another very good resource you can find here
Using Internet Explorer from .NET

enjoy
Yaniv

Thursday, March 19, 2009

Read && Write To/From file c++ MFC

two simple function to read & write to/from file in c++ MFC.

void WriteToFile(CString data)
{
CStdioFile file("C:\\TEMP\\chinese.txt",CFile::modeCreate | CFile::modeWrite);
file.WriteString(data);
file.Close();

}
CString ReadFromFile()
{
CStdioFile file("C:\\TEMP\\chinese.txt",CFile::modeRead);
CString data;
file.ReadString(data);
file.Close();
return data;

}


Yaniv

Tuesday, March 17, 2009

See all network computers

if you want to see all network computer , you can run the next command on your windows console
net view

Sunday, March 15, 2009

Windows command line

In the next link you can find all windows command line from A-Z
Command-line reference A-Z

Thursday, March 12, 2009

Read && Write To/From file UTF-8 characters in java

Here is the write method :


private void writeToFile(String data)
{
try {
File file = new File("C:\\TEMP\\chinese1.txt.html");
BufferedWriter bw = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(file),"UTF8"));

bw.write(data);
bw.close();

} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}



Here is the read method


private String readFromFile()
{
String retStr="";
try {
File file = new File("C:\\TEMP\\chinese.txt.html");
BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(file),"UTF8"));

String s;
while((s = br.readLine()) != null) {
retStr += s;//new String(s.getBytes(),"UTF-8");
}
br.close();

} catch (IOException e1) {
e1.printStackTrace();
}
writeToFile(retStr);
return retStr;
}


Yaniv

Sunday, March 8, 2009

Axis Web services with XML Schemas

if you would like to develop AXIS web services with validation schema, you can find here a very good tutorial / article , with project sample .

Developing Axis Web services with XML Schemas

enjoy
Yaniv