|
Set KeyPreview property of your form true and register to the KeyPress event of your form.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
How can i convert any date and time into this representation:
ddMMyyy hhMMss
I need this so i can save a file with a name of the current date and time.
I tried a few things with TimeSpan. Im not getting through
Can anyone help me with this?
Thanks in advance
|
|
|
|
|
DateTime now = DateTime.Now;
string now = now.ToString("ddMMyyy HHmmss");
You can use any DateTime object you created. This one here uses the current date and time ("Now")
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
Thank you Greeeg!
That worked!
|
|
|
|
|
I know this problem was solved, but I would highly recommend using yyyyMMdd so the files will be in chronological order.
|
|
|
|
|
Does Windows explorer (among others) sort them in that order? Good to know.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi
i load an image on label control.but with tab control ,control is not selected .
How can i make this control selected with tab control
|
|
|
|
|
Hello, I need to do some gui automation work with Java from C#.
I apologize, there are two ways:
1/ throught .net 3.0 System.Windows.Automation,
It seems to be incompatible with Java.
2/ throught Java Access Bridge throught interop with functions in WindowsAccessBridge.dll
However, all called functions /isJavaWindow, getAccessibleContextAt, getAccessibleContextFromHWND, getAccessibleContextWithFocus/ are not working for me.
Does anybody have any examples ?
Gagy
|
|
|
|
|
Hi Greg,
Please use below code
using System.Runtime.InteropServices;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
namespace JabApiLib.JavaAccessBridge
{
public static class JabHelpers
{
public class AccessibleTreeItem
{
public String name; // the AccessibleName of the object
public String description; // the AccessibleDescription of the object
public String role; // localized AccesibleRole string
public String role_en_US; // AccesibleRole string in the en_US locale
public String states; // localized AccesibleStateSet string (comma separated)
public String states_en_US; // AccesibleStateSet string in the en_US locale (comma separated)
public Int32 indexInParent; // index of object in parent
public Int32 childrenCount; // # of children, if any
public Int32 x; // screen coords in pixel
public Int32 y; // "
public Int32 width; // pixel width of object
public Int32 height; // pixel height of object
public Boolean accessibleComponent; // flags for various additional
public Boolean accessibleAction; // Java Accessibility interfaces
public Boolean accessibleSelection; // FALSE if this object doesn't
public Boolean accessibleText; // implement the additional interface
public Boolean accessibleInterfaces;
public string textValue;
public string m_msgStr;
public List<accessibletreeitem> children;
public AccessibleTreeItem()
{
children = new List<accessibletreeitem>();
}
public AccessibleTreeItem(AccessibleContextInfo accessibleContextInfo)
: this()
{
this.name = accessibleContextInfo.name; // the AccessibleName of the object
this.description = accessibleContextInfo.description; // the AccessibleDescription of the object
this.role = accessibleContextInfo.role; // localized AccesibleRole string
this.role_en_US = accessibleContextInfo.role_en_US; // AccesibleRole string in the en_US locale
this.states = accessibleContextInfo.states; // localized AccesibleStateSet string (comma separated)
this.states_en_US = accessibleContextInfo.states_en_US; // AccesibleStateSet string in the en_US locale (comma separated)
this.indexInParent = accessibleContextInfo.indexInParent; // index of object in parent
this.childrenCount = accessibleContextInfo.childrenCount; // # of children, if any
this.x = accessibleContextInfo.x; // screen coords in pixel
this.y = accessibleContextInfo.y; // "
this.width = accessibleContextInfo.width; // pixel width of object
this.height = accessibleContextInfo.height; // pixel height of object
this.accessibleComponent = accessibleContextInfo.accessibleComponent; // flags for various additional
this.accessibleAction = accessibleContextInfo.accessibleAction; // Java Accessibility interfaces
this.accessibleSelection = accessibleContextInfo.accessibleSelection; // FALSE if this object doesn't
this.accessibleText = accessibleContextInfo.accessibleText; // implement the additional interface
this.accessibleInterfaces = accessibleContextInfo.accessibleInterfaces;
}
public Rectangle Bounds
{
get
{
return new Rectangle(this.x, this.y, this.width, this.height);
}
}
public Int32 SquarePixels
{
get { return this.x * this.y; }
}
}
internal class ItemComparer : IComparer<accessibletreeitem>
{
#region IComparer<ireader> Members
public int Compare(AccessibleTreeItem x, AccessibleTreeItem y)
{
if (x.SquarePixels < y.SquarePixels)
{
return 1;
}
else if (x.SquarePixels > y.SquarePixels)
{
return -1;
}
else
{
return 0;
}
}
#endregion
}
private static List<accessibletreeitem> screenContents = new List<accessibletreeitem>();
public static string screenContentsString = string.Empty;
public static int g_vmId;
public static IntPtr g_acPtr;
public static AccessibleTreeItem GetComponentTree(IntPtr hWnd, out Int32 vmID)
{
screenContents.Clear();
screenContentsString = string.Empty;
AccessibleTreeItem accessibleTreeItem = new AccessibleTreeItem();
vmID = 0;
//String temp = "2B0586";
//hWnd = Marshal.StringToHGlobalAuto(temp);
//bool result = JabApi.initializeAccessBridge();
IntPtr versionInfo;
IntPtr acPtr1 = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleContextInfo()));
bool result1 = JabApi.getVersionInfo(34, acPtr1);
if (JabApi.isJavaWindow(hWnd) == 1)
{
MessageBox.Show("Java Handle found");
JabApi.MouseClickedDelegate mcd = new JabApi.MouseClickedDelegate(HandleMouseClicked);
JabApi.setMouseClickedFP(mcd);
JabApi.FocusLostDelegate mcd1 = new JabApi.FocusLostDelegate(FocusLostDelegateEvent);
JabApi.setFocusLostFP(mcd1);
JabApi.FocusGainedDelegate mcd2 = new JabApi.FocusGainedDelegate(FocusGainedDelegateEvent);
JabApi.setFocusGainedFP(mcd2);
JabApi.PopupMenuWillBecomeInvisibleDelegate mcd3 = new JabApi.PopupMenuWillBecomeInvisibleDelegate(PopupMenuWillBecomeInvisibleDelegateEvent);
JabApi.setPopupMenuWillBecomeInvisibleFP(mcd3);
JabApi.PopupMenuWillBecomeVisibleDelegate mcd4 = new JabApi.PopupMenuWillBecomeVisibleDelegate(PopupMenuWillBecomeVisibleDelegateEvent);
JabApi.setPopupMenuWillBecomeVisibleFP(mcd4);
JabApi.PropertyActiveDescendentChangeDelegate mcd5 = new JabApi.PropertyActiveDescendentChangeDelegate(PropertyActiveDescendentChangeDelegateEvent);
JabApi.setPropertyActiveDescendentChangeFP(mcd5);
JabApi.PropertySelectionChangeDelegate mcd6 = new JabApi.PropertySelectionChangeDelegate(PropertySelectionChangeDelegateEvent);
JabApi.setPropertySelectionChangeFP(mcd6);
JabApi.PropertyStateChangeDelegate mcd7 = new JabApi.PropertyStateChangeDelegate(PropertyStateChangeDelegateEvent);
JabApi.setPropertyStateChangeFP(mcd7);
JabApi.PropertyTableModelChangeDelegate md8 = new JabApi.PropertyTableModelChangeDelegate(PropertyTableModelChangeDelegateEvent);
JabApi.setPropertyTableModelChangeFP(md8);
JabApi.PropertyValueChangeDelegate md9 = new JabApi.PropertyValueChangeDelegate(PropertyValueChangeDelegateEvent);
JabApi.setPropertyValueChangeFP(md9);
unsafe
{
IntPtr acPtr;
try
{
MessageBox.Show("calling getAccessibleContextFromHWND");
if (JabApi.getAccessibleContextFromHWND(hWnd, out vmID, out acPtr))
{
g_vmId = vmID;
g_acPtr = acPtr;
AccessibleContextInfo ac = new AccessibleContextInfo();
accessibleTreeItem = GetAccessibleContextInfo(vmID, acPtr, out ac, null, 0, string.Empty); // RECURSION SEED
MessageBox.Show("getAccessibleContextFromHWND");
return accessibleTreeItem;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
else
{
MessageBox.Show("No Java Handle");
//m_msgStr = "Window handle is not for Java";
//Debug.Print(m_msgStr);
}
return null;
}
public static AccessibleContextInfo GetAccessibleContextInfo(Int32 vmID, IntPtr ac)
{
AccessibleContextInfo aci = new AccessibleContextInfo(); //This will be the info that we return.
// Allocate global memory space for the size of AccessibleContextInfo and store the address in acPtr
IntPtr acPtr = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleContextInfo()));
try
{
//Convert the pointer to an actual object.
Marshal.StructureToPtr(new AccessibleContextInfo(), acPtr, true);
//getAccessibleContextInfo() returns true or false, depending on whether it succeeds.
if (JabApi.getAccessibleContextInfo(vmID, ac, acPtr))
{
aci = (AccessibleContextInfo)Marshal.PtrToStructure(acPtr, typeof(AccessibleContextInfo));
//Check that the info isn't null, and then return.
if (!ReferenceEquals(aci, null))
{
return aci;
}
}
}
catch
{
return new AccessibleContextInfo();
}
return new AccessibleContextInfo();
}
public static String Venkatesh(IntPtr hWnd, string stringToSearchAndClick)
{
int vmId;
IntPtr acPtr1;
AccessibleTreeItem accessibleTreeItem;
if (JabApi.getAccessibleContextFromHWND(hWnd, out vmId, out acPtr1))
{
AccessibleContextInfo ac = new AccessibleContextInfo();
accessibleTreeItem = GetItemsFromWindow(vmId, acPtr1, out ac, null, 0, string.Empty, stringToSearchAndClick); // RECURSION SEED
MessageBox.Show("getAccessibleContextFromHWND");
}
//AccessibleContextInfo ac = new AccessibleContextInfo();
//MessageBox.Show("Searching for " + text);
//GetItemsFromWindow(g_vmId, g_acPtr, out ac, null, 0, string.Empty); // RECURSION SEED
return "";
}
public static AccessibleTextItemsInfo GetAccessibleTextInfo(Int32 vmID, IntPtr ac)
{
//Reserve memory
IntPtr ati = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleTextItemsInfo()));
//Call DLL.
JabApi.getAccessibleTextItems(vmID, ac, ati, 0);
//Creat object
AccessibleTextItemsInfo atInfo = (AccessibleTextItemsInfo)Marshal.PtrToStructure(ati, typeof(AccessibleTextItemsInfo));
//Free memory
if (ati != IntPtr.Zero)
{
Marshal.FreeHGlobal(ati);
}
return atInfo;
}
private static AccessibleTreeItem GetItemsFromWindow(Int32 vmID, IntPtr currentPtr, out AccessibleContextInfo currentContext, AccessibleTreeItem parentItem, int level, string lineage, string stringToSearchAndClick)
{
IntPtr acPtr = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleContextInfo()));
try
{
//MessageBox.Show("In GetAccessibleContextInfo");
Marshal.StructureToPtr(new AccessibleContextInfo(), acPtr, true);
if (JabApi.getAccessibleContextInfo(vmID, currentPtr, acPtr))
{
currentContext = (AccessibleContextInfo)Marshal.PtrToStructure(acPtr, typeof(AccessibleContextInfo));
if (!ReferenceEquals(currentContext, null))
{
AccessibleTreeItem newItem = BuildAccessibleTree(currentContext, parentItem);
if (!ReferenceEquals(newItem, null))
{
string treeInfo = Repeat("\t", level) + currentContext.name;
//Checks to see if current object has any text items.
unsafe
{
if (currentContext.name == stringToSearchAndClick)
{
IntPtr actions;
Int32 failure1;
AccessibleActionsToDo actions_to_do;
int temp2 = Marshal.SizeOf(new AccessibleActions());
IntPtr accessible_action_ptr = Marshal.AllocHGlobal(temp2);
JabApi.getAccessibleActions(vmID, currentPtr, accessible_action_ptr);
AccessibleActions actions1 = (AccessibleActions)Marshal.PtrToStructure(accessible_action_ptr, typeof(AccessibleActions));
actions_to_do.actionsCount = actions1.actionsCount;
actions_to_do.actions = actions1.actionInfo;
int temp3 = Marshal.SizeOf(new AccessibleActionsToDo());
IntPtr accessible_action_ptr1 = Marshal.AllocHGlobal(temp3);
JabApi.MouseClickedDelegate mcd1 = new JabApi.MouseClickedDelegate(HandleMouseClicked);
int fp = 0;
Marshal.StructureToPtr(actions_to_do, accessible_action_ptr1, false);
JabApi.doAccessibleActions(vmID, currentPtr, accessible_action_ptr1, &failure1);
IntPtr Window_Handle = JabApi.getHWNDFromAccessibleContext(vmID, currentPtr);
}
if (currentContext.role == "table")
{
IntPtr tableInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleTableInfo()));
Marshal.StructureToPtr(new AccessibleTableInfo(), tableInfoPtr, true);
if (JabApi.getAccessibleTableInfo(vmID, currentPtr, tableInfoPtr) == false)
{
MessageBox.Show("Failed...");
//appendToBuffer(buffer, bufsize, "\r\nERROR: GetAccessibleContextInfo failed ", bufsize);
}
else
{
AccessibleTableInfo tableInfo;
tableInfo = (AccessibleTableInfo)Marshal.PtrToStructure(tableInfoPtr, typeof(AccessibleTableInfo));
for (int i = 0; i < tableInfo.rowCount; i++)
{
for (int j = 0; j < tableInfo.columnCount; j++)
{
IntPtr tableCellInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleTableCellInfo()));
Marshal.StructureToPtr(new AccessibleTableCellInfo(), tableCellInfoPtr, true);
if (JabApi.getAccessibleTableCellInfo(vmID, tableInfo.accessibleTable, i, j, tableCellInfoPtr) == false)
{
MessageBox.Show("Failed...");
}
else
{
JabApi.setPropertyValueChangeFP(PropertyValueChangeDelegateEvent);
AccessibleTableCellInfo tableCellInfo;
tableCellInfo = (AccessibleTableCellInfo)Marshal.PtrToStructure(tableCellInfoPtr, typeof(AccessibleTableCellInfo));
IntPtr cellACInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleContextInfo()));
Marshal.StructureToPtr(new AccessibleContextInfo(), cellACInfoPtr, true);
if (JabApi.getAccessibleContextInfo(vmID, tableCellInfo.accessibleContext, cellACInfoPtr) == false)
{
MessageBox.Show("Failed");
}
AccessibleContextInfo cellACInfo;
cellACInfo = (AccessibleContextInfo)Marshal.PtrToStructure(cellACInfoPtr, typeof(AccessibleContextInfo));
bool retVal = false;
if (cellACInfo.name == "234")
{
PropertyTableModelChangePackage fp = new PropertyTableModelChangePackage();
fp.vmID = vmID;
fp.AccessibleContextSource = tableCellInfo.accessibleContext;
fp.oldValue = "";
fp.oldValue = "";
JabApi.setPropertyTableModelChangeFP(fp);
retVal = JabApi.setTextContents(vmID, tableCellInfo.accessibleContext, "99999");
MessageBox.Show(cellACInfo.name);
}
}
}
}
}
}
}
screenContentsString += treeInfo + Environment.NewLine;
Debug.Print(treeInfo);
//Start collecting children
int nextLevel = level + 1;
for (int i = 0; i < currentContext.childrenCount; i++)
{
string lineageInfo = Repeat("\t", level) + level.ToString() + " Child " + i.ToString() + " Lineage = {" + lineage + "}";
screenContentsString += lineageInfo + Environment.NewLine;
Debug.Print(lineageInfo);
string currentlineage;
if (lineage == string.Empty)
currentlineage = i.ToString();
else
currentlineage = lineage + ", " + i.ToString();
if (currentContext.role_en_US != "unknown" && currentContext.states_en_US.Contains("visible")) // Note the optomization here, I found this get me to an acceptable speed
{
AccessibleContextInfo childContext = new AccessibleContextInfo();
IntPtr childPtr = JabApi.getAccessibleChildFromContext(vmID, currentPtr, i);
GetItemsFromWindow(vmID, childPtr, out childContext, newItem, nextLevel, currentlineage, stringToSearchAndClick);
//TODO: Not sure when or where to release the java objects, the JVM will leak memory until released
//JabApi.releaseJavaObject(vmID, childPtr);
}
}
}
return newItem;
}
}
else
{
currentContext = new AccessibleContextInfo();
}
}
finally
{
if (acPtr != IntPtr.Zero)
Marshal.FreeHGlobal(acPtr);
//TODO: Not sure when or where to release the java objects, the JVM will leak memory until released
//JabApi.releaseJavaObject(vmID, currentPtr);
}
return null;
}
private static AccessibleTreeItem GetAccessibleContextInfo(Int32 vmID, IntPtr currentPtr, out AccessibleContextInfo currentContext, AccessibleTreeItem parentItem, int level, string lineage)
{
unsafe
{
// Allocate global memory space for the size of AccessibleContextInfo and store the address in acPtr
IntPtr acPtr = Marshal.AllocHGlobal(Marshal.SizeOf(new AccessibleContextInfo()));
try
{
//MessageBox.Show("In GetAccessibleContextInfo");
Marshal.StructureToPtr(new AccessibleContextInfo(), acPtr, true);
if (JabApi.getAccessibleContextInfo(vmID, currentPtr, acPtr))
{
currentContext = (AccessibleContextInfo)Marshal.PtrToStructure(acPtr, typeof(AccessibleContextInfo));
if (!ReferenceEquals(currentContext, null))
{
AccessibleTreeItem newItem = BuildAccessibleTree(currentContext, parentItem);
if (!ReferenceEquals(newItem, null))
{
//Checks to see if current object has any text items.
if (currentContext.accessibleText == true)
{
AccessibleTextItemsInfo textItem;
//Gets text items.
textItem = GetAccessibleTextInfo(vmID, currentPtr);
newItem.textValue = textItem.sentence;
string treeInfo = Repeat("\t", level) + currentContext.name + " = \"" + textItem.sentence + "\"";
screenContentsString += treeInfo + Environment.NewLine;
Debug.Print(treeInfo);
}
else
{
string treeInfo = Repeat("\t", level) + currentContext.name + " : " + currentContext.role;
if (currentContext.name.Contains("14.20.22"))
{
MessageBox.Show(currentContext.name + " : " + currentContext.role);
JabApi.setTextContents(vmID, currentPtr, "12.0.0");
}
if (currentContext.role == "text")
{
Debug.Print(treeInfo);
}
if (currentContext.role == "combo box")
{
IntPtr actions;
Int32 failure = 512 ;
AccessibleActionsToDo actions_to_do;
int temp2 = Marshal.SizeOf(new AccessibleActions());
IntPtr accessible_action_ptr = Marshal.AllocHGlobal(temp2);
JabApi.getAccessibleActions(vmID, currentPtr, accessible_action_ptr);
AccessibleActions actions1 = (AccessibleActions)Marshal.PtrToStructure(accessible_action_ptr, typeof(AccessibleActions));
actions_to_do.actionsCount = actions1.actionsCount;
actions_to_do.actions = actions1.actionInfo;
int temp3 = Marshal.SizeOf(new AccessibleActionsToDo());
IntPtr accessible_action_ptr1 = Marshal.AllocHGlobal(temp3);
JabApi.MouseClickedDelegate mcd1 = new JabApi.MouseClickedDelegate(HandleMouseClicked);
int fp = 0;
JabApi.setMouseClickedFP(null);
Marshal.StructureToPtr(actions_to_do, accessible_action_ptr1, false);
JabApi.doAccessibleActions(vmID, currentPtr, accessible_action_ptr1, &failure);
IntPtr Window_Handle = JabApi.getHWNDFromAccessibleContext(vmID, currentPtr);
}
screenContentsString += treeInfo + Environment.NewLine;
Debug.Print(treeInfo);
}
//Start collecting children
int nextLevel = level + 1;
for (int i = 0; i < currentContext.childrenCount; i++)
{
string lineageInfo = Repeat("\t", level) + level.ToString() + " Child " + i.ToString() + " Lineage = {" + lineage + "}";
screenContentsString += lineageInfo + Environment.NewLine;
Debug.Print(lineageInfo);
string currentlineage;
if (lineage == string.Empty)
currentlineage = i.ToString();
else
currentlineage = lineage + ", " + i.ToString();
if (currentContext.role_en_US != "unknown" && currentContext.states_en_US.Contains("visible")) // Note the optomization here, I found this get me to an acceptable speed
{
AccessibleContextInfo childContext = new AccessibleContextInfo();
IntPtr childPtr = JabApi.getAccessibleChildFromContext(vmID, currentPtr, i);
GetAccessibleContextInfo(vmID, childPtr, out childContext, newItem, nextLevel, currentlineage);
//TODO: Not sure when or where to release the java objects, the JVM will leak memory until released
//JabApi.releaseJavaObject(vmID, childPtr);
}
}
}
return newItem;
}
}
else
{
currentContext = new AccessibleContextInfo();
}
}
finally
{
if (acPtr != IntPtr.Zero)
Marshal.FreeHGlobal(acPtr);
//TODO: Not sure when or where to release the java objects, the JVM will leak memory until released
//JabApi.releaseJavaObject(vmID, currentPtr);
}
}
return null;
}
public static string Repeat(string s, int count)
{
var _s = new System.Text.StringBuilder().Insert(0, s, count).ToString();
return _s;
}
private static AccessibleTreeItem BuildAccessibleTree(AccessibleContextInfo acInfo, AccessibleTreeItem parentItem)
{
if (!ReferenceEquals(acInfo, null))
{
AccessibleTreeItem item = new AccessibleTreeItem(acInfo);
if (!ReferenceEquals(parentItem, null))
{
screenContents.Add(item);
parentItem.children.Add(item);
}
return item;
}
return null;
}
static void HandleMouseClicked(System.Int32 vmID, IntPtr jevent, IntPtr ac)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void FocusLostDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void FocusGainedDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void PopupMenuWillBecomeInvisibleDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void PopupMenuWillBecomeVisibleDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void PropertyActiveDescendentChangeDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac,
IntPtr oldActiveDescendent, IntPtr newActiveDescendent)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void PropertySelectionChangeDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void PropertyStateChangeDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac,
[MarshalAs(UnmanagedType.LPWStr)] string oldState, [MarshalAs(UnmanagedType.LPWStr)] string newState)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void PropertyTableModelChangeDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac, IntPtr oldValue, IntPtr newValue)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
static void PropertyValueChangeDelegateEvent(System.Int32 vmID, IntPtr jevent, IntPtr ac,
[MarshalAs(UnmanagedType.LPWStr)] string oldValue, [MarshalAs(UnmanagedType.LPWStr)] string newValue)
{
JabApi.releaseJavaObject(vmID, ac);
JabApi.releaseJavaObject(vmID, jevent);
}
}
}
|
|
|
|
|
Hi ,
How to click a button using Java Access Bridge with WindowsAccessBridge.dll (C#.net). Please share me complete code for below two classes.
1)AccessibleActionsToDo
2)AccessibleActions
AccessibleActionsToDo actions_to_do;
int temp2 = Marshal.SizeOf(new AccessibleActions());
IntPtr accessible_action_ptr = Marshal.AllocHGlobal(temp2);
JabApi.getAccessibleActions(vmID, currentPtr, accessible_action_ptr);
AccessibleActions actions1 = (AccessibleActions)Marshal.PtrToStructure(accessible_action_ptr, typeof(AccessibleActions));
actions_to_do.actionsCount = actions1.actionsCount;
actions_to_do.actions = actions1.actionInfo;
int temp3 = Marshal.SizeOf(new AccessibleActionsToDo());
IntPtr accessible_action_ptr1 = Marshal.AllocHGlobal(temp3);
JabApi.MouseClickedDelegate mcd1 = new JabApi.MouseClickedDelegate(HandleMouseClicked);
int fp = 0;
JabApi.setMouseClickedFP(null);
Marshal.StructureToPtr(actions_to_do, accessible_action_ptr1, false);
JabApi.doAccessibleActions(vmID, currentPtr, accessible_action_ptr1, &failure);
IntPtr Window_Handle = JabApi.getHWNDFromAccessibleContext(vmID, currentPtr);
|
|
|
|
|
Hi,
Iam new to c# can anyone help me to find the no of occurance of a string eg("C") in a set of string eg("Couch") without any loops.
thank you,
Regards
Praveen
|
|
|
|
|
You could split the string on the substring you're looking for, then see how many items are in your array. A regex would also work.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Both methods outlined by CG would work, I'd go for the Regex one as it's more powerful and infintely more configurable should your requirements change.
If you need any help with Regexs this[^] site is very good, if that doesn't help then just ask.
Just Google it.
Failing that try phoning
|
|
|
|
|
Use String.Split to find the number of character count.
for example :
"infintely".Split("i".ToCharArray()); returns an array of count 3.
so number of i in "infintely" is 2.
Ashish
|
|
|
|
|
Wasn't that meant to be for the OP?
Just Google it.
Failing that try phoning
|
|
|
|
|
You can replace the string that you are looking for with an empty string, and check the length of the original string with the resulting string. Divide the difference in length by the number of characters in the string that you are looking for to get the number of occurances.
---
b { font-weight: normal; }
|
|
|
|
|
hi friend
how to open GPRS Connection through my pocket pc 2003 (pda) in c#
i have to do two things first i have to open GPRS CONNECTION programmatically in c# then i have to send dataset on server side web service will receive the dataset.
if any one have sample code or snippt how to open gprs connection please
so please help me as soon as possible.
thanks
raj
india
BIG
BIG
|
|
|
|
|
Hello,
I want to be able to update a connection string that I have in my app.config file. This is so that the customer can change the connection to another server or database.
Can anyone give me any example code. I am using C# 2005.
Many thanks in advance,
Steve
|
|
|
|
|
In .NET 2005 there's a new configuration framework that simplifies writing config settings per user or per app. If you add a settings file to your project, you can add settings and then access them directly ( they get written to the file for you ). Check the MSDN for more info. One thing, - I created a new settings file and it didn't work, the file you need is under a folder called 'profile' and you actually access it from Profile.Settings.Default.Propname, where Propname is the setting you created.
Your other option is to open the app.config using an XmlDocument and changing the values using XPath/DOM code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello
I am using my.settings to create a application scope connection string.
The customer would like to change this if they want to connect to another database, and this should update the app.config file with the updated connection string.
My problem I have into the setting and create a connection string (easy). But I don't know and can't find out to update and save the new connection string.
My.Settings.cnnString = "This is example connection" 'Error read-only property
I am using vb.net 2005
Can anyone help,
Thanks in advance,
Steve
|
|
|
|
|
|
Hello
I am using my.settings to create a application scope connection string.
The customer would like to change this if they want to connect to another database, and this should update the app.config file with the updated connection string.
My problem I have into the setting and create a connection string (easy). But I don't know and can't find out to update and save the new connection string.
My.Settings.cnnString = "This is example connection" 'Error read-only property
Can anyone help,
I got this code and it seem it would work. However, there is a problem with the code. I get a "Object reference not set to an instance of an object."
Here my code.
[code]
Dim config As Configuration.Configuration = Configuration.ConfigurationManager.OpenExeConfiguration(Configuration.ConfigurationUserLevel.None)
config.ConnectionStrings.ConnectionStrings("ServiceMasterConnectionString").ConnectionString = "This is new connection " 'Error -
config.Save()
[/code]
Thanks in advance,
Steve
|
|
|
|
|
As I said there's not much point in asking here since we're C# developers and I for one have developed in VB.NET but not recently so don't know about My.Settings, people in the VB.NET forum should know.
Just Google it.
Failing that try phoning
|
|
|
|
|
Hello
I am using my.settings to create a application scope connection string.
The customer would like to change this if they want to connect to another database, and this should update the app.config file with the updated connection string.
My problem I have into the setting and create a connection string (easy). But I don't know and can't find out to update and save the new connection string.
My.Settings.cnnString = "This is example connection" 'Error read-only property
Can anyone help,
I got this code and it seem it would work. However, there is a problem with the code. I get a "Object reference not set to an instance of an object."
Here my code.
<br />
Dim config As Configuration.Configuration = Configuration.ConfigurationManager.OpenExeConfiguration(Configuration.ConfigurationUserLevel.None)<br />
config.ConnectionStrings.ConnectionStrings("ServiceMasterConnectionString").ConnectionString = "This is new connection " 'Error - <br />
config.Save()<br />
Thanks in advance,
Steve
|
|
|
|
|
Christian Graus wrote: the file you need is under a folder called 'profile' and you actually access it from Profile.Settings.Default.Propname,
Oh, so you got it to work finally?
|
|
|
|
|