473,378 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Screen logger class

How to create screen logger class from WinForms application.

It should have the following methods:

Open() - creates a window in screen
Writeln(string s) - writes text to this window
Close() - closes the window

The issue is with Open() function.
How to create a window which remains in screen and allows to write log text
into it?

Andrus.

Jul 23 '07 #1
6 2133
Hi,

You can just open a new windows form that contains only a textbox, then you
can write to it as needed.

Not sure if this will solve your problem.
"Andrus" <ko********@hot.eewrote in message
news:Og**************@TK2MSFTNGP06.phx.gbl...
How to create screen logger class from WinForms application.

It should have the following methods:

Open() - creates a window in screen
Writeln(string s) - writes text to this window
Close() - closes the window

The issue is with Open() function.
How to create a window which remains in screen and allows to write log
text into it?

Andrus.

Jul 23 '07 #2
Ignacio,

Thank you.
I think this solves the issue.
I'nt it better to write to the form area directly ?

Where to find some sample code which implements this ?

Andrus.
You can just open a new windows form that contains only a textbox, then
you can write to it as needed.

Not sure if this will solve your problem.
"Andrus" <ko********@hot.eewrote in message
news:Og**************@TK2MSFTNGP06.phx.gbl...
>How to create screen logger class from WinForms application.

It should have the following methods:

Open() - creates a window in screen
Writeln(string s) - writes text to this window
Close() - closes the window

The issue is with Open() function.
How to create a window which remains in screen and allows to write log
text into it?

Andrus.

Jul 23 '07 #3
You can just open a new windows form that contains only a textbox, then
you can write to it as needed.
I created the following form for logging.
Howver, messages are not shown. Why ?
How to implement scrolling when writing to last line in login form?

Andrus.
using System;
using System.Windows.Forms;
using System.IO;

class main {
[STAThreadAttribute()]
public static void Main() {

LoginForm f = new LoginForm();
f.Show();

f.Writeln("Login message 1");
f.Writeln("Login message 2");
MessageBox.Show("");

}

class LoginForm : Form {

int vpos = 0;

public void Writeln(string s) {

Label l = new Label();
l.Visible = true;
l.Text = s;
l.Top = vpos;
vpos += 20;
}
}
}

Jul 23 '07 #4
Look at TextBox.ScrollToCaret()

Jul 23 '07 #5
Look at TextBox.ScrollToCaret()

thank you.
i tried listbox and this seems to solve the scolling issue.

Is this code best way to create scrolling logging window ?

Andrus.

using System;
using System.Windows.Forms;
using System.IO;

class main {
[STAThreadAttribute()]
public static void Main() {

LoginForm f = new LoginForm("Performing task x");

for (int i = 0; i <= 100; i++) {
f.Writeln("Login message " + i.ToString());
}
MessageBox.Show("");

}

class LoginForm : Form {

ListBox lb;

public LoginForm(string s) {
Text = s;
Left = 0;
Top = FindForm().Height / 2;
Height = FindForm().Height/2;
Width = FindForm().Width;
lb = new ListBox();
lb.Dock = DockStyle.Fill;
this.Controls.Add(lb);
Show();
}

public void Writeln(string s) {
lb.Items.Add(s);
if (Control.ModifierKeys != Keys.Control) lb.TopIndex =
lb.Items.Count - 1;
}
}
}

Jul 23 '07 #6
* Andrus wrote, On 23-7-2007 18:51:
>Look at TextBox.ScrollToCaret()

thank you.
i tried listbox and this seems to solve the scolling issue.

Is this code best way to create scrolling logging window ?
I'm not sure what FindForm() does exactly, but calling it 3 times in a
row might be a little overdone.

I'd replace that by:

Form foundForm = FindForm();
Top = foundForm .Height / 2;
Height = foundForm .Height/2;
Width = foundForm .Width;

Jesse
>
Andrus.

using System;
using System.Windows.Forms;
using System.IO;

class main {
[STAThreadAttribute()]
public static void Main() {

LoginForm f = new LoginForm("Performing task x");

for (int i = 0; i <= 100; i++) {
f.Writeln("Login message " + i.ToString());
}
MessageBox.Show("");

}

class LoginForm : Form {

ListBox lb;

public LoginForm(string s) {
Text = s;
Left = 0;
Top = FindForm().Height / 2;
Height = FindForm().Height/2;
Width = FindForm().Width;
lb = new ListBox();
lb.Dock = DockStyle.Fill;
this.Controls.Add(lb);
Show();
}

public void Writeln(string s) {
lb.Items.Add(s);
if (Control.ModifierKeys != Keys.Control) lb.TopIndex =
lb.Items.Count - 1;
}
}
}
Jul 23 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ville Vainio | last post by:
Just posting this for the sake of google: Like everyone else, I figured it's time to start using the 'logging' module. I typically want to dump "info" level (and up) log information to...
0
by: Laszlo | last post by:
Hi I need a GL::Logger wich implements Class::Singleton to be a singleton and Log::Log4perl to can log amy message into a file. Here is the module source:...
6
by: Logger | last post by:
Help, Want someone's option. I'm calling a popup screen, say form B, to add/edit a record. In, say form A, I call form B using javascript window.open in server side code. I need to know when I...
1
by: rodsatt | last post by:
Hi, This is my first post, and I got questions about logging. When something happen within an object, and if I would like to log the event, what would be a good way to do it? 1. I make the...
10
by: Gary Jefferson | last post by:
Suppose I have 3 modules that belong to a project, 'A', 'A.a' and 'B', and each module has its own logger, created with: module1logger = logging.getLogger('project.A') and module2logger =...
4
by: garyjefferson123 | last post by:
Suppose I have some sort of context variable that I want to appear in log messages. E.g.: logger = logging.getLogger("somelogger") class SomeOp: def __init__(self, ctx): self.ctx = ctx def...
4
by: skunkwerk | last post by:
i'm redirecting the stdout & stderr of my python program to a log. Tests i've done on a simple program with print statements, etc. work fine. however, in my actual program i get weird output like...
1
by: Matimus | last post by:
Yes but in the other hand :http://docs.python.org/library/logging.html#logger-objects That is part of the power of the logging module. If you ask for a logger of the same name in two different...
0
by: archwn | last post by:
Dear all, I would like to create a custom logger which allows logging commands in stream-style, but at the same time the output goes to some file or to the screen (cout) or to both. The code below...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.