|
Hi everyone.
I'm looking for a good way to let one process know that another process has made changes in
a shared database, so that the first process can update its view, if it is currently open.
After alot of searching on inet I've come to the conclusion that PostMessage from the Win32 api might
be the solution, but I haven't managed to find a guide as how to do it.
I think I can manage the PostMessage part, but how do I retrieve it in target process?
Any help or links to tutorials would be greatly appreciated.
-Larantz-
|
|
|
|
|
Override your target process form's WndProc() to handle the message.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
[Solved it]
Hi Ravi.
Thx for reply.
I tried overriding the WndProc() and just added a debugger to
see if it fires when I run the 2nd process with PostMessage(..).
WndProc() process compiles, but when I fire it up, I get an error
along the lines of "Error creating windows referance". (I got it in norwegian...)
How can I preserve / inherit original WndProc() and just extend it with
the code I want to fire?
-Larantz-
-- modified at 9:10 Friday 2nd June, 2006
|
|
|
|
|
Hi again ravi.
I was hoping you might explain to me why the messages I send from
"senderclass" isn't picked up by the "recieverclass".
All I can think of is that the pointer to the process is wrong.
But I know that Process.GetprocessByName("processname") finds the right process.
Here's the code for the PostMessage routines:
[DllImport("User32.Dll")]
public static extern long PostMessage(IntPtr hWnd, long wMsg, long wParam, long lParam);
public const long WM_PAINT = 0x0F;
public const long WM_DISPLAYCHANGE = 0x7E;
System.Diagnostics.Process[] procs = Process.GetProcessesByName("processname_here");
foreach(System.Diagnostics.Process proc in procs)
{
Helpers.PostMessage(proc.Handle, Helpers.WM_PAINT, 0, 0);
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_PAINT)
{
MessageBox.Show("Got message");
}
}
Thanks in advance,
-Larantz-
|
|
|
|
|
i'm not sure whether somebody is still interested in this question, but the mistake is the using of proc.Handle. This is a process handle, but for sending messages you need a window handle. So take proc.MainWindowHandle.
|
|
|
|
|
Hi... I have added programaticly to a DataSet two DataTables by the DataSet.Tables.Add() Method.
When I use the DataSet.GetXml() method I get just a line "<New DataSet />".
Why does that happen and how can I have the DataSet with it's tables?
|
|
|
|
|
Hi
Have you tried adding a new DataRow to one of the tables and then calling DataSet.GetXml()? I know that the XML serialiser doesn't generate XML for "empty" columns (where all the values are System.DBNull), so perhaps it's the same for "empty" tables?
Cheers
Andy
|
|
|
|
|
But then I would have 2 tables with a row in each that I don't need, and it will make my project go nuts, it's just an idiotic thing to do...
Can't I do something else instend of inserting a new row with Data I don't need?
|
|
|
|
|
It might be idiotic(?) but it works. If you don't like the way the GetXml call goes about it's business, write your own! Or you could simply build the XML; if it's just the case of a dataset with a couple of empty tables then why not just string-build it? You get a string back from GetXml anyway...
|
|
|
|
|
You have to put data in the tables.
|
|
|
|
|
But then I would have 2 tables with a row in each that I don't need, and it will make my project go nuts, it's just an idiotic thing to do...
Can't I do something else instend of inserting a new row with Data I don't need?
|
|
|
|
|
The only way you're going to see the structure of an empty dataset is to view the schema:
ds.WriteXml(aStream, XmlWriteMode.WriteSchema);
-or-
string s = ds.GetXmlSchema(); Last modified: Friday, June 02, 2006 8:47:59 AM --
|
|
|
|
|
so how from Schema I can add Data?
|
|
|
|
|
I don't understand your dilemma here. You want to see the XML structure of your dataset, but you're not willing to put data in it to do that. How are you trying to use this XML? If you write the schema and data from the DataSet, then another DataSet that reads that XML and schema will have the same structure and data as the original. Otherwise, I really don't see what you're trying to do.
|
|
|
|
|
Hello all,
I've developed a little module of timesheet and within i use a ole db connection to a ms project file.
MsProject 2003 ==> Microsoft.Project.OLEDB.11.0 ole db provider.
On my pc, everything works fine BECAUSE I'VE MS PROJECT 2003 INSTALLED ON IT.
But i try to put it on the server (win 2000 sp 4 enterprise ) :
The 'Microsoft.Project.OLEDB.11.0' provider is not registered on the local machine.
Can anyone help me ?
Thanks a lot.
|
|
|
|
|
Philippe Generet wrote: On my pc, everything works fine BECAUSE I'VE MS PROJECT 2003 INSTALLED ON IT.
But i try to put it on the server (win 2000 sp 4 enterprise ) :
The 'Microsoft.Project.OLEDB.11.0' provider is not registered on the local machine.
At the risk of sounding obvious, I would say you need to either install Project on your server, or find out if there's some other way of installing the provider (though a quick look on Google didn't return anything). As a general rule, programming with Office applications seems to require them to be installed on the server.
|
|
|
|
|
Dear All,
How do i set the Database object security from the frontend for the SQLServer with User Interface
Like If you create new login , What are all the privilege i need to give to that user
I m going to do this using Front End using C# with SQLServer.
With GreatRegards,
Siva
|
|
|
|
|
Shiv5 wrote: Urgent
Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?
Shiv5 wrote: How do i set the Database object security from the frontend for the SQLServer with User Interface
What do you mean by your use of the proper noun "User Interface"? Do you mean using Enterprise Manager? Or did you mean "user interface" (adjective + noun combination)?
Shiv5 wrote: Like If you create new login , What are all the privilege i need to give to that user
What do you want the user to be able to do? What do you want them not to be able to do?
Shiv5 wrote: I m going to do this using Front End using C# with SQLServer
What is this proper noun "Front End"? Is it a new IDE? I'm gussing you mean you want to write a program in C# that will create a new user and assign privileges to that user. Is that correct?
You can run just about any SQL code through a SqlCommand object. If you can write in in Query Analyzer you can run it through a SqlCommand object (Just remember every time you see a GO in query analyzer that is new SqlCommand .
The SQL commands that you need are likely to be:
* sp_grantlogin[^]
* sp_grantdbaccess[^]
* GRANT {SELECT / UPDATE / INSERT / DELETE / EXECUTE} ON {object} ON{security account}[^]
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Colin Angus Mackay wrote: Perhaps a little planning would be helpful?
ROTFLMAO
|
|
|
|
|
i have one toolbar control. it contain two buttons.
when i click any one of these two buttons,the same click event is fired in code behind.
How can i handle click event for two buttons indivually.
|
|
|
|
|
Just put some code in your event to read the button text for example:
private void Button_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
if (button.Text == "button1")
{
// do this for button 1
}
else if(button.Text == "button2")
{
// do this for button 2
}
else {}
}
Alternativly you can add seperate Event handlers for the differnt buttons. There are many ways to do it.
|
|
|
|
|
private void OnToolbarButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)<br />
{<br />
switch (this.ToolBar1.Buttons.IndexOf(e.Button))<br />
{<br />
|
|
|
|
|
Hi,
is there any way or method to find out the Ascii code of the character that is typed in the text box.
Actually, i'm trying for a textbox that only accept numeric values/symbols (that is 0 to 9). Because i don't want to let my user to enter any character or special symbol except decimal point.
if anybody have any idea than please do let me!
With Thanks.
|
|
|
|
|
Add an Event handler to the text box
this.textBox1.KeyDown += new System.EventHandler(this.textBox1_Keydown);
This allows 0-9 and backspace.
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(!Char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
{
e.Handled = true;
}
}
|
|
|
|
|
Thanks a lot Darren Marshall!
its as simple as was in VB 6
Thanks and
Best Regards.
|
|
|
|