|
On the other hand, if you can fit all the required data in lParam (32-bit), then you
make it so that you dont need pointers at all.
Some of the Window messages are known to contain a point in lParam, using the high and
low 16 bits for x and y (or is it y and x, dont recall).
Since I am not familiar with message 789 I can't tell if this is applicable to you.
If you defined it, and are responsible for the code in both processes,
I suggest the simple way described above !
Luc Pattyn
|
|
|
|
|
Hi, I am trying to drive Source Safe from my own front end.
I can't manage to create a new directory in VSS (Not a Directory on my PC)
I am using the Interop.SourceSafeTypeLib would another library be any better?
Thanks
Elephant
|
|
|
|
|
Have you tried VSSItem.NewSubproject ?
|
|
|
|
|
Hi all!
I use your help very urgent!
2 years ago a remote application was created.
The DataService (DataService.dll) contains a IRemoteFactory, which
allows the client to get access to the corresponding interface (here
the implementation):
public sealed class VRemoteFactory : MarshalByRefObject,
IRemoteFactory {
private DataObject m_DataObj = null;
public IDataObject iDataObject {
get {
if (null == m_DataObj) {
m_DataObj = new DataObject();
}
return m_DataObj;
}
}
The class DataObject (implemented as MarshalByRefObject in the
DataService.dll) implements the IDataObject interface, which provides a
property 'Version' and a function to get an object of the class Data
(implemented as sealed Serializable).
Now I have to extend the DataService.
As described in the .NET Remoting book of Ingo, I created a new
interface IExtendedDataObject which inherits from IDataObject. The
DataObject class now implements IExtendedDataObject, with the new
property that returns a class ExtData (which inherits from Data (which
is no longer declared as sealed)). I did not change anything at the
VRemoteFactory.
So every thing works fine as long as I use the new addapted client with
the new DataService (DataServer.exe). But if I try to run my new Client
againts the old DataService (DataServer.exe) I get a
InvalidCastException (Return argument has invalid type), but I do not
know why ??? I get this exception as soon as I call the
IRemoteFactory.iDataObject in the client, but why ???
In a demo project every thing works!!!
Please help me!
PS: I read something about namespace clashes if the old version is
compiled in .NET 1.0 and the new in 1.1. ????
Thanks
|
|
|
|
|
Hello!
I want to be able to change color of tabpages in a tabcontrol. Ive heard it´s got to do with drawmode, but I can´t figure out what to do. How do I achieve this?
|
|
|
|
|
Hi,
You can try to create a new class that inherits from TabPage. In this class you can make an override of the function OnPaint and use the PaintEventArgs parameter of this method to draw.
Then in your tabcontrol, instead of adding tabpages, you must add your new class.
|
|
|
|
|
Hi
You can just set the BackColor like so:
MyTabPage.BackColor = Color.Aquamarine;
HTH HN3
|
|
|
|
|
Set the TabControl's DrawMode to OwnerDraw, and then handle the DrawItem event to draw things yourself.
private void tagpage2_DrawItem(sender object, Eventarg e)
{
//here is place to write ur code using System.graphics
}
|
|
|
|
|
|
Hello,
System.Net.WebClient has method: DownloadDataAsync and event:DownloadDataCompleted
How does it internally work?
So...I assume when I call DownloadDataAsync it starts some private method StartDownload (for example) in a new thread, and from this StartDowload(which runs in the Thread) will be called DownloadDataCompleted(),
BUT they have made it so, that in attached to the event method, i can use all UI, thats mean...that DownloadDataCompleted is called in the main programm thread, how did they did that?
Thanks.
|
|
|
|
|
Delegates.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Yes, but how? What should i invoke?
So I mean, to invoke a UI control from Thread I should Invoke this control...but I want to be able OnEvent use all controls I want, without Invoking, like it did in System.Net.WebClient...is it possible?
-- modified at 5:41 Wednesday 17th January, 2007
|
|
|
|
|
|
|
Hi all,
I have a little problem with one of my threads now that I switched over to the dotnet 2.0
I have a main form with a toolbar. One button on the toolbar opens a new form, an appointmentbook.
I have a Global boolean variable AppointmentBook to check if it is open or not, then I initialized the form I want to open with the thread during the load of my main form, named appointmentBook. It all worked in .net1.1 but now I get an error at the point where I say
...appointmentBook.WindowState = System.Windows.Forms.FormWindowState.Normal...
What this is suppose to do is if the form was just minimized, and the toolbar button was clicked, it will see that currently there is an open form and then just bring that form up again.
The error I receive is a cross threading error, and says that I can't access the form initialized in another thread.
So I have the following...
case "2":
//start thread to handel new appointment book
if(Brim.Library.GlobalVariables.AppointmentBook)
{
appointmentBook.WindowState = System.Windows.Forms.FormWindowState.Normal;
}
else
{
StartThread();
}
private void StartThread()
{
ThreadStart appointThread = new ThreadStart(InitializeAppointmentBook);
Thread workerThread = new Thread(appointThread);
workerThread.Start();
}
private void InitializeAppointmentBook()
{
Brim.Library.GlobalVariables.AppointmentBook = true;
appointmentBook.ShowDialog();
}
Any help in how to solve this will be appreciated.
Thanks in advance
Last modified: 32mins after originally posted --
He who laughs last is a bit on the slow side
|
|
|
|
|
What's the error ? Global Variables always cause grief.
In .NET 2.0 there's an exception called if you access UI elements across thread. You can either turn this off ( checkforcrossthreadclientsomethingorother is the property name ), or you can fix your code, to not access UI elements between threads ( which is fraught with danger )
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Does <code>StartThread</code> create the <code>appointmentBook</code> object? If not, who creates it? My guess would be that it is created by a different thread and when the UI thread attempts to access the <code>WindowState</code> property, a cross thread exception occurs.
You can solve this problem by creating the form on the UI thread (or whatever thread accesses the <code>WindowState</code>) property. To make a method execute on the UI thread, you can use Control.Invoke[^] or Control.BeginInvoke[^]. This[^] article will explain you the basics behind those methods and why they are needed.
|
|
|
|
|
Thanks for the reply. The main form is on the main thread. The main form contains the toolbar. The appointmentBook is created on the main form...frmAppointmentBook appointmentBook = new frmAppointmentBook, but the appointmentBook.ShowDialog() is only called within the sub thread. Then the call to the WindowState of the appointmentBook is done from the main thread.
Hope that makes sense
He who laughs last is a bit on the slow side
|
|
|
|
|
NeroToxic wrote: ut the appointmentBook.ShowDialog() is only called within the sub thread. Then the call to the WindowState of the appointmentBook is done from the main thread.
There lies your problem. If you're going to show the form on a different thread, create the form on that thread. When trying to acess the <code>WindowState</code> property from the main thread, use Invoke or BeginInvoke like this
void SetWindowStateForAppointmentBook()
{
if (appointmentBook.InvokeRequired)
{
this.Invoke(new MethodInvoker(SetWindowStateForAppointmentBook), null);
}
else
{
appointmentBook.WindowState = System.Windows.Forms.FormWindowState.Normal;
}
} Hope this helps.
|
|
|
|
|
Thanks, works 100%
He who laughs last is a bit on the slow side
|
|
|
|
|
Hi
I have exported pubs authors table into flatfile. I am trying to import the same flat file data into dataset in C#. Could you any one help me please.
Data from flat file to Dataset(same format like authors table).
kesavan
|
|
|
|
|
The following works for an Excel worksheet:
this.dataSet = GetDataset(worksheet, "BookName");
private DataSet GetDataset(Excel.Worksheet worksheet, string startElement)
{
StringBuilder stringBuilder = new StringBuilder();
XmlTextWriter xmlTextWriter = new XmlTextWriter(new StringWriter(stringBuilder));
xmlTextWriter.WriteStartDocument();
xmlTextWriter.Formatting = Formatting.Indented;
xmlTextWriter.Indentation = 3;
int row = 2;
Array rowValues = (Array)worksheet.get_Range("A" + row.ToString(), "C" + row.ToString()).Cells.Value2;
string Col1 = GetString(rowValues.GetValue(1, 1));
string Col2 = GetString(rowValues.GetValue(1, 2));
string Col3 = GetString(rowValues.GetValue(1, 3));
DataSet ds = new DataSet("table");
xmlTextWriter.WriteStartElement(startElement);
if (Col2 == string.Empty)
{
DataTable dataTable = new DataTable("row");
dataTable.Columns.Add("Col1");
dataTable.Columns.Add("Col2");
dataTable.Columns.Add("Col3");
dataTable.Rows.Add(new object[] { null, null, null });
ds.Tables.Add(dataTable);
return ds;
}
while (Col2 != string.Empty)
{
xmlTextWriter.WriteStartElement("row");
xmlTextWriter.WriteElementString("Col1", Col1);
xmlTextWriter.WriteElementString("Col2", Col2);
xmlTextWriter.WriteElementString("Col3", Col3);
xmlTextWriter.WriteEndElement();
row++;
rowValues = (Array)worksheet.get_Range("A" + row.ToString(), "C" + row.ToString()).Cells.Value2;
Col1 = GetString(rowValues.GetValue(1, 1));
Col2 = GetString(rowValues.GetValue(1, 2));
Col3 = GetString(rowValues.GetValue(1, 3));
}
xmlTextWriter.WriteEndElement();
xmlTextWriter.Flush();
xmlTextWriter.Close();
XmlTextReader xmlReader = new XmlTextReader(stringBuilder.ToString(), XmlNodeType.Element, null);
ds.ReadXml(xmlReader);
return ds;
}
For a flat file get rowValues array as follows:
StreamReader inStream = new StreamReader(filePath);
line = inStream.ReadLine();
while(inStream.Peek() >= 0)
{
line = inStream.ReadLine();
string[] rowValues = line.Split(new Char [] {','});//assumes flat file is comma delimited
}
inStream.Close();
Col1 = rowValues[1];
Col2 = rowValues[2];
Col3 = rowValues[3];
|
|
|
|
|
I am trying to connect SQL Server from my computer (named TANKIMHUY.kimhuy.com.vn) to my colleague's computer (named PHANTAM.kimhuy.com.vn). Of course both computers are clients.
SQL Server instance is installed in two machines.
I open SqlConnection's wizard dialog, I see two names( (local) and PHANTAM) in Server Name comboBox.
When I choose PHANTAM as a server name and fill usename: sa password: sa, but I see an empty list of databases instead of a list of available databases such as Northwind, ... in SQL Server 2000
I am very confused what wrong I have. Someone help me show the available databases or how to connect SQL Server from client machine to client other in C#
Thank you very much.
-- modified at 1:57 Wednesday 17th January, 2007
|
|
|
|
|
Have you check the basics?
- Have you got the correct credential to conect to his database? (Try with both SQL credential and microsoft autentification)
- Has your colleague given you the correct privileges to access his database?
- have you try to create a OBDC connection to his PC (That will also validate the connection)
- Check with your IT that they have not restricted some connections...
Elephant
|
|
|
|
|
Hi All,
I have block of code and i want to execute that code only once when we run(execute) a program 4 first time in C#.net
pls give a sol ,I wiil be looking for u r reply,
regards,
VINAY,
pune
|
|
|
|