|
I have a component in which the ErrorProvider is defined upon initialization of the component as:
<br />
valueErrorProvider = new System.Windows.Forms.ErrorProvider();<br />
valueErrorProvider.SetIconAlignment (this, ErrorIconAlignment.MiddleRight);<br />
valueErrorProvider.SetIconPadding (this, 2);<br />
valueErrorProvider.BlinkRate = 1000;<br />
valueErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.AlwaysBlink;<br />
<br />
components = new System.ComponentModel.Container();<br />
tltpInternal = new System.Windows.Forms.ToolTip(components);<br />
tltpInternal.ShowAlways = false;<br />
tltpInternal.InitialDelay = 250;<br />
tltpInternal.AutoPopDelay = 5000;<br />
tltpInternal.Active = false;
To set/clear the message I use the following:
private void SetErrorMessage(string msg)<br />
{<br />
this.valueErrorProvider.SetError(this, msg);<br />
tltpInternal.SetToolTip(this, msg);<br />
tltpInternal.Active = (msg.Trim().Length > 0);<br />
tltpInternal.ShowAlways = (msg.Trim().Length > 0);<br />
}
The problem is that the ErrorProvider symbol does not always show. The Tooltip is always populated as expected, the symbol just doesn't flash. If I select a different application and then go back to the application with the error, it begins to flash as expected.
Is there something I need to call to ensure the ErrorProvider will display?
|
|
|
|
|
hai
i am doing a project in which i need to trap the active window title after any event like mouse click, minimize,alt+tab,etc. I tried to use the cbt hooks but could not install a global hook. i learnt that i need to give the final parameter of SetWindowsHookEx as 0. But even then i could not install it. please help me.Urgent.
Advance Thanks to u.
|
|
|
|
|
|
The WH_CBT hooks execute in the context of the application in which the even occured...so you need to write them as a _standard_ dll so the target process can load them into its address space.
Only WH_JOURNALRECORD, WH_JOURNALPLAYBACK, WH_KEYBAORD_LL and WH_MOUSE_LL global hooks execute in the context of the hook installer app so only they are safe form .NET afaik.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
sorry i could not understand what u said.I am attaching the code that i tried please check out the error i have made and inform me.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Threading;
using System.Text;
namespace ThreadSpecificMouseHook
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
public delegate int HookProc(int nCode, Int32 wParam, IntPtr lParam);
static int hHook = 0;
public String WindowName;
public const int HCBT_ACTIVATE = 5;
public const int WH_CBT= 5;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
HookProc WindowHookProcedure;
[StructLayout(LayoutKind.Sequential)]
public class CBTACTIVATESTRUCT
{
public bool fMouse;
public int hWndActive;
}
[DllImport("user32.dll",CharSet=CharSet.Auto,
CallingConvention=CallingConvention.StdCall)]
public static extern int SetWindowsHookEx(int idHook, HookProc lpfn,
IntPtr hInstance, int threadId);
[DllImport("user32.dll",CharSet=CharSet.Auto,
CallingConvention=CallingConvention.StdCall)]
public static extern bool UnhookWindowsHookEx(int idHook);
[DllImport("user32.dll",CharSet=CharSet.Auto,
CallingConvention=CallingConvention.StdCall)]
public static extern int CallNextHookEx(int idHook, int nCode,
Int32 wParam, IntPtr lParam);
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
public static extern int GetWindowText(int hWnd, StringBuilder text, int count);
[DllImport("kernel32.dll", SetLastError=true)]
public static extern IntPtr GetModuleHandle(string lpModuleName);
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(88, 112);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(40, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1,
this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
public int WindowHookProc(int nCode, Int32 wParam, IntPtr lParam)
{
//CBTACTIVATESTRUCT myhook = (CBTACTIVATESTRUCT) Marshal.PtrToStructure(lParam,typeof(CBTACTIVATESTRUCT));
if (nCode < 0)
{
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
else
{
if (nCode == HCBT_ACTIVATE)
{
GetActiveWindow();
MessageBox.Show(WindowName);
}
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
if(hHook == 0)
{
WindowHookProcedure = new HookProc(WindowHookProc);
hHook = SetWindowsHookEx(WH_CBT,
WindowHookProcedure,
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]),
0);
//If SetWindowsHookEx fails.
if(hHook == 0 )
{
MessageBox.Show("SetWindowsHookEx Failed");
return;
}
button1.Text = "UnHook Windows Hook";
}
else
{
bool ret = UnhookWindowsHookEx(hHook);
//If UnhookWindowsHookEx fails.
if(ret == false )
{
MessageBox.Show("UnhookWindowsHookEx Failed");
return;
}
hHook = 0;
button1.Text = "Set Windows Hook";
this.Text = "Windows Hook";
}
}
public void GetActiveWindow()
{
const int nChars = 256;
int handle = 0;
StringBuilder Buff = new StringBuilder(nChars);
handle = GetForegroundWindow().ToInt32() ;
if (handle != this.Handle.ToInt32())
{
if ( GetWindowText(handle, Buff, nChars) > 0 )
{
WindowName= Buff.ToString();
}
}
}
}
}
advance thanks
|
|
|
|
|
Hi,
I think this a simple question but I have two computers that I want to be synchronized so I have attached a GPS to them so I can get the universal time (UTC). Then I want to set the local system time to the same as the resently read UTC time. I have tried with the DateTime class but I can only find read only methods there.
I hope someone can help me with this problem.
Thanks in a million
|
|
|
|
|
Try P/Invoking SetSystemTime as the following:
[Serializable, StructLayout(LayoutKind.Sequential)]
private struct SYSTEMTIME
{
[MarshalAs(UnmanagedType.U2)] public short Year;
[MarshalAs(UnmanagedType.U2)] public short Month;
[MarshalAs(UnmanagedType.U2)] public short DayOfWeek;
[MarshalAs(UnmanagedType.U2)] public short Day;
[MarshalAs(UnmanagedType.U2)] public short Hour;
[MarshalAs(UnmanagedType.U2)] public short Minute;
[MarshalAs(UnmanagedType.U2)] public short Second;
[MarshalAs(UnmanagedType.U2)] public short Milliseconds;
}
[DllImport("kernel32.dll")]
static extern bool SetSystemTime(ref SYSTEMTIME time);
- Nick Parker My Blog | My Articles
|
|
|
|
|
What Nick told you is correct, but note that this isn't really a good way to synchronize the machines. Yes, the time on each machine would be the same (within a certain margin, taking into account network lag), but that doesn't mean they're accurate. You should use an NTP server, which is a time client that eventually synchronizes with the atomic clock (or whatever they're using now for an accurate decay rate; I heard they changed it or where planning on changing it).
Windows XP has an NTP client built-in and set to time.windows.com, IIRC. If you're on a corporate network, most likely your network administrators have set up your DHCP server (if using a dynamic address space, which most corporate networks do) to broadcast time servers). You can also get free or cheap NTP clients on the 'net - just try searching for some on google[^].
This is by far a better approach. The longer the NTP client runs the more accurate the time is and both machine clocks will be in sync by the nature of NTP. NTP also takes into account time zones which is a necessary step in ensuring that time is accurate.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Having trouble exporting data from DataReader from access database to csv file
|
|
|
|
|
Can you be more specific?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Sorry,
Thanks for the advise... i'll give better details next time
Have worked out my problems anyhow.
|
|
|
|
|
Digger27 wrote:
Having trouble exporting data from DataReader from access database to csv file
Again, like Colin said we need more info. This shouldn't be hard and both Heath and I have discussed this issue in the past in this forum. Take a look at the following[^] post (similar concept) as well as Heath's[^] response too. Hopefully this will get you started.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Can someone please help me i would like to be able to send and retrieve data from the ISA slot (i am making an IO card and would like to use C# as the controling software)
Are there any classes avaliable that would allow such bus access in an XP enviroment
Any help or ideas would be greatly aprieciated
|
|
|
|
|
zaarzzz wrote:
Are there any classes avaliable that would allow such bus access in an XP enviroment
No, NT-based OS's will NOT allow you to this directly. You will the Windows DDK AFAIK, and write your own driver and start praying (alot)!
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Hi,
Can C# export a report (created using Crystal Reports 9) to multiple excel files automatically (in background)?
Because the report is to big for only one excel file, so i need to split it into more than 1 excel files.
Thank you for the help.
|
|
|
|
|
What I use to do for exporting is exporting HTML file but under XLS extension (Excel can understand HTML).
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition","attachement; filename=\"SomeFile.xls\"");
That is the code that I entered in my Page_Load. Everything works fine after that
If someone says "Die mortal!", don't stay to see if he isn't.
|
|
|
|
|
Hi,
I am having the following problem with a richtextbox. I have files that I read into it that often contain one line that may be 1 million characters or more.
When I read these long lines in, the line is displayed on multiple lines in the richtextbox. Each display line seems to break at around 3066 characters. (Reading these into an application like notepad, will give me what I am looking for which is a one line display).
All I'm really doing in the code is opening the file using a streamreader and reading it with ReadLine(). Looking at the richtextbox.Text property, all looks well until it displays.
I'd appreciated any tips you may have.
Thanks
Dave
|
|
|
|
|
Are you sure it's the number of characters? All control's are limited in height and width by int16.MaxValue (32767). If you try to draw anything beyond those borders, it will be clipped. Perhaps this is what you're seeing with the RTB?
Judah Himango
|
|
|
|
|
Why would you want to load up one line of any TextBox with over a million characters? What purpose could that possibly serve?
Look into just adding the first, say couple hundred characters of the line into the RichTextBox. If you need to append all these things together and your using the RichTextBox to do this, don't. Use the RichTextBox for displaying information and then write your code for appending the data together.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I do a lot of work with EDI files that in many cases aren't sent with \r\n delimiters and often it's useful to do a quick scan of the entire line as it was sent- so that's the main reason.
As I mentioned before applications sucha as notepad, TextPad or VS.NET can read something like this into a single line. But I'm obviously missing something.
It would seem to me that just assigning to the Text property or Lines property, that string would do the trick, but it doesn't.
Also, as to Judah's point, I'm not sure that it is related to the number of characters, that 3066(+/- a few characters) is just where my line keeps breaking at.
Thanks
Dave
|
|
|
|
|
I have a File with NODES (x and y values).
Is it possible to draw a line with this nodes , and can someone show me how to do it (read it from file and draw)? I am beginer
I would like to have it in my form, schould I create Pannel to draw on it or how
This is how my file looks like
1 0.0000E+00 -0.4396E+01
2 0.1136E+01 -0.4506E+01
3 0.2217E+01 -0.4706E+01
4 0.3290E+01 -0.4953E+01
5 0.4355E+01 -0.5230E+01
6 0.5409E+01 -0.5519E+01
7 0.6447E+01 -0.5808E+01
8 0.7472E+01 -0.6075E+01
9 0.8488E+01 -0.6324E+01
10 0.9492E+01 -0.6548E+01
11 0.1049E+02 -0.6749E+01
12 0.1147E+02 -0.6926E+01
13 0.1245E+02 -0.7086E+01
14 0.1343E+02 -0.7230E+01
15 0.1440E+02 -0.7360E+01
16 0.1538E+02 -0.7476E+01
17 0.1636E+02 -0.7568E+01
18 0.1735E+02 -0.7649E+01
19 0.1833E+02 -0.7719E+01
20 0.1931E+02 -0.7782E+01
21 0.2030E+02 -0.7836E+01
22 0.2130E+02 -0.7869E+01
23 0.2230E+02 -0.7902E+01
24 0.2331E+02 -0.7936E+01
25 0.2431E+02 -0.7969E+01
26 0.2532E+02 -0.8003E+01
27 0.2632E+02 -0.8036E+01
28 0.2733E+02 -0.8070E+01
29 0.2833E+02 -0.8103E+01
30 0.2934E+02 -0.8137E+01
31 0.3034E+02 -0.8170E+01
32 0.3134E+02 -0.8204E+01
33 0.3235E+02 -0.8237E+01
34 0.3335E+02 -0.8271E+01
35 0.3435E+02 -0.8336E+01
36 0.3535E+02 -0.8404E+01
37 0.3635E+02 -0.8474E+01
38 0.3735E+02 -0.8547E+01
Thanx, .a.d.o.
|
|
|
|
|
Well, this is a multi part question really.
Where are you getting stuck on? Or are you needing assistance with some design as well?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
OK
I am creating a little win application, in which I can select Input and Output Files for calculations I need. Calculation runs as a extern EXE File.. After ewerything is done, as result I get one text file where I can find data about NODEs (points) (x and y data). Now in my app, I need to create plot (drawing) in one pannel or something like that, a LINE which goes thrue my nodes..
I need to load this nodes file, (read it) and somehow create that plot..
And that is only for one moment, in next moment I have another Nodes position, and my LINE has changed.. So I taught, if I can do it for one time step (moment) I would change those pannels and so have something like an Animation..
|
|
|
|
|
Okay, if I understand you correctly you want to draw a line between nodes 1 and 2, then a moment later between 3 and 4 and so on?
Reading the file should be fairly easy:
ArrayList nodes = new ArrayList();
try
{
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
string[] values = line.Split(' ');
double x = Convert.ToDouble(values[1]);
double y = Convert.ToDouble(values[2]);
PointF node = new Point(x, y);
nodes.Add(node);
}
}
}
catch (Exception e)
{
}
DISCLAIMER: I typed this directly into the browser, there may be syntax errors.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
In one moment I need line thrue all points, in next moment I get another node set (in my file are meny node sets for diferent moments (time steps), and I should draw a whole new line.. As result I should have an Animation, where one line getting deformed (changes shape).. At first it is straight (First time step-moment):
.................................................. at the End (last step) it should looks like:
......
. .
............... .................. (something like that
I hope that U understand, I appologise about my poor English
|
|
|
|
|