|
EventLog MyNewLog = new EventLog("System", ".", "DNS Client Events");
MyNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
MyNewLog.EnableRaisingEvents = true;
signal = new AutoResetEvent(true);
Console.ReadLine();
}
public static void MyOnEntryWritten(object source, EntryWrittenEventArgs e)
{
if (e.Entry.InstanceId == 1014 || e.Entry.Source.Equals("DNS Client Events"))
{
MessageBox.Show("ERROER Event Raised");
}
}
|
|
|
|
|
First, why/how is the EntryWritten EventHandler working/not working for you /
CodeProject has many articles on using the System EventLog, like: "Enhanced EventLog writing for .NET Applications:" [^].
Also see: [^].
“I speak in a poem of the ancient food of heroes: humiliation, unhappiness, discord. Those things are given to us to transform, so that we may make from the miserable circumstances of our lives things that are eternal, or aspire to be so.” Jorge Luis Borges
modified 15-May-14 19:52pm.
|
|
|
|
|
Hi,
Is there a way to override the painting of a WinForms listbox's internal scrollbar ? (yes, WPF may be the solution, but I can't use it in my current project)
I've already done some researches but I didn't manage to find any solution
I think that the best solution would be to paint inside the WndProc method, but I don't know which message has to be intercepted...
May someone give me some advice or just a little tip ?
Thanks in advance
|
|
|
|
|
See this[^] article.
/ravi
|
|
|
|
|
Thanks for your link Ravi, but this component will not replace the internal scrollbar of the listbox...
It could be a solution to create my own usercontrol with a listbox and such a scrollbar, but I'll have to rewrite all listbox's methods to have my usercontrol having the same behavior as a classic listbox
|
|
|
|
|
I am able to find the Parent Window & its Child Windows, even I can find the position of the Parent Windows ... I can't find the position a its Child Window & its Child items (Button, Text Box ...)
1. The following codes to help me pinpoint the Parent & its Child Window:
IntPtr hwnd;
hwnd = FindWindow("ParentClass", "ParentTitle");
WindowsEnumerator enumerator = new WindowsEnumerator();
foreach (ApiWindow top in enumerator.GetTopLevelWindows())
{
foreach (ApiWindow child in enumerator.GetChildWindows(top.hWnd))
MessageBox.Show("Child Window = " + child.MainWindowTitle + ", Child ClassName = " + child.ClassName);
}
2. When I found an intended Child Window, I used:
IntPtr Chd_win = IntPtr.Zero;
Chd_win = FindWindowEx(hwnd_Parent, Chd_win, "ChildWindow_Class", "ChildWindow_Tiltle");
GetWindowRect(Chd_win, out rect);
MessageBox.Show("Child = " + Chd_win.ToString() + ": TopLeft_X = " + rect.Left.ToString() + ", TopLeft_Y = " + rect.Top.ToString());
*) The result shows always TopLeft_X = 0 & TopLeft_Y = 0
Anyone can help?
|
|
|
|
|
Can you find the control with Spy++? If not, then it might not be a real control, but simply a drawing.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have use AutoIt Info to monitor all Child Windows, it found them ... however I amn't sure it works for C# ( it has Class, ClassNN,Title, Name, Advanced Class ...), I did try all of them but doesn't work well!
- As you suggested I am using SPY now to see it can help!
|
|
|
|
|
By using Spy I am now able to see my intended Child Windows with Handle, Caption & Class exact like the one I used ... I try it over & returning the same x=0 & y=0!
However, the AutoiT find tool shows its position correctly!
I can't use AutoIt with the current project (C# only) ... you can help?
|
|
|
|
|
Finally I found out (for now) I can't get their coordinations x,y of the Child Window.
However, since I am able to go directly into its instance ... therefore I no more need it!
Cheers
|
|
|
|
|
Grats
Bit late reply; there's a "managed spy++" for use with .NET apps. Would help if you need to access .NET specific properties.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
overflow exception in database oledb
|
|
|
|
|
cool!
now what?
Please read this[^] before posting something.
modified 16-May-14 5:04am.
|
|
|
|
|
|
I am using a dll developed in Visual c++ in to the C# application. It works fine with Visual Studio 2005. But when using the same with Visual Studio 2012, it causes the error.
myDll.h
#ifndef _MYDLL_H
#define _MYDLL_H
extern "C" _declspec(dllexport) char* __stdcall getName();
#endif
myDll.cpp
#include "stdafx.h"
#include "mydll.h"
extern "C" __declspec(dllexport) char* __stdcall getName()
{
return "Hello !!!";
}
the above code produces the mydll.dll. I used to copy the dll into newly created c# windows application into bin/Debug directory. The c# application code is somewhat like
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace sysWinApp
{
public partial class Form1 : Form
{
[DllImport("myDll.dll")]
static extern string getName();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = getName();
}
}
}
the windows form consists of a label and a button. By clicking the button, it should display the content on the label, which is accessed from the string returned from the dll function. It works fine with VS2005 but the same didn't happen with VS2012.
The C# win app of VS2012 prompts the message that it "has stopped working".
any ideas to resolve this ?
|
|
|
|
|
I'm not sure how you ever got this working in VS2005. There are two issues.
First: You can't return a pointer to a char array that you allocated on the stack. The moment the funtion returns the memory is deallocated and a pointer to an unallocated address is returned. You need to allocate the memory using new. This implies that you need to export an additional function that receives a pointer and deletes it (to prevent memory leaks).
Second: In your C# application you define (incorrectly) that the imported function returns a (managed) string. Actually it returns a char pointer. I think you will need an unsafe block to receive the char pointer, initialize a new managed string with it and then delete the char pointer (using the function mentioned above). After that you can assign the managed string to the label.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
|
The C dll is a 32bit dll (as was your VS2005 application), while your VS2012 application is a 64bit application (or a bitness-ignoring application on a 64bit system).
|
|
|
|
|
My application is made only in English and i want to switch it to multilingual version . But instead of user changing default language in regionaal settings i gave my application a "ToolStripMenuItem" called langauge and added a submenu for Arabic , Korean and English version .
As far i am aware three things are required -:
1.Writing a code in click event of that Langauage subemenu say "Arabic"
2.Creating a corresponding resx file
3.Also i had set the Form localizable property to "True"
This is the code i added to my Program in Form1()
CultureInfo CurrentLocale;
public Form1()
{
InitializeComponent();
valueInit();
}
private void ChangeLanguage(string lang)
{
CurrentLocale = new CultureInfo(lang);
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(c, "$this");
RefreshResources(this, resources);
}
}
private void RefreshResources(Control ctrl, ComponentResourceManager res)
{
ctrl.SuspendLayout();
res.ApplyResources(ctrl, ctrl.Name, CurrentLocale);
foreach (Control control in ctrl.Controls)
RefreshResources(control, res);
ctrl.ResumeLayout(false);
}
private void englishToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangeLanguage("en-US");
}
private void arabicToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangeLanguage("ar-SA");
}
private void koreanToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangeLanguage("ko-KR");
}
Second i added a resx file called Form1.ar-SA.resx and Form1.kr-KO.resx
However when i run my application and try clicking on language Arabic it still does not change anything .
can someone please help me to find where i went wrong or what am i missing ?
diwesh saxena
|
|
|
|
|
In your ChangeLocale function, also try at the top of the function:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang);
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(lang);
|
|
|
|
|
Thanks for your investing your time . There is no ChangeLocale function ... Are you referring to Changelanguage Function ?
diwesh saxena
|
|
|
|
|
I have a WCF web service (https). Inside of that web service, I call another 3rd party web service (http) and get a large amount of data back (12MB) -- a jpg image. The client is getting an exception during my processing of that image: An existing connection was forcibly closed by the remote host. I've put logs on every line in the method and tracked it down to:
gr.DrawImageUnscaledAndClipped(img, rect);
IIS just simply kicks out the process during this call. I've tried wrapping this call in a try / catch to see the real exception, but its not throwing an exception, just simply kills the client's call with the above exception.
Anybody ever seen this before?
img is quite large jpg 32bit (9MB), 14,800 x 14,800 and the drawing surface is 15000 x 15465.
I was able to draw this large when I was calling the 3rd party web service via REST, but had to switch over to thier WCF version for added functionality. This of course comes with added overhead (img is transmitted as base64 vs. just a binary stream) and it requires running in an STA thread for some unknown reason.
I watched the server in task manager and the process craps out with the memory at about 1GB. It has gone higher then that with the REST version. I was able to process about 8 of these images at a time. Now I cannot process even 1 at a time.
The server is 64bit and has 18GB of RAM with only 11% consumed at idle.
If I comment out the DrawImage call, I get the 15000 x 15465 image back in its processed state (minus of course the content).
Any ideas? Why is IIS killing my call without even throwing an exception on the server side?
|
|
|
|
|
On what exactly do you try and draw the image?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Hi,
Just a normal Bitmap:
Bitmap bmp = new Bitmap(cx, cy + 465);
using (Graphics gr = Graphics.FromImage(bmp))
{
gr.FillRectangle(new SolidBrush(System.Drawing.Color.White), 0, 0, cx, cy + 465);
Rectangle rect = new Rectangle((cx - img.Width) / 2, 465 + ((cy - img.Height) / 2), img.Width, img.Height);
gr.DrawImage(img, rect.Left, rect.Top);
gr.DrawImage(Properties.Resources.Header, 0, 0, cx, 465);
The second DrawImage call works fine, but thats a smaller image.
|
|
|
|
|
Yes, but you are inside a web service, so on what UI are you drawing the image?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|