|
If you decompile Graphics.CopyScreen with Reflector you can see it's quite simple
DeviceContext context = DeviceContext.FromHwnd(IntPtr.Zero))
SafeNativeMethods.BitBlt(...)
I don't see how you can improve on that...
And I believe VNC does that the 1st time then plug a Window Hook on the WM_PAINT event to repaint just what's needed... (through GDI, miss the DirectX stuff)
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi,
hooking WM_PAINT sounds like a good way, but how is it done? Is every application hooked or is there some über-hook to catch all redraws appearing?
Thank you,
Stevie
Greetings,
Stephan Eberle
hawke@deltacity.org
|
|
|
|
|
problem is.. you can't do WM_PAIN hook in C# (in fact I'm not sure you can hook WM_PAINT) but anyway, here are some links:
Global Windows Hooks[^]
http://msdn.microsoft.com/en-us/library/ms997537.aspx[^]
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Thank you,
this looks like fun, ... not...
I'll try to implement GetMessage-hooking. Seems that's the best approach (to me)...
Thank you for your help!
Best regards,
Stevie
Greetings,
Stephan Eberle
hawke@deltacity.org
|
|
|
|
|
hello,
I would like to ask where does I still get this run time error
"Syntax error in INSERT INTO statement."
I get the error from this line of my code
da.Update(ds, "employeeTable")
for mode details below here is my code:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim cb As New OleDb.OleDbCommandBuilder
Dim dsNewRow As DataRow
'con.Open()
cb = New OleDbCommandBuilder(da)
dsNewRow = ds.Tables("employeeTable").NewRow
ds.Tables("employeeTable").Rows.Add(dsNewRow)
txtEmployeeID.Text = "5678"
dsNewRow.Item("employeeID") = txtEmployeeID.Text
da.Update(ds, "employeeTable")
con.Close()
End Sub
Thanks,
dfan23
|
|
|
|
|
how many times are u gonna ask this question buddy? Did you read the link i sent you?
|
|
|
|
|
Hello,
sorry if I ask again but I have read it and you have tell me that command builder is not
working if no primary key. I also tried others code but still this error keep still.
Sorry if this is not a good question.
Thanks,
dfan23
|
|
|
|
|
ok. I understand that sometimes it becomes frustrating when you don't get a job done. But please maintain a single thread of question. Posting the same question many times is not gonna solve it. Someone who has already responded you will be in a better position to help you out.
In any case, what we are gonna do is to create a table and get it done.
create a new table in your access database and name it: "MyTable".
Create three columns:
1. ID = AutoNumber =>Set it as key (You need to right click on the column and select primary key)
2. FirstName = Text
3. LastName = Text
Now, write this code in your program:
Dim con As New OleDb.OleDbConnection
Dim inc As Integer
Dim MaxRows As Integer
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim dt As DataTable
Private Sub Sampler_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ds = New DataSet("dataSet")
dt = New DataTable()
ds.Tables.Add(dt)
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
"Data Source = c:\Sadsign.mdb"
'This is where we load the table
con.Open()
sql = "SELECT * FROM MyTable"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(dt)
con.Close()
'This is where we add a new row in the table
Dim row As DataRow = dt.NewRow()
row.Item("FirstName") = "MyFirstName"
row.Item("LastName") = "MyLastName"
dt.Rows.Add(row)
'This is where we update the table in database.
con.Open()
sql = "SELECT * FROM MyTable"
da = New OleDb.OleDbDataAdapter(sql, con)
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.Update(dt)
con.Close()
'We Are Done
End Sub
Now, this code is working on my computer so, it should work on yours too provided you did exactly as i said.
|
|
|
|
|
Hello,
I would like to thanks you Mr. Som Shekhar, sir
thanks for the patient for helping me and I'm sorry for being so frustrated
I have coding this and reading alot for almost a week but still
I got the same error. Thanks and best regards for helping others like me.
Thanks,
dfan23
|
|
|
|
|
So, is it sorted now?
if yes, then rate the answer and mark it as solution to your problem.
|
|
|
|
|
hello,
A big 5 is really nice for you sir.
Thanks,
dfan23
|
|
|
|
|
u r welcome. and please stop calling me sir. we all have gone through this phase and i am just returning the favor of someone else who helped me in the past.
cheers!!
|
|
|
|
|
Hello,
now I can move on the next part of coding
for the system I'm planning to create.If ever I cant figured out again
my problem going to post it again here.
Thanks again for the help.
Thanks,
dfan23
|
|
|
|
|
In my application I am loading rows of data into a gridview object and then performing an internal sort (by code) for one of the columns. After that I select (by code) the top row. This seems to work as the top row in the gridview is selected by the cursor. However when I subsequently use the up/down arrow keys on the keyboard to navigate up and down the gridview, the cursor starts off at the original row that was selected BEFORE the sorting instead of the top row as selected by code. How do I get the software to continue from the top row as selected?
|
|
|
|
|
|
Thanks for the advise. But whenever i call DataGridView.ClearSelection() i get the error message telling me that the index is out of range even if the count of DataGridView.SelectedRows.Count is equal to 1 at that point.
All i am really doing is
GridView.Sort(GridView.Columns[1], ListSortDirection.Descending);
GridView.Rows[0].Selected = true;
//at this point DataGridView.SelectedRows.Count is equal to 1.
// if i call DataGridView.ClearSelection() at this point i will get an error
|
|
|
|
|
From what event are you running the code?
Try this code from a button;
GridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
GridView.ClearSelection();
I are Troll
|
|
|
|
|
Thanks, but I still get the index out of range exception when calling the above code.
i can't use "GridView.ClearSelection(1, 1, true)" either as i am told that that method is inaccessible due to its protection level.
|
|
|
|
|
tims81 wrote: Thanks, but I still get the index out of range exception when calling the above code.
i can't use "GridView.ClearSelection(1, 1, true)" either as i am told that that method is inaccessible due to its protection level.
Aw, I overlooked the protected flag
In what event is this code running? Can you paste the entire eventhandler?
GridView.Sort(GridView.Columns[1], ListSortDirection.Descending);
GridView.Rows[0].Selected = true;
I are Troll
|
|
|
|
|
The entire event handler is kinda big with different sub methods but essentially i am running it from a button_click event handler.
|
|
|
|
|
I've tried this code to confirm that it works;
private void Form1_Load(object sender, System.EventArgs e)
{
DataTable dt = new DataTable("employee");
dt.Columns.Add("firstname");
dt.Columns.Add("lastname");
dt.Rows.Add("john", "doe");
dt.Rows.Add("johnny", "walker");
dataGridView1.DataSource = dt;
}
void HandleClick(object sender, EventArgs e)
{
dataGridView1.ClearSelection();
if (dataGridView1.Rows.Count > 0)
dataGridView1.Rows[0].Selected = true;
}
This code fills a DataGridView, and focus is on the last cell of the last row when it finishes loading. After clicking Button1, it clears the entire selection, optionally selecting the first row.
tims81 wrote: The entire event handler is kinda big with different sub methods
Can you take a look at the Exception that you're getting, or post it here? It should contain the name of the method that caused the exception, maybe we can find something there
Is the event SelectionChanged used in the code? Could other events be triggered while you're doing work in the button-handler?
I are Troll
|
|
|
|
|
My bad, the selectionChanged event was causing an error. fixed that. now calling
GridView.Select();
GridView.ClearSelection();
GridView.Rows[0].Selected = true;
but it still only shows the first row selected but then continues from the original row when using the arrow keys. did your code still work after trying a sort operation like:
GridView.Sort(GridView.Columns[1], ListSortDirection.Descending); ?
|
|
|
|
|
tims81 wrote: but it still only shows the first row selected but then continues from the original row when using the arrow keys. did your code still work after trying a sort operation like:
You're right! It showed the highlighting on the correct row, but the focus-rectangle for keyboard-input was still on the last row. In order to "force" the correct focus, I changed the example-code to this;
private void Form1_Load(object sender, System.EventArgs e)
{
DataTable dt = new DataTable("employee");
dt.Columns.Add("firstname");
dt.Columns.Add("lastname");
dt.Rows.Add("john", "doe");
dt.Rows.Add("johnny", "walker");
dataGridView1.DataSource = dt;
dataGridView1.Sort(dataGridView1.Columns[1], ListSortDirection.Descending);
}
void HandleClick(object sender, EventArgs e)
{
dataGridView1.ClearSelection();
if (dataGridView1.Rows.Count > 0)
{
dataGridView1.Rows[0].Selected = true;
dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[0];
}
}
Hope this helps
I are Troll
|
|
|
|
|
It works now! That's so awesome. Thank you so much for your help, I owe you one!!!
|
|
|
|
|
You're welcome
I are Troll
|
|
|
|