|
As suggested, please read this[^] first.
Tell us what you did and what the exact problem is, then we can give you tips or hints for a solution.
No one here will never ever write a solution for you. If you want that go here[^].
|
|
|
|
|
Friends, i need a code to make the function queue, deletions at the beginning and at the end inclisões. This code works correctly as Stack. I need it to work as a queue. Please
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Pilha
{
private int[] valores;
private int topo;
public Pilha(int n)
{
if (n > 0)
{
valores = new int[n];
topo = -1;
}
}
public int Push(int valor)
{
if (topo < valores.Length - 1)
{
topo++;
valores[topo] = valor;
return 0;
}
return -1;
}
public int Pop()
{
if (topo >= 0)
{
int valor = valores[topo];
topo--;
return valor;
}
else return -1;
}
public string ImprimirPilha()
{
string saida = "\t";
if (topo >= 0)
{
for (int i = topo; i >= 0; i--)
{
saida = saida + valores[i] + "\n\t";
}
return saida;
}
else return "\tPilha Vazia";
}
}
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Pilha pilha = new Pilha(5);
int sair = 0;
string imprime = "";
while (sair == 0)
{
imprimeOpcoes();
int opcao = int.Parse(Console.ReadLine());
if (opcao == 0)
{
sair = 1;
}
else
if (opcao == 1)
{
Console.Clear();
Console.WriteLine("Digite um numero para inserir na pilha\n");
pilha.Push(int.Parse(Console.ReadLine()));
imprime = pilha.ImprimirPilha();
Console.WriteLine(imprime);
}
else
if (opcao == 2)
{
Console.Clear();
pilha.Pop();
imprime = pilha.ImprimirPilha();
Console.WriteLine(imprime);
}
else
if (opcao == 3)
{
Console.Clear();
imprime = pilha.ImprimirPilha();
Console.WriteLine(imprime);
}
}
}
static public void imprimeOpcoes()
{
Console.WriteLine("\nEscolha uma opção:\n");
Console.WriteLine("Sair digite 0");
Console.WriteLine("Inserir na pilha digite 1");
Console.WriteLine("Tirar da pilha digite 2");
Console.WriteLine("Imprimir pilha digite 3\n");
}
}
}
|
|
|
|
|
What exactly is your question? I hope you're not asking for someone to rewrite this for you?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
You do know that there's a Queue[^] collection in the System.Collections.Generic namespace, don't you?
You're kind of trying to reinvent the wheel here.
|
|
|
|
|
I'm guessing that's the whole idea - Computing Basics homework.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
After looking at it again, you're probably correct.
|
|
|
|
|
Hello everybody!
i need a code that allows me to listen to event log using my application c#
i want my application to be able to detect if an events is raised!
for exemple :
the event : Source == DNS Clients events & Event_ID ==1014
thank you !
|
|
|
|
|
What have you tried? Where are you stuck?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
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.
|
|
|
|
|