|
I know! Sometime you just need a bigger hammer to drive the point home! Like making TABs in VS.NET...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi! anybody can assist me in developing a simple blob analysis program via C# -GDI+. The idea is I would want to do some image processing on a captured images (in this example, it'll be few coins). The picture of these coins are taken via digital camera. I would really much appreciate it somebody can help me in the blob analysis program.
M
|
|
|
|
|
I have a class that I access from my main form to get all my class data. I created a thread to do a particular task (first time using threads), only it seems to have a new instantiation of my class, and all the class data is off. How can I get these two synchronized so that my thread can access the same data my form gets?
|
|
|
|
|
Post the code that spawns the work thread, assuming that this work thread is used to read in data or whatever and set a form's data member in the main thread.
In general, read in the data in the work thread. Invocate an event to update the main thread.
Kuphryn
|
|
|
|
|
Heres what the code looks like:
static void Main()
{
//making a new instance of this class to run outside of main
Form1 f = new Form1();
f.startScheduler();
Application.Run(new Form1());
}
public void startScheduler()
{
//get this thread goin
Thread t1 = new Thread(new ThreadStart(ripper));
t1.Start();
}
public void ripper()
{
//infinite loop
for ( ;;)
{
if (hc.getNumThemes() >= 1)
{
MessageBox.Show("calling riptheme");
hc.rip_Theme();
}
Thread.Sleep(4000);
}
}
during the application, hc.getNumThemes gets bumped from 0 to 1,2,3. But the thread always remains at 0.
|
|
|
|
|
Dear CPians,
I am in need of customized PropertyGrid component(.NET Compatable) with look and feel like the link below
http://www.visualhint.com/propertygrid.php
If you know any of such controls, Please let me know.
I would appreciate your help in this regard.
Thanks in advance.
Regards,
Jay.
|
|
|
|
|
As I mentioned to you before[^], you can use either the IL Disassembler (ildasm.exe that comes with the .NET Framework SDK) or a decompiler to find out how the PropertyGrid works. I also told you how it uses the System.ComponentModel namespace members to provide it with functionality (which leppie also mentioned), which is what that namespace (and a few related namespaces) are for. The .NET FCL provides a designer with almost everything it needs to design components.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Actually, I was referring to how you let the UITypeEditor s and what-not "do their job". That was the point I was trying to make.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
here is a C++ function:
LRESULT CALLBACK GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// Do we have to handle this message?
if (nCode == HC_ACTION)
{
// Process the hook only if the WinVNC thread id is valid
if (vnc_thread_id)
{
MSG *msg = (MSG *) lParam;
// Only handle application messages if they're being removed:
if (wParam & PM_REMOVE)
{
// Handle the message
if (m_ddihook)
HookHandleddi(msg->message, msg->hwnd, msg->wParam, msg->lParam);
else HookHandle(msg->message, msg->hwnd, msg->wParam, msg->lParam);
}
}
}
// Call the next handler in the chain
return CallNextHookEx (hGetMsgHook, nCode, wParam, lParam);
}
////////////////////////////////////////////////
according to an article on MSDN, i write a Hook code in C#.
how to convert this code to C# counterpart:
MSG *msg = (MSG *) lParam;
i declare lParam as IntPtr type. How about *msg ?
should i write it as this :
System.Messaging.Message msg = (System.Messaging.Message)lParam
???
|
|
|
|
|
MSG is a simple struct:
[StructLayout(LayoutLind.Sequential)]
public struct MSG
{
public IntPtr hwnd;
[MarshalAs(UnmanagedType.SysUInt)] public IntPtr message;
public IntPtr wParam;
public IntPtr lParam;
[MarshalAs(UnmanagedType.U4)] public int time;
public System.Drawing.Point pt;
} The second field is an IntPtr because the unmanaged type UINT is a processor-dependent bit width: 32 bits on a 32-bit CPU and 64 bits on a 64-bit CPU. To pass a value, just use new IntPtr(someNum);
If you need a pointer to this struct (MSG* ), you can either use the Marshal.StructureToPtr to marshal it to an IntPtr or - even easier - declare the method that accepts the MSG* as ref MSG msg . Here's an example:
[DllImport("user32.dll")]
private static extern bool SomeExampleFunc(ref MSG msg); This automatically marshals the MSG struct (that you simply instantiate and fill the fields) as a MSG* .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok, i have a DataTable with some columns, and i have a DataGrid.
The DataGrid DataSource is my DataTable.
So, how i color some elements?
I want to color all elements in the Table = "F" and "I"
Thanks.
|
|
|
|
|
|
I dont know, im not using Colum or table styles, just DataSource.
I Want color a element on a cell.
I have a DataTable with some columns, and call this table in DataSource.
|
|
|
|
|
1.To do this you first have to create class derived from DataGridTextBoxColumn or DataGridColumnStyle . You then have to override the Paint() method of these classes.
Implement the Paint Method as below
protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
{
string val = (string) GetColumnValueAtRow(source, rowNum);
if(val == "T")
foreBrush = Brushes.Green;
else if (val == "F")
foreBrush = Brushes.Red;
base.Paint (g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
}
2. You will have to use DataGridColumnStyle to achieve the functionality.
3. Read the article, I had given you in my previuos reply. also download and run the sample project of the article. This will help you a lot.
Regards,
Jay.
|
|
|
|
|
You're need to. It's not hard - just see the DataGrid.TableStyles property in the .NET Framework SDK documentation. If you don't, you can't. The other reply is correct in what you must do.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have this project in school, doing a project and while the code is the small part(main thing is learning use RUP and so on) it is still kinda tricky. Not codewise but design wise.
Right now we have one Project class, one Resource class, one Employee class, one "main" class and a "storage manager".(The program will be quite bigger eventually but this is the gist of it).
The program can handle several projects and several employees. And we added a resource class "between" employee and project, ie a resource can only have one project and one employee and it keeps the information needed. Like how many hours the employee should work on the project and so on.
At first we had no relation between these three classes, instead we had a database way of thinking and used a "foreign key" a employee id and project id in resource. But instead it was recommended to us that a good object oriented design should have associations instead.
So I've have been thinking of adding knowledge of project and employee to the resource class and both the employee and project should know about the resource. Will this be good or just too "cluttered".
Another problem we faced was that if that many objects are bound to each other we will have trouble sending them back and forth to our server.(Or will we?)
Any tips of design patterns or just general tips about how we can do?
(Not asking you too do school work for me here , we are actually recommended seeking information on the Internet)
|
|
|
|
|
Cenatar wrote:
So I've have been thinking of adding knowledge of project and employee to the resource class and both the employee and project should know about the resource. Will this be good or just too "cluttered".
It depends on which way you need to travel through the objects. I would imaging your suggestion above is correct. Asking yourself some questions like: Does an employee object need to know about the projects it is connected with? Does a project object need to know about the employees working on it? If it is "yes" in both cases then:
Project keeps a collection of references to its resources
Resource keeps a reference to its project and the employee
Employee keeps a collection of references to its resources
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
Colin Angus Mackay wrote:
Project keeps a collection of references to its resources
Resource keeps a reference to its project and the employee
Employee keeps a collection of references to its resources
That is actually exactly how we imagined it thank you, but later wont this be a big mess when we try and transfer it to the server? ie what happens when I get a project from the server(or database) and I want to see what resources that is connected to it?
This might be a stupid question, as I've not looked into this at all. Will do that though, but thank you for your help.
|
|
|
|
|
Cenatar wrote:
what happens when I get a project from the server(or database) and I want to see what resources that is connected to it?
What do you mean? That depends on how you want to implement it, what technologies are abailable and so on.
If you are concerned about large ammounts of data transferring in one go you could implement a lazy fetch algorithm. In other words, you get the project as your starting point. Then if you need to iterate through the list of resources, you'll access that collection through a property and the internal code of the property checks whether the information is available yet and if not builds the collection by fetching the relevant data from the database. The resource object will expose properties that get you to the project and employee with a lazy fetch algorithm, since the project already exists that reference will be reused, but since the employee doesn't exist in your application any attempt to get the employee property will, for the first time, perform a database lookup.
Be warned that over zealous use of lazy fetch (aka lazy lookup) algorithms can hurt performance, however some uses, like in matrix classes (and this is more of a lazy calculation, than lookup) can work very well if you don't need to know everything about the matrix. As a general rule, try and fetch as much as possible in one request (without fetching so much the user is left waiting) because it reduces network traffic (one request and lots of data in the reply, rather than lots of requests and lots of replies - which probably won't fill network packets efficiently).
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
Hi,
I'm trying to set a mailto option in a Windows Form that will send an attachment (eg: WordPad has this feature, call "Send").
This is as far as I got...
System.Diagnostics.Process.Start("mailto:?attachment=" + fileNameWithPath);
Not working though... any help is greatly appreciated )
Ron
|
|
|
|
|
Many MAPI clients do not support attachment in the mailto: pluggable protocol. Outlook and Outlook Express are two that don't support that.
The only way to do it that is application independent is to use Extended MAPI, which must be wrapped. You can also use simple MAPI, but Outlook XP and newer will prompt the user with annoying questions (Microsoft "fix" to all the Outlook-related problems).
One such article that is pretty good is Simple MAPI.NET[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I want to color a column in a datagrid . How do I do this?
Karteek
|
|
|
|
|
I told you how the last time you asked this: by extending the DataGridColumnStyle with your own class nad overriding the necessary properties and methods. You must then define your DataGridTableStyle s and DataGridColumnStyle s explicitly. See DataGrid.TableStyles in the .NET Framework SDK documentation for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|