|
Hi All
What is nmake used for?? Can anyone give me an example for its usage ???
Thanxs
Maharishi
Nothing is Impossible. Even impossible spells "i m possible"
|
|
|
|
|
nmake is a build environment tool which uses a "makefile" to execute build instructions. The "makefile" contains variables and commands. Here you go: NMAKE Reference.
|
|
|
|
|
I'm writing a plug-in in VB.NET to a an application called DesktopSidebar for Windows. Right clicking my plug-in's "panel" shows among other things a Properties Dialog. All I need to do is pop up the dialog in the proper place and on the same monitor in a multiple monitor environment. My plug-in doesn't appear at this point to have the Window handle of the calling application. After quite a bit of trial and
error I came up with this:
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Int32,
ByRef lpRect As RECT) As Int32
Public Structure RECT
Dim Left As Int32
Dim Top As Int32
Dim Right As Int32
Dim Bottom As Int32
End Structure
Dim colProcess() As System.Diagnostics.Process
Dim oProcess As Diagnostics.Process
colProcess = Diagnostics.Process.GetProcessesByName("sidebar")
If colProcess.Length > 0 Then
oProcess = colProcess(0)
Dim handle As System.IntPtr = oProcess.MainWindowHandle
Dim loc As RECT
If GetWindowRect(handle.ToInt32, loc) > 0 Then
'Where are we docked?
If loc.Left = 0 Then
Me.Location = New Drawing.Point(loc.Right,(loc.Bottom -
loc.Top)/2)
Else
Me.Location = New Drawing.Point(loc.Left - Me.Width,
(loc.Bottom - loc.Top)/2)
End If
End If
End If
This works great as long as you have a single monitor, whether DesktopSideBar is docked to the Left or the Right. However, I run in a
multi-monitor environment. In my particular setup my primary display is my laptop and my secondary display actually hovers ABOVE my primary display (it's a 19 inch monitor) and I have my desktop extended onto it. The code above, only targets the primary display, even though I dock DesktopSideBar on my secondary monitor. My screen coordinates are still good... just not on the right monitor.
Could anyone offer up some suggestions on how to not only determine the monitor my panel is on, but also how to set the location of my dialog to a specific place on the proper monitor?
|
|
|
|
|
When running an application on a multiple monitor environment the coordinates of the form are the coordinates for the combined desktop.
The .NET Framework provides the Form.DesktopLocation property to set and get the location of forms in multimonitor environments. So, in the code you posted above you should remove stataments like
Me.Location = New Drawing.Point(loc.Right,(loc.Bottom -
loc.Top)/2)
replacing them with
Me.DesktopLocation = New System.Drawing.Point(loc.Right,(loc.Bottom -<br />
loc.Top)/2)
|
|
|
|
|
how to access web service with SSL from windows application (C#)?
How to use the certificate in the client windows application/
Is there any sample available?
Thanks a lot.
|
|
|
|
|
Hi!
I have the following:
function(Control theControl)
{
// At this point I know that the control has an items property
if (theControlis ListBox) ((ListBox)ctrl).Items.Clear;
if (ctrl is ComboBox) ((ComboBox)ctrl).Items.Clear;
}
You guru's probably already know my question...
How can I create a generic solution here?
something like:
function(Control theControl)
{
// At this point I know that the control has an items property
((theControl as Type)ctrl).Items.Clear;
}
|
|
|
|
|
What you need is an interface. If all Controls with .Items implemented a particular interface, something like IHasItems, then you could do a generic implementation. Unfortunately, there is no IHasItems interface, so you're SOL.
You could create a wrapper class around a Control, create an IHasItems interface and implement it yourself. For instance,
Define an interface like so:
public interface IHasItems
{
IList Items
{
get;
}
}
Then inherit a class from each control you need to use, while implementing that interface:
public class ListBoxEx: ListBox, IHasItems
{
...
}
That's it, you can then pass any IHasItems implementer into your function
function(IHasItems theControl)
{
theControl.Items.Clear();
}
Now, with that solution you're going to have to guarantee that the .Items property will return something with a .Clear() method, but you get the picture.
Hope that helps.
The graveyards are filled with indispensible men.
|
|
|
|
|
I just checked and the above solution will indeed work. However, that is quite a bit of extra work (you have to create an interface, then create a wrapper class).
Instead of that, why not just make your function accept an IList instead of a Control? For instance,
public void function(IList items)
{
items.Clear();
}
Then pass the items to it like:
ComboBox combo = new ComboBox();
ListBox listBox = new ListBox();
function(combo.Items);
function(listBox.Items);
That is an easier solution and will work equally well. If your function requires the Control, not just the .Items, then you should use the first solution I posted.
The graveyards are filled with indispensible men.
|
|
|
|
|
Hi Judah,
Thanks for your input. I'll try it out and see if that's what I need.
|
|
|
|
|
Both Listbox and ComboBox inherit from ListControl , so it would be somewhat logical to assume that's where the Items porperty comes from. If only it were that easy.
Although they share a common name, Items properties represent differents type of objects in Listbox and ComboBox (ListBox.ObjectCollection and ComboBox.ObjectCollection , respectively).
Therefore, there's no common ancestor you can cast to and call Items.Clear() .
As for your question of how to create a generic solution, there is a way, although it may be overkill for what you're looking for.
using System.Reflection;
object collection = ctrl.GetType().GetProperty("Items").GetValue(ctrl, null);
collection.GetType().GetMethod("Clear").Invoke(collection, null); Alas, the 'generic' solution is usually not the easiest
Charlie
if(!curlies){ return; }
|
|
|
|
|
Oops. Upon further reflection (no pun intended) and reading the other proposed solution, I realized that once
you've got your object collection, you can cast is to IList and call
Clear() on it. So the second line would become:
object collection = ctrl.GetType().GetProperty("Items").GetValue(ctrl, null);
((IList)collection).Clear();
Charlie
if(!curlies){ return; }
|
|
|
|
|
Hi Charlie,
This was what I was looking for!
Thanks a lot.
John
|
|
|
|
|
Hi,
I have a web app where I'm using SmtpMail to send individual messages when a request is made to a supervisor. It works ok, but the problem is that the web server is not the smtp server and relaying through the mail server (Lotus Domino 5) takes like , I'm not kidding, 4 - 5 seconds to execute the Send method! If I use the local IIS smtp server, and have it relay to the real mail server, the call happens instantly. I've tried pointing at another IIS smtp server on out network and again, it enters and leaves Send immediately. So my question is, what is Send doing with the Domino server that is taking so long? Has anyone had any experience with this?
|
|
|
|
|
Have you tried sending an e-mail with outlook though you Domino server to see how quick it is?
It could just be your setup.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
Hi, I have a problem. On our computer (Celeron 566 MHz, 128MByte, W2000, .NET1.1) we use a CAN bus for getting measurement data from a client. For the CAN bus there is a DLL for NT/2000. Everytime if data comes in, the DLL calls a callback routine in my C# program. Data will come all 50 ms at the moment. This is working so far but if the data comes in, the CPU usage goes up to 100%, even if the callback routine in my C# program is doing nothing. That means only for calling the callback routine every 50 ms is killing the system. Is it possible that I'm doing something wrong?
Before we have written this software in Delphi and at that time the program needs only around 2%-5% CPU usage with 50 ms and around 10% with 1 ms data interval.
Regards
Michael
|
|
|
|
|
I think you'll need to post a little more information to get much help. That's a pretty difficult question to answer without code. Still, when you say CAN, are you referring to the bus protocol often used in automobiles, trucks, and various equipment? If so, who wrote your communications DLL? If it's what I'm thinking, you need to take a look at setting filters to limit the amount of incomming data. CAN data running at full speed (about 1 meg I think) is quite a bit of callbacks. If filtering isn't an option in the supplied DLL, you could write your own in ATL COM. This should be much faster and then you could post up only the messages you really need to your application. If we're on the same page, you may want to consider another provider for your communications DLL like possibly Noregon Systems out of Winston Salem, NC.
|
|
|
|
|
Ok, I will give some more info. CAN means the busprotocol which is used in automotiv industries. The DLL is written by the manufacturer of the industrial computer (using the Win DDK), where the CAN chip is build in.Of cause this is not only the DLL but also a system driver for this hardware. The DLL is only the interface. We used the CANbus with 250 kBaud which enables us to read the incomming Data with 1 ms resolution and we need all the data because we have to control a very dynamical process.
Next I will give some code how I have impleneted this:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Security;
namespace CanOpen
{
// First of all I define the data structure for the callback function
// Before this was public byte oldData[] and public byte newData[]
// But the structure of the Callback function works with byte oldData[8] and
// byte newData[8] and I didn't know how to realize this in C#
public struct NewDataType
{
public int node;
public byte oldData1,
oldData2,
oldData3,
oldData4,
oldData5,
oldData6,
oldData7,
oldData8; //
public byte newData1,
newData2,
newData3,
newData4,
newData5,
newData6,
newData7,
newData8; //;
public int dataLen; //max. 8 bytes (= max. PDO data length)
public PDOChannelType PDOChannel;
}
.....
// Next I define the delegate for the Calback function
delegate void DelegateUserCANNewInputData( ref NewDataType pNewData);
.....
// This is the function, which registers the callback function,
// I tried with and without SuppressUnmanagedCodeSecurity but it has no influence
[DllImport("canopen.dll"),SuppressUnmanagedCodeSecurity]
static extern int CANopenNewInputDataRegister(DelegateUserCANNewInputData
UserCANNewInputData);
.....
private void RegisterCallBackFunctions()
{
int RetCode;
DelegateUserCANNewInputData FptrUserCANNewInputData = new DelegateUserCANNewInputData
(UserCANNewInputData);
RetCode = CANopenNewInputDataRegister(FptrUserCANNewInputData);
}
|
|
|
|
|
Ok, I will give some more info. CAN means the busprotocol which is used in automotiv industries. The DLL is written by the manufacturer of the industrial computer (using the Win DDK), where the CAN chip is build in.Of cause this is not only the DLL but also a system driver for this hardware. The DLL is only the interface. We used the CANbus with 250 kBaud which enables us to read the incomming Data (PDOs) with 1 ms resolution and we need all the data because we have to control a very dynamical process.
Next I will give some code how I have impleneted this:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Security;
namespace CanOpen
{
// First of all I define the data structur for the callback function
// Before this was public byte oldData[] and public byte newData[]
// But the structure of the Callback function works with byte oldData[8] and
// byte newData[8] and I didn't know how to realize this in C#
public struct NewDataType
{
public int node;
public byte oldData1,
oldData2,
oldData3,
oldData4,
oldData5,
oldData6,
oldData7,
oldData8; //
public byte newData1,
newData2,
newData3,
newData4,
newData5,
newData6,
newData7,
newData8; //;
public int dataLen; //max. 8 bytes (= max. PDO data length)
public PDOChannelType PDOChannel;
}
public class VCanOpen
{
.....
// Next I define the delegate for the Callback function
delegate void DelegateUserCANNewInputData( ref NewDataType pNewData);
.....
// This is the function, which registers the callback function,
// I tried with and without SuppressUnmanagedCodeSecurity but it has no influence
[DllImport("canopen.dll"),SuppressUnmanagedCodeSecurity]
static extern int CANopenNewInputDataRegister(DelegateUserCANNewInputData
UserCANNewInputData);
.....
// During the initialization of the CANOpen class
private void RegisterCallBackFunctions()
{
int RetCode;
DelegateUserCANNewInputData FptrUserCANNewInputData = new DelegateUserCANNewInputData
(UserCANNewInputData);
RetCode = CANopenNewInputDataRegister(FptrUserCANNewInputData);
}
.....
// This is the callback function which will be called by the DLL
void UserCANNewInputData(ref NewDataType pNewData)
{
// Do something or nothing
}
....
} // class VCanOpen
} // namespace CanOpen
Regards
Michael
|
|
|
|
|
Matt is right, do you really need all of that data? Are you using RP1210A? If so, filter out what you don't need at the driver/dll layer and don't allow all of the data to come up. CAN is a very fast protocol and on a loaded bus can bring almost any computer to its knees if it tries to process every message.
david
|
|
|
|
|
I really need all this data. I need all the PDOs coming in for this measurement data. The data is already filtered in the system driver. And there is only one other node which sends data. At the end I need to record the data with a frequncy of 1 kHz. But even with 50 ms the system is not more usable. Again, before we use Delphi and it works very well. Only 5 % of CPU is used with Delphi.
Another question? If it is so, as you described, maybe .NET is not the future solution for applications which must handle a big amount of data in short time.
regards,
Michael
|
|
|
|
|
Couple of thoughts:
1) Try using windows messaging instead of callbacks. Windows messaging is much more efficient and optimized by the OS.
2) Try offloading the callback to another thread.
As for Delphi, I've never used it.
What is your busload on the CAN network you're trying to read everything from and what speed are you running (250, 500, 1M, etc)? I can tell you that nearing 70-100% busload on a 250k CAN network will make a boat anchor out of my PC, if it tries to process all the data. Not to mention you are trying to record it... which requires flushing to a file every now and then.
David
|
|
|
|
|
In the area of raw ability to crunch numbers, how does .NET technology compare with old fashioned C++? So for example if I wanted to render a fractal would CLR do that well? The reson is that .NET will lend itself perfectly to user customisation of modules in my graphics program because I can have it recompile after the user has edited the code, allowing huge flexibility. But is .net up to the task?
Joel Holdsworth
|
|
|
|
|
|
|
I used an ActiveX Object in my VB6 project like this:
obj = CreateObject("AAA.BBB");
When I tried to do the same thing in C# .Net project, I can't not find this object in "Add reference" dialog.
Does anyone know why?
Thanks in advance!
|
|
|
|
|