|
Mine is windows form application in C#. Application find some page on internet e.g. IE window. And then send some value to text of the IE page.
I have used below code for the same. But some how SendMessageTimeout function return nothing, without error.
private IHTMLDocument2 documentFromDOM()
{
Process[] processes = Process.GetProcessesByName("iexplore");
if (processes.Length > 0)
{
IntPtr hWnd = processes[0].MainWindowHandle;
int lngMsg = 0;
int lRes;
EnumProc proc = new EnumProc(EnumWindows);
EnumChildWindows(hWnd, proc, ref hWnd);
if (!hWnd.Equals(IntPtr.Zero))
{
lngMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");
if (lngMsg != 0)
{
SendMessageTimeout(hWnd, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, out lRes);
if (!(bool)(lRes == 0))
{
int hr = ObjectFromLresult(lRes, ref IID_IHTMLDocument, 0, ref document);
if ((bool)(document == null))
{
MessageBox.Show("No IHTMLDocument Found!", "Warning");
}
}
}
}
}
return document;
}
Any help is welcome. Or if somebody has an C# example of SendMessageTimeout with IE window to retrieve IE HTML will be greatful.
|
|
|
|
|
You have not shown your DllImport declaration for SendMessageTimeout so it's not possible to tell if you have an error there.
You are not checking the return value of the function, only the lpdwResult parameter value - this may or may not be significant.
A quick observation:
if (!(bool)(lRes == 0)) , there is no need to cast to bool, just if (lRes != 0) will do.
|
|
|
|
|
Thanks for the reply.
Here is DllImport declaration
[DllImport("user32.dll", EntryPoint = "GetClassNameA")]
public static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount);
public delegate int EnumProc(IntPtr hWnd, ref IntPtr lParam);
[DllImport("user32.dll")]
public static extern int EnumChildWindows(IntPtr hWndParent, EnumProc lpEnumFunc, ref IntPtr lParam);
[DllImport("user32.dll", EntryPoint = "RegisterWindowMessageA")]
public static extern int RegisterWindowMessage(string lpString);
[DllImport("user32.dll", EntryPoint = "SendMessageTimeoutA")]
public static extern int SendMessageTimeout(IntPtr hwnd, int msg, int wParam, int lParam, int fuFlags, int uTimeout, out int lpdwResult);
[DllImport("OLEACC.dll")]
public static extern int ObjectFromLresult(int lResult, ref Guid riid, int wParam, ref IHTMLDocument2 ppvObject);
public const int SMTO_ABORTIFHUNG = 0x2;
public Guid IID_IHTMLDocument = new Guid("626FC520-A41E-11CF-A731-00A0C9082637");
As per suggestion, I have checked return value and it(i) is 1 (non zero). Modified statement is as below;
int i = SendMessageTimeout(hWnd, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, out lRes);
if (lRes != 0 && i !=0)
|
|
|
|
|
According to MSDN[^]:
If the function succeeds, the return value is nonzero.
so it is definitely succeeding.
I don't think it will make any difference to your exact problem, but your function declaration is not correct. You shouldn't use int where it should be IntPtr as int is always 32 bits but IntPtr will be 64 bits on a 64 bit system. I would use:
using System;
using System.Runtime.InteropServices;
internal static class NativeMethods
{
public const int SMTO_NORMAL = 0x0000;
public const int SMTO_BLOCK = 0x0001;
public const int SMTO_ABORTIFHUNG = 0x0002;
public const int SMTO_NOTIMEOUTIFNOTHUNG = 0x0008;
public const int SMTO_ERRORONEXIT = 0x0020;
[DllImport("User32.dll", SetLastError = true)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd,
int Msg,
IntPtr wParam,
IntPtr lParam,
int fuFlags,
int uTimeout,
out IntPtr lpdwResult);
}
I have never tried to get HTML this way so I really can't help any further without some experimenting - if I get time I will have a look.
Edit: I have had a quick play around. In my tests, lRes (lpdwResult) always sets a zero pointer - I haven't found out what exactly this is supposed to be - MSDN just states:
The value of this parameter depends on the message that is specified.
Have you seen the code here[^] - perhaps that can help?
modified 26-Feb-12 6:18am.
|
|
|
|
|
Thanks for the reply. Still trying to figure it out.
|
|
|
|
|
|
First, the subject line of a post should be short. The body of the post should contain the question, not the other way around.
SQL servers are designed to be managed using SQL query language, including the construction of databases, tables, column definitions, security as so forth.
You build an SQL script that builds the database and when your app is installed, you include custom actions that ask for the server to attach to, the credentials to use, and then you connect to the server and execute the script, just like it would be if you were querying a database instead.
|
|
|
|
|
During install, check if the database already exists.
If it does, don't create it.
|
|
|
|
|
how to loop through Application openforms
and get specified form which is active
with note that may be more than one form with the same name is running
Form ActvFrm = this.ActiveMdiChild;
string cptn = ActvFrm.Name;
FrmNewPatiant FNew = (FrmNewPatiant)Application.OpenForms["FrmNewPatiant"];
foreach (Form FrmNew in Application.OpenForms)
{
if (FrmNew.Text == cptn)
{
FrmNewPatiant actvNewPat = (FrmNewPatiant)Application.OpenForms[cptn];
actvNewPat.tabNewFile.TabPages[2].Enabled = true;
actvNewPat.tabNewFile.SelectedTab = FNew.tabNewFile.TabPages[2];
}
}
|
|
|
|
|
What I used to do was store a value typically the id of the record or individual. I stored this value as the tag value of the child form created. In this way you can make certain not to replicate already created or open form by comparing this value to be created with the values stored in all of the currently open and active forms.
I now use Tabs instead of MDI in most of my applications though which is why I said used.
modified 26-Feb-12 19:14pm.
|
|
|
|
|
can you give me example on how to use tags for each mdi child?
|
|
|
|
|
This is how I did it when using MDI.
I used a Tree View control populated with A-Z subnodes would be names organized last to first with a comma and middle initial, and I would store the id of the record containing the information in the tag element of the Tree View like so.
private void updateTreeview()
{
for (int i = System.Convert.ToInt32('A'); i <= System.Convert.ToInt32('Z'); i++)
{
treeView1.Nodes.Add(Convert.ToString((char)(i)), Convert.ToString((char)(i)));
}
TreeNode childnode = null;
string sContactsName = null;
foreach (DataRow rowContacts in dtContacts.Rows)
{
sContactsName = string.Concat(rowContacts["LastName"].ToString(), ", ", rowContacts["FirstName"].ToString());
if (!(System.Convert.IsDBNull(rowContacts["MiddleInitial"].ToString())))
{
sContactsName = string.Concat(sContactsName, " ", rowContacts["MiddleInitial"].ToString(), ".");
}
childnode = new TreeNode(sContactsName, 0, 1);
childnode.Name = sContactsName;
childnode.Tag = rowContacts["ContactID"].ToString();
string sortnode = sContactsName.Substring(0, 1).ToUpper();
treeView1.Nodes[sortnode].Nodes.Add(childnode);
}
treeView1.Visible = true;
treeView1.Enabled = true;
treeView1.ExpandAll();
}
After the node containing the name was clicked I handled it like this:
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
string nodeName = e.Node.Name;
if (nodeName.Length == 1)
{
return;
}
foreach (Form f in this.MdiChildren)
{
if (f.Name == nodeName)
{
f.Activate();
return;
}
}
string id = e.Node.Tag.ToString();
displayContact(nodeName, id);
}
This checked the form by id to see if it was already displayed and only created a new form if it was not displayed.
|
|
|
|
|
It would be very appreciate if anybody can help me.
Is it possible to pass filter condition in datagrdview.parameter to filter all the records having null value on that column
if (comboBoxOperator.Text == "xxx..") ResultFilterExpression = this.DataGridViewColumn.DataPropertyName + " LIKE '" + FilterValue + "%'";
How I can pass FilterValue as null condition .
With Many thanks
Pol
|
|
|
|
|
if (comboBoxOperator.Text == "xxx..") ResultFilterExpression = this.DataGridViewColumn.DataPropertyName + " IS NULL";
?
--edit;
Don't bump[^] your question.
Bastard Programmer from Hell
modified 24-Feb-12 19:32pm.
|
|
|
|
|
|
You're welcome
|
|
|
|
|
every body.. please help me about my problem..
i need exemple of code using c#..
how to access mySql if you made class model, class dao,,and class view.
in class model : you can make "setter getter" of your komponent,,
in class dao: you can make connection and accessing database.. "save,sellect,update,delete".
in class view : you can make some form to access mySql..
please help me..
|
|
|
|
|
Sounds like homework to me: go speak to your teacher.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
i'm sory sir.. i'm a student in high school.. so i'm just new in code to know.. jajajaajjajaajajaja.
sooo please help me sirrr
|
|
|
|
|
|
I want compress a string with Java(in Android) and decompress with c#...
I did test many algorithm.. but i cant solved my problem.
What can i do?
|
|
|
|
|
Doesn't Java support Zip[^]? .NET supports it as well. Tried it?
--edit;
Don't crosspost[^], pick a forum and stick to it.
Bastard Programmer from Hell
modified 24-Feb-12 19:27pm.
|
|
|
|
|
The important thing is to select an algorithm which is normally supported on Windows computers, like the "normal" zip suggested above. Do not use bzip, gzip and so on. After compressing with Java, save it to a file (with the extension .zip), and try to open that file with Windows explorer: when that works, the first step is succesfully completed. Then find out how to unzip it with C#.
|
|
|
|
|
Hi All
I am trying to loop through a byte array (sample below) reading the values to then insert those into a database
I loop through keeping track of the position
byte[] data;
long position=0;
while (position < data.Length)
{
position = Conversion.Extract(data, out mydata, position);
position = Conversion.Extract(data, out nextitem, position);
}
public static long Extract(byte[] message, out int variable, long position)
{
const int length = 4;
if (message.Length >= position + length)
{
variable = BitConverter.ToInt32(message, (int)position);
return position + length;
}
variable = 0;
return -1;
}
The data i have contains some null values, how can i extract these and successfully move onto the next value. At present if i come across a null value i dont know how to detect this and move onto the next item. Can anyone help at all
Thanks
Simon
6F 72 67 61 6E 69 73 61 74 69 6F 6E 49 64 3D 33
26 10 00 00 00 50 65 6F 70 6C 65 50 65 6F 70 6C
65 4C 69 6E 6B 6A 08 00 00 09 00 00 00 0E 00 00
00 53 65 6E 69 6F 72 50 65 72 73 6F 6E 49 64 0E
00 00 00 4A 75 6E 69 6F 72 50 65 72 73 6F 6E 49
64 11 00 00 00 53 65 6E 69 6F 72 50 65 72 73 6F
6E 4D 69 73 49 64 11 00 00 00 4A 75 6E 69 6F 72
50 65 72 73 6F 6E 4D 69 73 49 64 08 00 00 00 4C
69 6E 6B 54 79 70 65 16 00 00 00 50 61 72 65 6E
74 61 6C 52 65 73 70 6F 6E 73 69 62 69 6C 69 74
79 08 00 00 00 50 72 69 6F 72 69 74 79 0B 00 00
00 4C 61 73 74 55 70 64 61 74 65 64 07 00 00 00
44 65 6C 65 74 65 64 01 00 00 00 D7 0A 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 01 80 C3 29
C6 85 BF CE 08 00 02 00 00 00 3C 0C 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 F0 83 76 C6
85 BF CE 08 00 03 00 00 00 3C 0C 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 C0 0E 76 C6 85
BF CE 08 00 04 00 00 00 67 0B 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 01 70 CA 4B C6 85 BF
CE 08 00 05 00 00 00 67 0B 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 02 70 CA 4B C6 85 BF CE
08 00 06 00 00 00 9B 08 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 02 C0 BE B2 C5 85 BF CE 08
00 06 00 00 00 AD 09 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 02 10 6D F5 C5 85 BF CE 08 00
06 00 00 00 3F 0A 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 02 80 59 11 C6 85 BF CE 08 00 07
00 00 00 E3 0A 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 01 C0 D0 2C C6 85 BF CE 08 00 08 00
00 00 9B 08 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 01 C0 BE B2 C5 85 BF CE 08 00 08 00 00
00 AD 09 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 01 10 6D F5 C5 85 BF CE 08 00 08 00 00 00
C9 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 20 76 FA C5 85 BF CE 08 00 08 00 00 00 3F
0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01 B0 CE 11 C6 85 BF CE 08 00 09 00 00 00 E3 0A
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01
90 5B 2C C6 85 BF CE 08 00 0A 00 00 00 C9 09 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 20
76 FA C5 85 BF CE 08 00 0B 00 00 00 F6 08 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 01 E0 C9
D2 C5 85 BF CE 08 00 0C 00 00 00 F6 08 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 02 F0 2C C9
C5 85 BF CE 08 00 0E 00 00 00 91 09 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 01 C0 C7 EF C5
85 BF CE 08 00 0F 00 00 00 91 09 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 02 90 52 EF C5 85
SeniorPersonId | JuniorPersonId | SeniorPersonMisId | JuniorPersonMisId | LinkType | ParentalResponsibility | Priority | LastUpdated Deleted
1 | 2775 | {null} | {null} | {null} | 0 | 1 | 2012-02-22 14:31:18.200 | {null}
2 | 3132 | {null} | {null} | {null} | 0 | {null} | 2012-02-22 14:31:18.703 | {null}
3 | 3132 | {null} | {null} | {null} | 0 | {null} | 2012-02-22 14:31:18.700 | {null}
4 | 2919 | {null} | {null} | {null} | 0 | 1 | 2012-02-22 14:31:18.423 | {null}
modified 24-Feb-12 7:54am.
|
|
|
|
|
I may be misunderstanding this, but wouldn't you just check it see if variable is 0 and get the next Int32 if it was??
|
|
|
|
|