
thomas10001
Avatar/Signature-
Posts
57 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by thomas10001
-
No that look like a Fibonacci number series. I need the Fibonacci Heap which is a specialized data tree storages.
-
Where can I find an implementation of a Fibonacci Heap in C#? I have found one in C++, but it doesn't work properly for me.
-
Capture a hidden window without making it top level?
thomas10001 replied to thomas10001's topic in Graphics and Multimedia
I just found out that I did mix up the parameters FromHbitmap(hdcMem); should've been FromHbitmap(hbitmap); and it works fine! Thanks all! -
Capture a hidden window without making it top level?
thomas10001 replied to thomas10001's topic in Graphics and Multimedia
PrintWindow It seems that I should use PrintWindow I found the following code that I modified a bit. public static Bitmap captureHiddenWindow(IntPtr hwnd) { Bitmap bitmap = null; // Takes a snapshot of the window hwnd, stored in the memory device context hdcMem IntPtr hdc = PlatformInvokeGDI32.GetWindowDC(hwnd); if (hdc != IntPtr.Zero) { IntPtr hdcMem = PlatformInvokeGDI32.CreateCompatibleDC(hdc); if (hdcMem != IntPtr.Zero) { Rectangle rc; PlatformInvokeGDI32.GetWindowRect(hwnd,out rc); IntPtr hbitmap = PlatformInvokeGDI32.CreateCompatibleBitmap(hdc, rc.Width, rc.Height); if (hbitmap != IntPtr.Zero) { PlatformInvokeGDI32.SelectObject(hdcMem, hbitmap); Win32.PrintWindow(hwnd, hdcMem, 0); bitmap = System.Drawing.Image.FromHbitmap(hdcMem); PlatformInvokeGDI32.DeleteObject(hbitmap); } PlatformInvokeGDI32.DeleteObject(hdcMem); } PlatformInvokeGDI32.ReleaseDC(hwnd, hdc); } return bitmap; } I added the bitmap = System.Drawing.Image.FromHbitmap(hdcMem); because I need a bitmap returned. I got an exception when I tried it due to (I guess) hdcMem was negative. What do I do wrong here? Is there another way to use the dc that I am not aware of? -
I need to capture the image of a hidden window. Can this be done without making it the top level window? (I have already code to capture an image of the top level window. But that involves a lot of hiding and showing windows and creates problem with flickering and that the whole area is not redrawn and I do not always capture what I want.)
-
It sounds to me that you want to eavesdrop on the data flowing to a local process. This is going to be somewhat complicated. Example: most web Yes that is what I want to do. you will have to find what ports they are using and then passively capture the data -- which is probably not easily done in .NET. I have a software that displays the ports used. But it is possible to do? Should I listen to the port on my computer or on the remote end? Does it matter? Any hints how to do this?
-
I want to listen (read data) from a port that is in use on my computer. How can I do this? I want to find out what is sent to my port from another server. I have tried to make simple program using sockets. But I am not able to read any data. I have also tried to connect with telnet and other software but without any result. If I want to listen to a port that is in use sending/receiving data, should I connect to my local port or to the server is one question. Even if the port is in use, shouldn't I be able to connect to it and read the data somehow?
-
Hi I have a DataGrid with a DataSet as the DataSource. But I want to hide :cool: or supress the * row. There is a property allowNew but it seems that it is only available if the DataSource is a DataView. Is there a way to hide/supress the * row when having a DataSet as DataSource? Thomas
-
Hi I were able to get set the keys now and having gridstyles. And my delete and add works fine. Thanks. But I am not able to supress the * row with allowNew = false. Is there something that should be set on the datagrid as well to hide/supress it? Thomas
-
Hi Another reason I just rediscovered is that I have problem to set values (primary keys I have generated if I have datagridtablestyle attached) If I just have a plain dataset, no datagridtablestyle , I do this to set the values in the new row. DataSet ds1 = getDataSet(); BindingManagerBase myMgr = (CurrencyManager) BindingContext[ds1,tableName]; if(myMgr.Count > 0) { // This is the way to set a value in a row which has not been saved yet // and merged into the normal dataset DataRowView tempRowView = (DataRowView) myMgr.Current; if(tempRowView.IsNew) { tempRowView[columnName] = columnValue; System.Console.WriteLine(tableName+"."+columnName+" = "+columnValue); } } But when I have datagridtablestyle the above code doesn't work. I don't know how to get a DataRowView or similar if I have datagridtablestyle . If I knew how to do this I would give up the arraylist for now. Thomas
-
Hi I have made a framework where I want to be able to use other controls than a textbox in the grid. ie comboboxes etc. I thought this is the only? way to be able to use other controls. I also do not want the empty insertion row (marked *) which I don't know how to suppress. Thomas
-
I post a bit of the code here... I post part of the DataList and DataMapping I am using in my example in case the problem lies here. I have several int's double strings etc in my code to make it general. But here I have removed them to make the code shorter. public class DataList { private string myString1 = ""; private int myInt1 = 0; private bool isNullInt1 = true; public DataList() { } public string string1 { get {return myString1;} set {myString1 = value;} } public int int1 { get {return myInt1;} set {myInt1 = value;isNullInt1 = false;} } public bool isNullint1 { get {return isNullInt1;} } } } //----------------------------------------------------------- public class DataMapping { private StringCollection myMappingName; private StringCollection myMappingTable; private StringCollection myMappingColumn; private StringCollection myInternalName; private StringCollection myRelationName; private StringCollection myType; private ArrayList myIndex; private ArrayList dataLists; private int intUsed = 0; private int stringUsed = 0; private int myCount = 0; public ArrayList arrayList { get { return dataLists; } } public void clearDataList() { dataLists.Clear(); } public DataMapping() { this.dataLists = new ArrayList(); this.myMappingName = new StringCollection(); this.myMappingTable = new StringCollection(); this.myMappingColumn = new StringCollection(); this.myInternalName = new StringCollection(); this.myRelationName = new StringCollection(); this.myType = new StringCollection(); this.myIndex = new ArrayList(); } public int getNRelations() { return this.myRelationName.Count; } public string getRelationName(int item) { return this.myRelationName[item]; } public string getTableName(int item) { return this.myMappingTable[item]; } public void Add(string mappingName,string mappingTable,string mappingColumn,string type,string relationName) { addMapping(mappingName,mappingTable,mappingColumn,type); this.myRelationName.Add(relationName); } // mappingName a unique name for this mapping // mappingTable table to find the value // mappingColumn column in mappingTable to find value // type int or string (so far) public void Add(string mappingName,string mappingTable,string mappingColumn,string type) { addMapping(mappingName,mappingTable,mappingColumn,type); this.myRelationName.Add(""); } private void addMapping(string mappingName,string mappingTable,string mappingColumn,string type) { this.myCount++; this.myMappingName.Add(mappingName); this.myMappingTable.Add(mappingTable); this.myMappingColumn.Add(mappingColumn); this.myType.Add(type); // ie: we have "round" as the first mappingname and it is an int string internalName = ""; int index = 0; switch(type) { case "int": intUsed++; index = intUsed; internalName = "int"+intUsed; break; case "string": stringUsed++; index = stringUsed; internalName = "string"+stringUsed; break; } this.myInternalName.Add(internalName); this.myIndex.Add(index); } public string getInternalName(string mappingName) { // returns the internal name corresponding the mappingName int item = this.myMappingName.IndexOf(mappingName); return this.myInternalName[item]; } public string getMappingNameFromColumnName(string columnName) { int item = this.myMappingColumn.IndexOf(columnName); return this.myMappingName[item]; } public string getColumnName(int item) { return this.myMappingColumn[item]; } public string getInternal(int item) { return this.myInternalName[item]; } public string getMapping(int item) { return this.myMappingName[item]; } public string getType(int item) { return this.myType[item]; } public int getIndex(string mappingName) { int item = this.myMappingName.IndexOf(mappingName); int index = 0; index = (int)this.myIndex[item]; return index; } public void AddDataList() { dataLists.Add(new DataList()); } public void setValue(int row,string mappingName,int intValue) { switch(getIndex(mappingName)) { case 1: ((DataList)dataLists[row]).int1 = intValue; break; } } public void setValue(int row,string mappingName,string stringValue) { switch(getIndex(mappingName)) { case 1: ((DataList)dataLists[row]).string1 = stringValue; break; } } public int getIntValue(int row,string mappingName) { switch(getIndex(mappingName)) { case 1: return ((DataList)dataLists[row]).int1; } return 0; } public bool getIsNullInt(int row,string mappingName) { switch(getIndex(mappingName)) { case 1: return ((DataList)dataLists[row]).isNullint1; } return true; } public string getStringValue(int row,string mappingName) { switch(getIndex(mappingName)) { case 1: return ((DataList)dataLists[row]).string1; } return ""; } public int Count { get {return myCount;} } } } //----------------------------------------------------------- Code for columnstyles public void addDataMapping(string mappingName,string mappingTable,string mappingColumn,string type) { dataManager.addDataMapping(mappingName,mappingTable,mappingColumn,type); } public void addDataMapping(string mappingName,string mappingTable,string mappingColumn,string type,string relationName) { dataManager.addDataMapping(mappingName,mappingTable,mappingColumn,type,relationName); } public string getDataInternalName(string mappingName) { return dataManager.getDataInternalName(mappingName); } public void addDataGridTableStyle(DataGrid dataGrid) { gridTableStyle = new DataGridTableStyle(); gridTableStyle.DataGrid = dataGrid; gridTableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText; // if using dataMappings we have an ArrayList inside the DataMapping object // and mappingName must be "ArrayList" // otherwise mappingName is the name of tables[0] // since we then should only have one table if(this.getDataMapping().Count > 0) gridTableStyle.MappingName = "ArrayList"; else gridTableStyle.MappingName = getDataSet().Tables[0].TableName; dataGrid.TableStyles.Add(gridTableStyle); } public void addGridColumnStyle(string header,string mappingName,int width,bool readOnly,string columnType,string formatString) { DataGridTextBoxColumn column = new DataGridTextBoxColumn(); column.HeaderText = header; // check if we have dataMappings if(this.getDataMapping().Count > 0) column.MappingName = getDataInternalName(mappingName); // the the internal mapping name else column.MappingName = mappingName; // mapping name is the name itself column.Width = width; column.ReadOnly = readOnly; column.TextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.KeyDown); column.TextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.KeyUp); if(!formatString.Equals("")) column.Format = formatString; gridTableStyle.GridColumnStyles.Add(column); } //----------------------------------------------------------- Code to setup my datamapping and columnstyles for my datagrid addDataMapping("bedid","bed","bedid","int"); addDataMapping("roomid","bed","roomid","int"); addDataMapping("bedname","bed","bedname","string"); ... addDataGridTableStyle(this.grid); addGridColumnStyle("BedId","bedid",0,false,"TextBox",""); addGridColumnStyle("RoomId","roomid",0,false,"TextBox",""); addGridColumnStyle("Bed Name","bedname",80,false,"TextBox","");
-
I have a special class (DataMapping and DataList) for GridColumnStyles I use which is general so I don't have to have a hardcoded class for the items in the grid. I don't know if the problem could be in that code. But it doesn't feel like it is there. I could had posted it here unless it wasn't that much code.
-
I do both dm.arrayList.RemoveAt(removeAt); and this.BindingContext[ds,showTable].RemoveAt(removeAt); Is it correct that I would have to delete from the dataset as well or should it be handled automatically by the arrayList since its connected to the dataset. However before I do my Update of the dataset I have to copy the values over from my arrayList into the dataset. Is this really the correct way? Thomas
-
Hi I have a button on my form which calls my delete method. By the way when my grid is empty the headers don't show. Even though I have initialized the variables in the class that are used in the list. I read somewhere that this was required. Maybe this has something to do with this problem?!
-
-
Here is the exception I get. Caused by the "stubborn" Position pointing wrong ************** Exception Text ************** System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Windows.Forms.DataGrid.Edit(String instantText) at System.Windows.Forms.DataGrid.Edit() at System.Windows.Forms.DataGrid.OnEnter(EventArgs e) at System.Windows.Forms.Control.NotifyEnter() at System.Windows.Forms.ContainerControl.UpdateFocusedControl() :o
-
I was able to get the (New) adding new rows to work by using the code below. (It has a own defined class DataMapping and DataList which takes care of the columngrid styles and the values for the arraylist) After finding out that (from some other with similar problems) the datasource must be set to a dummy temporarily to get it to work. It is a bit awkward to have to set it to a dummy value! But I cannot get the delete command to work properly. If I delete the last row I get the arrayoutofbounds exception later if I click somewhere in the grid (not in the code below but somewhere undebuggable). But if there is only one single row (which is also last) I don't get the exception. The key seems to be the position. Position gets to -1 sometimes and even if I explicity set it to 0 it doesn't change. Anyone has a clue how to get the delete of the last row to work? If I delete the last row of course Position must be set to one row less otherwise it points outside the array. But I cannot get the position to be updated correctly in this case. private void updateSource(object dataSource) { System.Windows.Forms.DataGrid dg = ((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid(); dg.DataMember = ""; dg.DataSource = dataSource; dg.Refresh(); } private void addArrayList(DataMapping dm) { DataList dl = new DataList(); int pos = dm.arrayList.Add(dl); DataList dl2 = new DataList(); System.Collections.ArrayList al = new ArrayList(); al.Add(dl2); cs = (CurrencyManager)this.BindingContext[dm.arrayList]; if(cs.Position < 0) { this.updateSource(null); this.updateSource(al); // set dummy array this.updateSource(this.getCurrentUserControl().getDataMapping().arrayList); cs.Refresh(); cs.Position = pos; } cs.EndCurrentEdit(); cs.Position = pos; // moved to here 2005-01-22 cs.Refresh(); this.updateSource(null); this.updateSource(al); // set dummy array this.updateSource(this.getCurrentUserControl().getDataMapping().arrayList); } private void deleteArrayList(DataMapping dm,System.Data.DataSet ds,string showTable) { int removeAt = ((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().CurrentCell.RowNumber; dm.arrayList.RemoveAt(removeAt); //------------------------------------------------------- // try this to get rid of exception cs = (CurrencyManager)this.BindingContext[dm.arrayList]; int position = removeAt-1; cs.Refresh(); if(position < 0) position = 0; //------------------------------------------------------- this.BindingContext[ds,showTable].RemoveAt(removeAt); this.BindingContext[ds,showTable].Position = position; //------------------------------------------------------- // more test code // create a dummy array DataList dl = new DataList(); System.Collections.ArrayList al = new ArrayList(); al.Add(dl); this.updateSource(null); this.updateSource(al); // set dummy array this.updateSource(dm.arrayList); // set back original }
-
I have a DataGrid that I have bound to an ArrayList. If I create a new row and save right away everything is fine. But if I select any column in the new row BEFORE saving the first row I get an error message saying: -------------------------------------------------------------------- Error when committing the row to the original data store. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Do you want to correct the value? [Yes] [No] If I select [No] I get another errror message saying System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) -------------------------------------------------------------------- After I started to catch the CurrentCellChanged event for the DataGrid I found out that the CurrentRowIndex of DataGrid and Position of CurrencyManager is -1. And if I try to set the value to 0, it gets back to -1 automatically. :( If I would had another row in arraylist (ie if I saved right away, close my window and open it again) and then create a new row. Then I can click in another column without getting this error. I have searched alot on internet and found that there are other having the same problem. But have not got a solution that works. Someone suggested to reinitiate the datasource. Tried that with no success. Is there anyone here who know how to fix this problem? :confused:
-
Hi I have a strange bug that I get. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at System.Windows.Forms.CurrencyManager.CancelCurrentEdit() at System.Windows.Forms.DataGrid.HandleEndCurrentEdit() at System.Windows.Forms.DataGrid.OnLeave_Grid() at System.Windows.Forms.Control.InvokeMarshaledCallbacks() I cannot debug it! It is outside my control I believe. I have seen on a site that this is a possible bug from microsoft. But I do not know how to fix it. I cannot provide all code as a sample because it is too much to post here. But I have a datagrid that is feed by an ArrayList which is embedded into an object. The bug appear somewhere I cannot debug. If I run my code to make a new entry (New Button) and directly after run my Save code and close the whole window and then reopen the window I will not get the error. But if I directly after the New Button enter a value into my field and the save, then I will get the error above. A small part from my code from my New button. I do not know if this is to any help or if it is here there is a cause to the bug. Anyone have an idea how to find the bug or fix it? public void newClicked(UserControlBase callingControl,int callingControlRowClicked,int newRowClicked) { // If we have datamappings we must make a new row in arraylist of datamapping DataMapping dm = this.getCurrentUserControl().getDataMapping(); string showTableName = this.getCurrentUserControl().getShowTable(); if(dm.Count > 0) // are we using datamappings? { ((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataSource = null; cs = (CurrencyManager)this.BindingContext[dm.arrayList]; cs.EndCurrentEdit(); cs.List.Add(new DataList()); // could do dm.AddDataList() instead. its the same cs.Refresh(); // seem to be not needed! ((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataMember = ""; ((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataSource = this.getCurrentUserControl().getDataMapping().arrayList; }
-
I found a system function sendinput which is to simulate user interaction as keyboard input, mouse and hardware input. After lot of search on internet I found a bit of code which I added definitions from winuser.h and made a class Robot. It works for mouseinput as move and click etc. But I tried to add the struct for keybdinput. But I can't get it to work. Anyone got a clue what's wrong? Even the System.Windows.Forms.SendKeys.Send(string) doesn't work for me Here is the Robot class (The formatting got a bit unorganized when I pasted it) ------------------------------------------------------------------------ using System; using System.Runtime.InteropServices; namespace HoldemAdvice { /// <summary> /// Summary description for Robot. /// </summary> public class Robot { public static int MOUSEEVENTF_MOVE = 0x0001; /* mouse move */ public static int MOUSEEVENTF_LEFTDOWN = 0x0002; /* left button down */ public static int MOUSEEVENTF_LEFTUP = 0x0004; /* left button up */ public static int MOUSEEVENTF_RIGHTDOWN = 0x0008; /* right button down */ public static int MOUSEEVENTF_RIGHTUP = 0x0010; /* right button up */ public static int MOUSEEVENTF_MIDDLEDOWN = 0x0020; /* middle button down */ public static int MOUSEEVENTF_MIDDLEUP = 0x0040; /* middle button up */ public static int MOUSEEVENTF_XDOWN = 0x0080; /* x button down */ public static int MOUSEEVENTF_XUP = 0x0100; /* x button down */ public static int MOUSEEVENTF_WHEEL = 0x0800; /* wheel button rolled */ public static int MOUSEEVENTF_VIRTUALDESK = 0x4000; /* map to entire virtual desktop */ public static int MOUSEEVENTF_ABSOLUTE = 0x8000; /* absolute move */ public static int KEYEVENTF_EXTENDEDKEY = 0x0001; public static int KEYEVENTF_KEYUP = 0x0002; public static int KEYEVENTF_UNICODE = 0x0004; public static int KEYEVENTF_SCANCODE = 0x0008; public static int INPUT_MOUSE = 0; public static int INPUT_KEYBOARD = 1; public static int INPUT_HARDWARE = 2; public Robot() { } [DllImport("User32.dll", SetLastError=true)] public static extern int SendInput(int nInputs, ref INPUT pInputs, int cbSize); [DllImport("User32.dll", SetLastError=true)] public static extern int SendInput(int nInputs, ref KEYBOARD pInputs, int cbSize); public struct INPUT { public int type; public MOUSEINPUT mi; //public KEYBDINPUT ki; // doesn't work when this is declared here } // making another struct to use when keyboard inputs public struct KEYBOARD { public int type; public KEYBDINPUT ki; } public struct MOUSEINPUT { public int dx; public int dy; public int mouseData; public int dwFlags; public int time; public int dwExtraInfo; } public struct KEYBDINPUT { public int wVK; public int wScan; public int dwFlags; public int time; public int dwExtraInfo; } public int sendinput(ref INPUT input) { // Call the API int resSendInput; resSendInput = SendInput(1, ref input, Marshal.SizeOf(input)); if (resSendInput == 0 || Marshal.GetLastWin32Error() != 0) System.Diagnostics.Debug.WriteLine(Marshal.GetLastWin32Error()); return resSendInput; } public int sendinput(ref KEYBOARD input) { // Call the API int resSendInput; resSendInput = SendInput(1, ref input, Marshal.SizeOf(input)); if (resSendInput == 0 || Marshal.GetLastWin32Error() != 0) System.Diagnostics.Debug.WriteLine(Marshal.GetLastWin32Error()); return resSendInput; } } } ---------------------------------------------------------------------- Here is my calls to Robot Robot robot = new Robot(); // move the mouse to (50,445) (where I have a textfield for testing) Robot.INPUT input = new Robot.INPUT(); input.type = Robot.INPUT_MOUSE; input.mi.dx = 50-System.Windows.Forms.Cursor.Position.X;// relative movements! input.mi.dy = 445-System.Windows.Forms.Cursor.Position.Y; input.mi.dwFlags = Robot.MOUSEEVENTF_MOVE; robot.sendinput(ref input); // make a left mouse down input.mi.dwFlags = Robot.MOUSEEVENTF_LEFTDOWN; robot.sendinput(ref input); // make a left mouse up input.mi.dwFlags = Robot.MOUSEEVENTF_LEFTUP; robot.sendinput(ref input); // now my text field got the focus // try to enter a (65) in the text field. But no result. Robot.KEYBOARD input2 = new Robot.KEYBOARD(); input2.type = Robot.INPUT_KEYBOARD; //input2.ki.wVK = 65;// have tried both wVK and wScan but no result. What input2.ki.wScan = 65;// can be wrong? input2.ki.dwFlags = Robot.KEYEVENTF_SCANCODE; robot.sendinput(ref input2);
-
I found how to move the mouse and do keyboard input. But not how to emulate a mouse click. Anyone who knows? Is there any way to perform a mouse click using the keyboard? That would solve my problem. // to move mouse System.Windows.Forms.Cursor.Position = new System.Drawing.Point(95,105); // to do keyboard input System.Windows.Forms.SendKeys.Send("^a"); // Ctrl-a
-
Is there any class or functions to do Demo playbacks or GUI testing? What I need to do is to interact with another software's (a compiled exe) userinterface! From my program I need to be able to move and perform clicks in the other software and to perform keyboard input, ie to copy data from a text field in the other software's userinterface in to my software for processing. I saw that sun java has a robot class is there any similar things in .NET? Thomas
-
I have the framework installed on a computer with Win98. Now I have compiled my software on my other computer (WinXP) and also created a setup. But when I run the software on win98 I get an error saying I dont have the right version of MDAC. It says it should be mdac 6.01 or so. Do I have to search for the file on internet, or is it a way to include it in the setup for my software I created? How can I do this or where can I find the proper version of MDAC?
-
I found the solution. Since I am using an ArrayList as datasource I had to set DataSource = null before adding the new row otherwise no visual effect. Then it has to be set to the arraylist after wards, which I already knew.