|
well, i created a Bitmap as hwnd (a transparent images that resides on top of the screen (win32.getDC via native function in user32.dll) and i wonder how i can access window x and y position values and how i can get x and y of the mouse position.
is there something like a mousemove event with native win32 windows?
i have to bitmap hWnd to remain at the same x-position all the time.
and ideas?
thanks
jkersch
|
|
|
|
|
Has anyone used this? I have a very simple app that takes a xml file that I'd like to validate against a schema.
XmlValidatingReader(doc.InnerXml, XmlNodeType.Element, null);<br />
reader.ValidationType = ValidationType.Auto;<br />
reader.Schemas.Add(null, Server.MapPath(schema));<br />
reader.ValidationEventHandler += new ValidationEventHandler(ValidationHandler);<br />
while( reader.Read() );
It doesn't seem to matter what the xml is like, it never throws an exception. I've removed nodes in the xml and even passed in a xml file with a completely different structure and it passes right through.
|
|
|
|
|
try this
While objValidator.Read() And m_ValidationSuccess
End While
m_ValidationSuccess comes from validating call back
Bhaskara
|
|
|
|
|
Thanks for the VB
By implementing the ValidationHandler I can get any errors received during the validation. The problem is NO ERRORS are being generated.
|
|
|
|
|
I think I have discovered that the string function PadLeft in the 1.1 framework is broken. I experienced padding problems in my production app, so I built this simple program to test it. Form1 just contains a listbox name=listbox1 and the Items collection contains a string with 10 spaces in front of it.
private string[] texts = new string[5] {"Line One", "Line Two", "Line Three", "Line Four", "Line Five"};
private void Form1_Load(object sender, System.EventArgs e)
{
string item = this.listBox1.Items[0].ToString();
int len = 0;
for (int i=0; i<item.Length; i++)
{
if (item[i] != ' ')
{
len = i;
break;
}
}
for (int i=0; i<5; i++)
{
this.listBox1.Items.Add(String.Concat(texts[i], " unpadded"));
}
for (int i=0; i<5; i++)
{
this.listBox1.Items.Add(texts[i].PadLeft(len));
}
}
When executed, the padding eratically addes only one space and the third line is padded with nothing. All strings should have had 10 spaces padded in the left as per the framework documentation!!!
This signature left intentionally blank
|
|
|
|
|
theRealCondor wrote:
this.listBox1.Items.Add(texts[i].PadLeft(len));
This is your problem, PadLeft wants the total length, this would include what is already in the string which is why your results vary, each string length is different. The following works for me:
private void button_Click(object sender, EventArgs e)
{
string[] text = new string[]{"Line One", "Line Two", "Line Three", "Line Four", "Line Five"};
int len = 10;
char c = '.';
for(int i = 0; i < 5; i++)
box.Items.Add(text[i].PadLeft(len + text[i].Length, c));
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Re-reading the SDK I can see that they think they are stating this. Total length of string. Anyway --> this one gets inserted into the memory bank.
It is not the bugs that kill a programmer, it is the subtle errors that appear to be coded correctly.
Thanks Nick.
This signature left intentionally blank
|
|
|
|
|
Hi all!
Can anybody tell me where from to embed the Timeline control like one used in MS-Producer.I am studying DirectX 9.0 SDK documentation but havent found any clue yet.Any kind of help will be appreciated.
Thanks
|
|
|
|
|
I have a very typical problem. I am trying to create a user in activedirectory running in windows 2003 server. i am able to create user but when coming to setting password its not working.
the code :
String strPath = "LDAP://192.168.0.101:389/OU=100001,DC=Tserver,DC=local";
try
{
DirectoryEntry user = new DirectoryEntry(strPath, @"Tserver.local\administrator", "password", AuthenticationTypes.Secure | AuthenticationTypes.Sealing |AuthenticationTypes.ServerBind );
//create user
DirectoryEntry user = entry.Children.Add("cn=Test User", "user");
user.Properties["sAMAccountName"].Add("testuser");
user.Properties["sn"].Add("User");
user.Properties["givenName"].Add("Test");
user.Properties["description"].Add("Test account added with code.");
user.CommitChanges();
// User has to be saved prior to this step
user.Invoke("SetPassword", new string[] {"password1"} );
user.CommitChanges();
user.Close();
user.Dispose();
}
catch (Exception exx)
{
Response.Write("Exception: "+ exx.ToString() + " \n");
return;
}
Response.Write("Success: Password set.");
Error Description:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: The network path was not found.
Source Error:
Line 127:
Line 128: // User has to be saved prior to this step
Line 129: user.Invoke("SetPassword", new string[] {"princeton"} );
Line 130: user.Properties["userAccountControl"].Value = 0x200;
Line 131: user.CommitChanges();
Source File: c:\inetpub\wwwroot\adminlogin\pages\information.aspx.cs Line: 129
Stack Trace:
[FileNotFoundException: The network path was not found.]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +29
System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
AdminLogin.Information.btnSave_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\adminlogin\pages\information.aspx.cs:129
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
I am looking for some help to solve this problem
I think this explains the problem well? Thank you in advance.
shambho Mahadeva
hap
|
|
|
|
|
99% of the time....when you get a System.Exception.FileNotFound it is due to the fact that you are trying to get an assembly and that assembly either does not exist on the target machine ... or it does exist but the assembly identifiers do not match.
For example: if you built your application and used System.Security.dll which had an assembly identifier of version 1.1.4322 but a service pack that your machine did not receive had version System.Security.dll at version 1.1.4325 then you would get that exception.
This signature left intentionally blank
|
|
|
|
|
But my dear friend i am able to create user add all other properties why not password. Is this System.Security.dll has some thing to do with setpassword native method alone. I dont know thats why i am posting this reply.
Kindly reply me
thanks in advance
anand
|
|
|
|
|
shambho wrote:
// User has to be saved prior to this step
user.Invoke("SetPassword", new string[] {"password1"} );
Your should be passing an Object[] instead:
Object[] pswd = new Object[]{"password1"};
However by default all code that executes from the local intranet or Internet zones is partially trusted and full trust is required. You might check into placing the AllowPartiallyTrustedCallers attribute on your code.
- Nick Parker My Blog | My Articles
|
|
|
|
|
hi friend,
actually i am not using
user.Invoke("SetPassword", new string[] {"password1"} );
but
user.Invoke("SetPassword", new object[] {"password1"} );
By mistake while i was trying different alternative you got this piece of code. even with object its giving the same error
|
|
|
|
|
Hello,
I'm working on a Mapi Agent using C#.
Everything works fine despite the fact I've to commit the nice Outlook Message
which is shown after Installing the Security Update for Microsoft if you try to send mails from other interfaces.
See the Knowledge Base Articel :
http://support.microsoft.com/default.aspx?scid=kb;en-us;263073
WD2000: Warning Message: "A Program Is Trying to Access ..." When You Send Mail Merge to E-mail After You Apply Outlook Security Update
and Information for Developers :
OL98: Developer Information About the Outlook E-mail Security Update
http://support.microsoft.com/default.aspx?scid=kb;EN-US;262700
The Problem is that I've to commit this windows automatically - because this agent should run by itself.
I already find out that I've to use the user32.dll with their functions FindWindow and SendMessage,
and that you have to use Spy++ to find out the WindowClass and the wParam and lParam in hex formate.
Indeed I'm right now at the point that I can find the window, and can send messages - WM_Command.
But the wNotifyCode is wrong, I've to send a BN_Clicked WM_Command but with my routine I send a Code 0 (send from a menue) to the Window
although I got the right hex codes.
So now my question : how can I send a BN_Clicked Message to the window?
Is there any other opportunity to commit the windows with "Yes"?
I'm grateful for any advice.
Here are some code snippets :
----------------------------------------------------------------------------------
The class for the user32.dll Import and their functions :
----------------------------------------------------------------------------------
public class Win32
{
public const int WM_COMMAND = 0x111;
[DllImport("User32.dll")]
public static extern int FindWindow(string strClassName, string strWindowName);
[DllImport("User32.dll")]
public static extern int FindWindowEx(int hwndParent, int hwndChildAfter, string strClassName, string strWindowName);
[DllImport("User32.dll")]
public static extern Int32 SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
[MarshalAs(UnmanagedType.LPStr)] string lParam); // second message parameter
[DllImport("User32.dll")]
public static extern Int32 SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam); // second message parameter
}
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
The Main Routine with the calling routines :
----------------------------------------------------------------------------------
System.Int32 iHandle
// Finding the window :
iHandle = Win32.FindWindow("#32770", "Microsoft Office Outlook");
// Send a Message
Win32.SendMessage(iHandle, Win32.WM_COMMAND, 0x000012A6, 0)
----------------------------------------------------------------------------------
********************
There are only ten types of people in the world.
Those who understandy binary and those who do not
|
|
|
|
|
I use A data grid which has a datasource and a datamember is connected
to an access database.
I make update to the datagrid by using:
oledbdataAdapter1.update(dataset11.tables[0]) ;
where user make all he wants then press a button to execute the previous
line of code.
the problem is the an exception may ocuur:
"Concurrency Violation: the update command affected 0 rtecords"
I don't know what is the reason of this exception as it appears rarelly.
|
|
|
|
|
check if there are any foreign key relations existing.
Bhaskara
|
|
|
|
|
Hello,
i have developed a web service where the client sends to the server a signed xml document signed with "Infopath". When the server receives the document it is impossible fot him to valiadate the signatures. Here is my code:
(doc is a XmlDocument)
<br />
XmlNodeList nodeList = doc.GetElementsByTagName("Signature");<br />
SignedXml[] signatures = new SignedXml[nodeList.Count];<br />
<br />
for(int i = 0; i < nodeList.Count; i++)<br />
{ <br />
signatures[i] = new SignedXml();<br />
signatures[i].LoadXml((XmlElement)nodeList[i]);<br />
if (!signatures[i].CheckSignature())<br />
validSignatures--;<br />
}<br />
The xml document has been signed with a valid X509 certificate.
thank you for your help!
|
|
|
|
|
I need to print some invoices,Quality control forms etc. I have a windows application. What is a preffered way to print forms in c#. Jodoveepn seems good but i have a problen that a windows form has a max height of 876 which does not fill all of and A4 page(letter)I need the user to clck a button and the relevant forms are printed automatically without previewing. Basically i am not sure on the best approach for printing forms in a c# windows application?
|
|
|
|
|
Hi,
I have different user controls associated with the tree nodes using 'tag' property, I want to display the user controls in the empty area in the form that contains the tree view control. Can any one please guide me how to access the user control using the tag property in the AfterSelect event of the tree view control?
|
|
|
|
|
You can cast the sender as a TreeNode object and then access it's properties directly. This will allow you to see what the Tag value is.
private void treeview1_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode node = sender as TreeNode;
if(node != null)
{
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
I have done this, but still not able to access the original user control.
Let me explain again what I am doing
private void LinkUserControls()
{
treeview1.Nodes[0].Tag = _myUserControl;
}
private void treeview1_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode node = e.Node;
if(node != null)
{
// i would like to make _myUserControl visible here.
// like
_myUserControl.visible = true;
_myUserControl.location = new System.Drawing.Point(50,50)
}
}
please guide
|
|
|
|
|
got the solution it worked as follows
private void treeview1_AfterSelect(object sender, TreeViewEventArgs e)
{
if(e.Node != null)
{
UserControl uc = (UserControl) e.Node.Tag;
uc.Visible = true;
uc.BringToFront();
uc.Location = new Point(225, 240);
}
}
|
|
|
|
|
How can I get a variable pointer (as IntPtr) ?
I am trying to compare between two objects, the objects are not the same but they could be from some place ...
Example - let say we have two classes one derived from another ...
public class A
{
  protected h=0;
  public virtual func()
  {
   h=0;
  }
}
public class B:A
{
  public override func()
  {
   h=1;
  }
}
Now ... I'am creating the objects ...
obj1=Activator.CreateInstance(t1); //Type t1; class A
c.Invoke(obj1,null); //ConstructorInfo c; getting constructor from class A
the same with the other class...
obj1=Activator.CreateInstance(t2); //Type t2; class B
c.Invoke(obj2,null); //ConstructorInfo c; getting constructor from class B
From this point you can see in the debugger obj1,obj2 (with the variable h=0 in both)
Now I'am invoking my function...
//MethodInfo m1,m2; getting my virtual AND override functions each from it's class ... and after that running functions , with null as parametter...
object []parametersForFunction=new object[m1.GetParameters().Length];
//m1 or m2 doesn't matter they have the same parameters... virtual,override
m1.Invoke(obj1,parametersForFunction);
m2.Invoke(obj2,parametersForFunction);
I can't check "h" with the GetFields() couse its not public()..
My problem is here...
Now if wee go back to the debugger we can see that in obj1.h=0 and obj2.h=1
Somthing like this
obj1.A.h=0
obj2.B.A.h=1
My idea was to try the Marshal.ReadIntPtr(IntPtr,offset) so I can read obj2 after some offset, So I needed my variable Address. (somehow even in unsafe we cant do object *p=obj1; on objetcs...)
I tried Marshel.ReadByte and it's not working cause my object type could be anything...
Anyone have some idea ???
Thanks
|
|
|
|
|
You can use BindingFlags to get non-public members from an object.
Type.GetField(name, BindingFlags.GetField | BindingFlags.NonPublic)
|
|
|
|
|
Yes, but I still wanted to do this by comparing objects.
I want to know how to get a variable pointer as IntPtr and how to read from unknown type object from a specific place.
|
|
|
|