|
No, considering it's completely meaningless in Windows Forms. ViewState holds onto the current state of the controls and variables on a Web Form between page refreshes. There's no such concept in Windows Forms.
I see nothing in this code that couldn't be done more simply with a class-scoped variable.
|
|
|
|
|
thanks for the fast reply.. im sorry but im still quite new to vb.net could you give me an example (i dont want you to wright my code for me just an example of what you mean)
thanks again
Kev
|
|
|
|
|
Protected Property currentFolderPath() As String
Get
Return m_currentFolderPath.Trim()
End Get
Set(ByVal value As String)
m_currentFolderPath = value
End Set
End Property
led mike
|
|
|
|
|
Very confused here in VB.net 2003. If the user is working in one form and clicks onto a 2nd form, the first form's deactivate does not fire if they click on the grid in the 2nd form, but it does fire if they click on the 2nd form's header. Also the 2nd form's activate does not fire either. This seems strange, how can I determine when the user has clicked off of the first form onto any control on the 2nd form? I've tried Lost Focus but that didn't work either. I'm trying to disable a timer on the first form whenever the user clicks onto any other form, but it doesn't seem to work unless they click on the form header and not the grid.
|
|
|
|
|
listen,
i dont really know what you are trying to achieve but, try mdi forms parent/child or use usercontrols like pages rather than using many forms.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Thanks, I'm already using mdi parent/child forms. I have several child forms where there are automatic data refreshes being triggered by timers. I'm trying to stop these from firing when the user clicks on another form already open. Since the original post, I have everything working fine except for two forms that are instantiated from the same base form. The form activate and deactivate don't work consistently on these two. I'm guessing my problem has something to do with these two being based on the same form. More investigation to do!
|
|
|
|
|
Hi,
I need to populate a combobox, with a list of servers from the registry, I've written the following code, which I thought would work, however, when I run the project, I get the following error "NullReferenceException was unhandled, Object reference not set to an instance of an object."
This is the code I'm using, can anyone see where I may be going wrong?
private void Login_Load(object sender, EventArgs e)
{
string strKey = @"SOFTWARE\Microsoft\Microsoft SQL Server";
//if (IntPtr.Size == 8)
//{
// strKey = @"SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server";
//}
RegistryKey rkSqlServer = Registry.LocalMachine.OpenSubKey(strKey);
string[] instances = rkSqlServer.GetValue("InstalledInstances")
as string[];
if (instances.GetUpperBound(0) >= 0)
{
foreach (string element in instances)
if (element == "MSSQLSERVER")
{
lstServers.Items.Add(Environment.MachineName);
}
else
{
lstServers.Items.Add(Environment.MachineName + @"\" + element);
}
}
}
Thanks,
RB
|
|
|
|
|
RighteousBrother wrote: string[] instances = rkSqlServer.GetValue("InstalledInstances")
where do you get the error
Try stepping through with debug and chack the value of rkSqlServer after opensubkey, I'm betting there is no key returned.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How do the filtering of files in the WebBrowser. NET? I wish they control does not availed image files jpg, gif, swf ...
|
|
|
|
|
|
Hi all!
In my application I launch a third party application(AUT) to do some tests on it. From my application I launch the AUT in a separate thread so my application doesn't block. My application then analyzes the AUT in search for Clickable controls. I'm able to do this and no Thread has been thrown yet(please tell me if I'm being luck and I shouldn't be doing this).
But then I want to programatically perform a click on that control. The way I'm trying to do it is using UIAutomation. So I try to create a AutomationElement from the control handle. That's when an InvalidOperationException is thrown saying I can't perform that operation because I'm doing it from a different Thread.
I understand this and I've read the "Make Thread-Safe Calls to Windows Form Controls" How-To from Microsoft and the "What's up with BeginInvoke?" article but I haven't realize how to apply this knowledge to my problem. The reason is that the operation I'm trying to do is get the handle from a Control in a thir party application.
Am I missing something? can someone shed some light on me please?
Thanks,
José Tavares
|
|
|
|
|
jpsstavares wrote: But then I want to programatically perform a click on that control.
jpsstavares wrote: Am I missing something? can someone shed some light on me please?
Invoke works for a single process. It sounds like you have two processes so that is not going to work.
led mike
|
|
|
|
|
led mike wrote: Invoke works for a single process. It sounds like you have two processes so that is not going to work.
Well, actually no, I'm launching the application in another thread other than my main thread, but in the same process.
Regarding the programatically clicking of a control, is there a way to do it (with UIAutomation or anything else)?
|
|
|
|
|
jpsstavares wrote: Well, actually no, I'm launching the application in another thread other than my main thread, but in the same process.
No. Launching an application will produce a new process for that application. Unless you mean something different than "launching an application".
|
|
|
|
|
Yeah sorry, I wasn't explicit. I'm "launching" the application by Executing its assembly with AppDomain.CurrentDomain.ExecuteAssembly(filePath);
|
|
|
|
|
You have to click the Button on the same thread as it was created, otherwise you'll get this exception.
For normal applications that means that all UI components are created on the main (UI) thread and all calls to the UI coming from background threads have to be marshaled back to the UI thread, either by using Control.Invoke or a SynchronizationContext.
In your szenario, either run the 3rd party software on the UI thread and your tasks on a background thread, then you can use Invoke or a SynchronizationContext, or really be sure that everything you call to the 3rd party app is on the same worker thread.
Regards
Urs
-^-^-^-^-^-^-^-
no risk no funk
|
|
|
|
|
chieldHwnd= FindWindowEx(parentHwnd, chieldHwnd, "obj_EDIT", null);
int length = SendMessage(chieldHwnd, WM_GETTEXTLENGTH, (IntPtr)0, (IntPtr)0);
if (length > 0)
{
StringBuilder sb = new StringBuilder(length);
int numChars = SendMessage(chieldHwnd, WM_GETTEXT, (IntPtr)(length + 1), sb);
listBox1.Items.Add("in Textbox : " + sb);
}
this code takes a text in textbox but form has 2 textboxes and it takes last textbox's text how can i get the specified text.
username -------------
password -------------
both of them empty
and it takes allways password's text of textbox
thanks for everything i have...
|
|
|
|
|
You need to call FindWindowEx in a loop passing previous values as hwndChildAfter. The loop should end when FindWindowEx returns NULL.
By the way, winapi questions should be asked here: Visual C++ / MFC[^]
|
|
|
|
|
thx and i am sorry that i send wrong place (
thanks for everything i have...
|
|
|
|
|
private int GetChildHandle(int parent, string className)
{
int child = FindWindowEx(parent, IntPtr.Zero, className, null);
return child;
}
public void DoExternalWrite(string text)
{
int parent = FindWindow("obj_Form", "Adobe Creative Suite 2 by cvs/SSG");
int child = GetChildHandle(parent, "obj_BUTTON");// is a group box
//in this groupbox there are two text box
int child2 = GetChildHandle(child, "obj_EDIT");
SendMessage(child, WM_SETTEXT, IntPtr.Zero, text);
}
1 ---------
2 --------- it types mytext to this textbox why ??
thanks for everything i have...
|
|
|
|
|
|
private int GetChildHandle(int parent, string className)
{
int childafter=0;
while (childafter != null )
{
childafter = FindWindowEx(parent, childafter, className, null);
}
return childafter;
}
????????????
thanks for everything i have...
|
|
|
|
|
|
private int GetChildHandle(int parent, string className)
{
int childafter = FindWindowEx(parent, 0, className, null);
while (childafter != 0 )
{
childafter = FindWindowEx(parent, childafter, className, null);
listBox1.Items.Add(childafter);
}
return childafter;
}
parent takes the hwnd with findwindow()
classname i gave
when i use that functions, it gives the same . It add to listbox only second textbox hwnd, i am going to crayz ???
thanks for everything i have...
|
|
|
|
|
Why are you adding hwnds to the listbox? I thought you wanted to get text from them.
|
|
|
|