|
Heyas Curtis,
I've actually come across a bit of a problem, VS is saying that in order for me to set this property value I must have an instantiated object. I don't understand that. the MainForm is going to be instantied when it runs. Here's my code:
In MainForms Class description I have...
<br />
internal String txtStatusValue{ set{ this.txtStatus.Text = value;}}<br />
and then in my class file I have..
<br />
internal void vMyFunction()<br />
{<br />
MainForm.txtStatusValue = "Blah Blah Blah";<br />
}<br />
I don't get it, could I trouble you for but more assistance?
Thanks,
John
|
|
|
|
|
sounds like your calling the txtStatusValue before the mainform is instantiated or before the variable you're using to call the mainform propery is initialized.
do something like this:
public class MainForm: Form
{
public static MainForm myMainForm = null;
public MainForm()
{
myMainForm = this;
}
internal public string txtStatusValue { set { txtStatus.Text = value; } }
}
public MyClass
{
public void someFunc()
{
MainForm.myMainForm.txtStatusValue = "foo";
}
}
hope this helps...
|
|
|
|
|
If I have a function in dll generated by managed C++, how do I pass arrays in C# so that I can get my output array back?
Any help is appreciated!
Devin
|
|
|
|
|
What do you mean? Your question keeps many details unsaid. If you have a C++.NET DLL with a function like
void YourClass::MyFunc( double [] dArray ){...}
Why can't you call that function from C# directly like
...<br />
double [] dArray = new double [ 10 ];<br />
YourClass yc = new YourClass();<br />
yc.MyFunc( dArray );<br />
...
If your question is more complex than that, you will get better responses if you elaborate...
Koushik Biswas
|
|
|
|
|
Thanks Koushik!
It is then pretty natural.
Devin
|
|
|
|
|
Hi all,
I have developed a dll in Win32. That dll finds the updated regions
of the desktop and then post these regions data to a C# application
using PostThreadMessage(). But problem is here i m not so much use to
with C# so i havent any idea how can i get it from the Application
message queue of my C# application.
Thanx
|
|
|
|
|
In C#, you typically don't deal with the Win32 message queue. The .NET framework is designed to abstract away the underlying operating system & hardware. So, if you're listening for when a user moves his mouse over your System.Windows.Forms.Form, just setup an event handler for the MouseMove event.
Form myForm = new Form();
myForm.MouseMove += new MouseEventHandler(MyMouseMoveFunction);
...
void MyMouseMoveFunction(object sender, MouseEventArgs arguments)
{
}
That said, if you want to get low level, past the abstractions, you can create a class that inherits from System.Windows.Forms.Form, then override the WndProc virtual method; that method is called every time your form receives a windows message.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
|
Dear u r quite right that i can track mouse movements. But here is the
different case my dll is a hooking dll and is responsible for getting
screen display updates. So here i m restricted to use that unmanaged
dll.
I have passed dll the managed thread id so that dll can post messages
of screen updates to my C# application.
Is it right to pass a managed thread id in PostThreadMessage()?
Thanx for ur response.
|
|
|
|
|
Does the WebBrowser control introduced in .NET 2.0 work fine with console applications? I'm facing problems doing something like
string x = "<HTML>abc</HTML>";
browser.DocumentText = x;
Unfortunately, x never gets set, browser.DocumentText always remains as <HTML> </HTML>
On a hunch, I tried doing an Application.DoEvents right after setting the DocumentText property and it worked. Does that mean there is no *easy* way to use the WebBrowser just for inspecting and manipulating the DOM tree?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
We've had trouble with WebBrowser controls without a parent; you may end up having to create an invisible form and add the browser to that form before you can do things with the document.
|
|
|
|
|
That did the trick, thank you. I dearly wish .NET 2.0 provided a class to do nothing else but parse HTML.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote: I dearly wish .NET 2.0 provided a class to do nothing else but parse HTML.
I agree.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
Yeah, the WebBrowser control won't work properly without a parent form, which you don't have in a Console app. You'll have to create a form to put the control on, but just never show the form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi, I have a problem with the functions SetCommTimeouts and GetCommTimeouts of the Win32 API.
First of all, I want to make a synchronous read on a USB device with a timeout of 250 ms, that is, the ReadFiule function returns after 250 ms if no data is received.
This is the COMMTIMEOUTS Structure
<code>
[StructLayout(LayoutKind.Sequential)]
public struct COMMTIMEOUTS
{
public int ReadIntervalTimeout;
public int ReadTotalTimeoutMultiplier;
public int ReadTotalTimeoutConstant;
public int WriteTotalTimeoutMultiplier;
public int WriteTotalTimeoutConstant;
}
</code>
These are the 2 functions: GetCommTimeouts and SetCommTimeouts
<code>
[DllImport("kernel32.dll")]
public static extern bool GetCommTimeouts(IntPtr hFile, out COMMTIMEOUTS lpCommTimeouts);
[DllImport("kernel32.dll")]
public static extern bool SetCommTimeouts(IntPtr hFile, ref COMMTIMEOUTS lpCommTimeouts);
</code>
And finally, here is how I try to adjust the timeouts
<code>
FileIO.COMMTIMEOUTS timeouts;
// Create handle
hidHandle = unchecked( FileIO.CreateFile(path,
(uint)(FileIO.GENERIC_READ | FileIO.GENERIC_WRITE),
FileIO.FILE_SHARE_READ | FileIO.FILE_SHARE_WRITE,
ref security,
FileIO.OPEN_EXISTING,
0,
IntPtr.Zero));
if(hidHandle == FileIO.INVALID_HANDLE_VALUE)
{
success = false;
}
else
{
// Read timeouts
if(FileIO.GetCommTimeouts(hidHandle, out timeouts))
{
timeouts.ReadIntervalTimeout = 0;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
timeouts.WriteTotalTimeoutMultiplier = 0;
// Set them
if(FileIO.SetCommTimeouts(hidHandle, ref timeouts))
{
// I READ THEM AGAIN AND THEY HAVE NOT CHANGED!!!
FileIO.GetCommTimeouts(hidHandle, out timeouts);
success = true;
}
}
else
{
int lastError = FileIO.GetLastError();
}
}
</code>
I create a handle successfully, I call GetCommTimeouts, it returns true, I modify the timeouts and apply them by calling SetCommTimeouts, it returns true. But then, when I call GetCommTimeouts again, the timeouts are just like before! They haven't changed!
Where's my mistake?
Thank you!
|
|
|
|
|
is it possible to add an app.config in a class library project and use that to retrieve the appsettings?
from within a class in the same project?
If so then I can not see why mine does not retrieve the appsettings?
Thanks
|
|
|
|
|
.config files work per AppDomain. Class libraries do not get an AppDomain, so they will use the .config files of the loading applications.
However, Mike Woodring has an interesting solution with per-Assembly configuration files. You may want to take a look at his Per-Assembly Configuration Files.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
so do you mean that I can not add an app.config in my class library project ?
|
|
|
|
|
Correct. If you have the class library goo.dll, then it will not use the goo.dll.config file for its appSettings.
I haven't used .NET 2.0 and do not know if they have expanded support for this to Class Libraries. Maybe someone else on the board can answer that.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I am using 1.1 and it allows me to add app.config
On the other hand, how can i pick up the connectionstring from a datalayer?
Thanks
|
|
|
|
|
I apologize. I don't understand what you mean by it "allows [you] to add app.config" and "pick up the connection string from a data layer."
If you need a configuration string that exists outside your application, you can always just roll your own config file, open it, parse it, and use the values that you find inside it. Or, you could store it in the registry. Or, use the AssemblySettings class to which I linked a couple of posts ago. You don't have to use the .config framework here. I think it would be great if you could....
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
In the class library project, I can go to add new item and add an app.config file.
|
|
|
|
|
Just because you can add it to the project does not mean that your code can use it automatically. Sorry that you got misdirected by the IDE.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
ok, so let me get this correct.
I should not be adding a app.config in my class library project, because even if i do, it will not work.
Is this correct?
Thanks
|
|
|
|