|
|
Hi,
Thanks for your help and very valuable suggestion
Now I developed a service that can pause my documents came for printing.This should also be done when a new document came for printing.
But how to achieve this Iam unable to do it.
for example...
I have given a document1,document2 for printing....then if i manually start my service it is making them into pause state..this is fine
But again a new one say document3 came for printing...Iam unable to make it to Pause state..Iam lacking here..
So I want to make my servcie work in such a way that it should identify a new document arrival for printing ..and automatically make it to pause state
If I have to make a scheduler what I have to write in that?
Kindly help me for that...
|
|
|
|
|
Sytem wide processes monitoring is complicated .
So did u try to put hook on the driver or the spooler ?
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
|
FindFirstPrinterChangeNotification
http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2005-10/msg00013.html
http://msdn.microsoft.com/en-us/library/ms535514(VS.85).aspx
http://binaryworld.net/Main/CodeDetail.aspx?CodeId=3643
PRINTER_INFO_1 contains the page number information for the pritner job
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
hi all,
i write the following code for extract the data from a database, data also retrieved but there is a problem ...code is here
OracleConnection dataConnection = new OracleConnection();
ArrayList objList = new ArrayList();
try
{
dataConnection.ConnectionString = "Data Source=orc;Persist Security Info=True;User ID=scott;Password=tiger;Unicode=True";
dataConnection.Open();
OracleCommand datacommand = new OracleCommand("SELECT * FROM DEPT", dataConnection);
OracleDataReader datareader = datacommand.ExecuteReader();
Dept d = new Dept();
while (datareader.Read())
{
d.DNAME = datareader["DNAME"].ToString();
d.DEPTNO = datareader["DEPTNO"].ToString();
d.LOC = datareader["LOC"].ToString();
objList.Add(d);
}
datareader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
dataConnection.Close();
}
try
{
cmbDname.DataSource = objList;
cmbDname.DisplayMember = "DNAME";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
but i amazed ......all filled data of combobox is same i.e DNAME
like : OPERATIONS (which is last row of DEPT table)
because
objList store only last data (OPERATIONS)........
but when i replace
objList.Add(d); with
objList.Add(d.DNAME); then objList store different DNAME..........but this time objList has only one colum <dname>....
my problem is that how can i store whole row in objList
|
|
|
|
|
Hi,
You actually create only one Dept object which is added to the list many times. So switch from
...
Dept d = new Dept();
while (datareader.Read())
{
...
to
...
Dept d;
while (datareader.Read())
{
d = new Dept();
...
Hope this helps,
Mika
p.s. Do not cross-post
|
|
|
|
|
i try
Dept d;
while (datareader.Read())
{
d = new Dept()
but fail i think problem is here .......
class Dept
{
public static string Deptno;
public static string Dname;
public static string Loc;
public string DNAME
{
get { return Dname; }
set { Dname = value; }
}
public string DEPTNO
{
get { return Deptno; }
set { Deptno = value; }
}
public string LOC
{
get { return Loc; }
set { Loc = value; }
}
}
|
|
|
|
|
What is the error message?
Mika
|
|
|
|
|
there is no syntax error ....there is a logical error..........
"objList" replace the previous data with new data on every loop....and that is problem....
|
|
|
|
|
Yes, the problem is in Dept class. Don't use static keyword on the fields containing the data since there is only one copy of the data.
Also it would make sense to protect the fields since you have public properties for setting and getting the field value.
class Dept {
private static string Deptno;
private static string Dname;
private static string Loc;
public string DNAME {
get { return Dname; }
set { Dname = value; }
}
public string DEPTNO {
get { return Deptno; }
set { Deptno = value; }
}
public string LOC {
get { return Loc; }
set { Loc = value; }
}
}
Hope this helps,
Mika
|
|
|
|
|
Mika beat me to it.
Yeah....applying the static modifier to the properties in your class makes it so that the "Department" class will maintain a SINGLE value for all instances of that class.
if you remove "static" as Mika suggested, you should be able to restructure your code as such to provide the functionality you're requesting:
ArrayList departments= new ArrayList();
Dept department;
while(reader.Read)
{
department = new Dept();
department.DName = reader["DepartmentName"]
department.DEPTNO = reader["DepartmentNumber"]
departments.Add(department);
}
One suggestion, simply from a coding style perspective: Don't abbreviate things that don't need to be abbreviated(unless you have some unknown technical limitation) Your objects are obviously being used for storing Department data, so why is your class not called "Department" ?
Your "DName" property would more appropriately be called "DepartmentName", but then again, with your class already named "Department", why would you need to restate the owner of the name? With a property of "Name", your object interface would be cleaner
department.Name;
"I need build Skynet. Plz send code"
|
|
|
|
|
thanks...thanks.........i (you) solve the problem
|
|
|
|
|
You're welcome
Mika
|
|
|
|
|
Using VS2005:
I've created a form, added a label control, and when I try to show it in my app, the label control is invisible, and the spot where it should be on the form is transparent (I can see the window contents of the window under the form).
I have not changed ANY properties in the form or the control. I'm using Form.Show() to display the form (I want it modeless).
BTW, if I use ShowDialog() to display it, calling Form.Close() does not dismiss the form (but calling Close() does work when I use Form.Show() ).
What have I done?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Wednesday, July 30, 2008 12:19 PM
|
|
|
|
|
Hi,
Can you post the designer.cs code? It would be easier to try to find out the reason.
Mika
|
|
|
|
|
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
this.label1.BackColor = System.Drawing.Color.White;
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label1.CausesValidation = false;
this.label1.Font = new System.Drawing.Font("Arial", 9.75F,
((System.Drawing.FontStyle)
((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))),
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.DarkRed;
this.label1.Location = new System.Drawing.Point(47, 128);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(198, 24);
this.label1.TabIndex = 0;
this.label1.Text = "Loading program. Please wait...";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Lime;
this.CausesValidation = false;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SplashPanel2";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.TransparencyKey = System.Drawing.Color.Lime;
this.ResumeLayout(false);
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
This is really odd,
Try to remove the TransparencyKey for the form. That corrected the problem for me, but then again the result isn't what you want.
[Modification starts]
Found this one which could be useful to you
http://support.microsoft.com/kb/820640/en-us?spid=7796&sid=195[^]
[Modification ends]
Mika
modified on Wednesday, July 30, 2008 1:47 PM
|
|
|
|
|
That was happening *before* I changed the transparency key.
As a test, I create a new form and added a label to it. I changed none of the properties. I compiled and ran the app, and it still looks like i described.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hope you noticed the link I added to my previus post (we posted simultaneously )
I tried the same but the second form was acting nicely. However I may have some differences in setup (vista, vs2005+vs2008 etc) which could affect the result.
I also added SetStyle(ControlStyles.DoubleBuffer, false); to the constructor of the form (which has the problem-label) and after that the label is drawing fine, but I still cannot click the window. If I try, the object under the window is receiving click
Are you experiencing the same?
Mika
|
|
|
|
|
It works for me John (XP + VS2008) using the code you posted below. I just see the label (black border, white background and DarkRed text), the form is invisible.
John Simmons / outlaw programmer wrote: BTW, if I use ShowDialog() to display it, calling Form.Close() does not dismiss the form (but calling Close() does work when I use Form.Show()).
Where are you calling Close() from?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
It's a splash panel that is displayed during program initialization. I use a BackgroundWorker object to instantiate/close the form. Here's the code for the worker thread:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Threading;
namespace DownloadablePlayer
{
public partial class vPopcornPlayer : Form
{
BackgroundWorker m_splashWorker = new BackgroundWorker();
private void ShowSplashScreen()
{
m_splashWorker.WorkerReportsProgress = false;
m_splashWorker.WorkerSupportsCancellation = true;
m_splashWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(splashWorker_DoWork);
m_splashWorker.RunWorkerAsync();
}
private void HideSplashScreen()
{
if (m_splashWorker.IsBusy)
{
m_splashWorker.CancelAsync();
Thread.Sleep(500);
}
}
private void splashWorker_DoWork(object sender,DoWorkEventArgs e)
{
BackgroundWorker thisWorker = sender as BackgroundWorker;
SplashPanel2 splashPanel = new SplashPanel2();
splashPanel.Show();
while (!thisWorker.CancellationPending)
{
Thread.Sleep(500);
}
splashPanel.Close();
splashPanel.Dispose();
}
}
}
I call ShowSplashScreen() and HideSplashScreen() from a function elsewhere in the form. As you can see there's not a lot going on here. I fail to see why it won't work for me.
If I substitute splashPanel.Show() with splashPanel.ShowDialog() , the form is displayed, but then I can't seem to close it.
I hate .Net.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I hate .Net
LOL!
Will have a look at it in the morning (UK) and see if can figure out what's going on.
At first glance - it's not the way I handle splash forms myself (your way may be better!). I show the splash screen modally from the main form and have a backgroundworker on the splash screen which does the initialisation/loading etc. That way a simple ShowDialog() in the main form launches it and in the splash the RunWorkerCompleted calls a method which calls Close() and the main form is returned to automatically.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
My way is different, not necessarily better.
I'm going to take the code home tonight and run it under both VS2005 and VS2008, and see if I can duplicate the problem.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Just so you know, I figured out how to fix it (and posted a new message about it in this forum).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|