|
Hi all
I am new to the site and sorry if I have posted on the wrong forum.
Basically I am a web developer and dealing first time with the windows application.
I need to create a custom printer via coding and add it to the list and made it available to the user whenever the user clicks on the print from the file menu.
I am using visual studio 2005 with vb.net .
Well this is the first step.
please help me. Any clues and suggestions will be highly appreciable.
Thanks
-- Palli
|
|
|
|
|
Your application should not be installing printers at all. This is either a pre-req that needs to be installed prior to running your app, or possibly even something that is installed with your application, but should not be done at run-time. There are plenty of cases where users may not be able to install printers. Since a Windows app runs as the user, it has no more permissions to the system that the user does.
|
|
|
|
|
Can I assume you're not creating a "real" printer, but a virtual one...
sort of similar to the "Send to OneNote" and "Microsoft XPS Document Writer" printers?
|
|
|
|
|
Thanks to all of you for your suggestions.
Ok..I think I should provide enough details to clear the scenario.
I need to create a custom "print to pdf" driver that when installed on a machine would appear in the print dialog of any application. When the users click on the print button, they will have an option to choose this printer. When they choose this printer, it will prompt for a location and then save files there as a PDF file.
Hope that helps.
Looking forward for your replies.
Thanks
-- Palli
|
|
|
|
|
Further research into the topic has cleared the picture more.
I need to develop a virtual printer that would be available to the user in the print list option of any application like word etc, when the user will select the virtual printer, it will ask for the location to save the file and would then save the file on the specified location as a PDF file.
Any suggestions so that I can start working would be highly appreciable.
Thanks
|
|
|
|
|
Hello everyone..
I have managed to add a virtual printer to the printer list.
And now the task is to create a PDF from the added printer.
Any suggestions regarding ?
Could I get the drivers from somewhere for the printer that creates a PDF of the document ?
Thanks
-- Palli
|
|
|
|
|
there is no direct method of doing what you want to achieve in C#
To begin with, you'll need to write your own custom printer driver for your virtual printer to use.
You will need to do a lot of api wrapping, as there is no interface in C# to help you here.
Your best bet is to start looking into the Windows Driver Development kit and see if you can find out
exactly what you need to do.
(and expect to be writing a c++ wrapper too I guess)
|
|
|
|
|
Actually i took two panels in my user control. and the functionality is i took a button on the top panel and on alternate click of the button the second panel will visible and invisible accordingly..
When we r using this user control in a new form when the button click happen and so the second panel is disabled( i mean made invisible) the controls that are present under the user control have to move up i mean they have to adjust during run time.
Can u suggest me how to do this...
Thanks and regards...
|
|
|
|
|
Just set the top and left properties of the controls. If all controls are in panels you should just have to reposition the panel.
|
|
|
|
|
dock both panels to Top. this way, when the first panel is hidden, the second one will automatically move up without any additional code. When 2 items are docked to top, the order is determined by the z-index, i.e. use BringToFront in the designer to change the order
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
I have created a user control with a panel. I want thi panel to work as a container which can hold other controls at design time.
[Designer("System.Windows.Forms.Design.ParentControlDesigner,System.Design", typeof(IDesigner))]
I write this line before my usercontrol class. Now i am able to drag a control in to my user control but it is not acting as a child control of my user control.
For example when a drag a button on to the panel it is not visible for me but when i used to drag my user control then only it is visible. when i stop dragging my user control it is not visible and when i run this i came to know that the button is not visible for me unless the panel is made invisible during run time.. So, i came to know that the button is underlying the panel not acting as a part of the panel..
can any one help me in solving this please...
Thanks and regards
|
|
|
|
|
Hi Honey.rpk,
I've tried doing this same thing without success.
The "work-around" I found is this :
1. create a UserControl 'ucPanel
modify ucPanel so it inherits from Panel
[Designer("System.Windows.Forms.Design.ParentControlDesigner,System.Design", typeof(IDesigner))]
public partial class ucPanel : Panel
2. create a UserControl 'ucMaster : use the same Designer attribute above, but leave this a UserControl.
make sure you put references to :
using System.Drawing.Design;
using System.ComponentModel.Design;
Into both UserControls' library declarations as well as whatever else they require.
With a Form open at design-time do this :
1. drop a ucMaster on your form, and style it as you wish.
2. drop a ucPanel on your form, and move it so is "captured" by ucMaster
Now you will find you can drop controls on the ucPanel, and they will be "properly captured" at design-time which you can verify by looking at the Designer.cs code for the Form.
I realize this is not a very satisfactory solution : what you'd like to do, of course, is to design one UserControl and put elements on it like Panels (or TableLayoutPanels, or whatever other container that can "capture" controls at design-time), and then have to only drop the one UserControl on the design surface and have its sub-components also capture.
I have experimented with creating an instance of ucPanel in the constructor of the ucMaster, creating it in the load event of ucMaster, but none of these experiments work.
I'm sure there's a better way, and, hopefully, one of our "real gurus" here will comment.
best, Bill
p.s. highly recommend Matthew McDonald's book on .NET 2.0 Windows Forms and Controls[^] : Chapters 13 and 26 on design-time programming are the single best resources in this area I've found yet.
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
modified on Monday, June 29, 2009 5:27 AM
|
|
|
|
|
This[^] is what you need.
And, do not double post.
|
|
|
|
|
sorry yar i am new to this and when i posted for the 1st time i haven't found it on the screen so i tried to post it again...
|
|
|
|
|
Hi d#@nish,
Actually that article (using VB.NET) does not contain a solution to the problem the user describes.
By the way : the declaration in VB syntax in that article :
<Designer("System.Windows.Forms.Design.ParentControlDesigner, _
System.Design", GetType(IDesigner))>
Is identical in function to the attribute in C# :
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
Which the questioner has already found.
The problem described is not getting one usercontrol itself to function to "capture" other controls dragged and dropped onto it at design-time, but to deal with the question where you have one usercontrol that contains other controls that normally capture other controls (like Panels, or TableLayoutPanels).
You create a UserControl, place a Panel on it, then place the UserControl on a Form at design-time, and ONLY the UserControl will capture controls dragged on to it
Unfortunately creating another UserControl #2 (or creating a Control that derives from something like 'Panel) with the same IDesigner inheritance, and placing it at design-time on UserControl #1, and then placing UserControl #1 on a Form does NOT allow you to have UserControl #2 capture controls.
I've also tried over-riding the 'ControlAdded Event of UserControl #1 using 'OnControlAdded, which will fire at design-time, and assigning the "incoming control" to its hosted UserControl #2 : no dice there, either.
But the fact that I have tried these several experiments, does not lead me to conclude that the problem cannot be solved
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
modified on Monday, June 29, 2009 5:56 PM
|
|
|
|
|
Yes it is in VB.Net. If you download the source(with preview one) and run it, you will actually see the controls dropped into the user control. Being used to C#, I could not understand the code though (atleast not as quickly as I would understand C# one). Hence I just posted the link if the OP knows VB.
|
|
|
|
|
Hi d@nish,
There's no "debate" here about the ability in VB or C# .net to use this Designer Attribute to make a UserControl "capture" other controls at design time when it's hosted on a Form !
You seem to be missing the real issue which is how to have a UserControl have other objects on it that normally "capture" controls (like Panels, or TableLayoutPanels, or other UserControls that also have this IDesigner attribute set) : then at design-time you want not just the usercontrol to capture, but also the other controls inside the UserControl to capture.
It may be a "limit," for damn good technical reasons, of .NET that this kind of "nested" hosting of UserControls or derived Controls that have this Attribute set will not work, but that's what we'd like to know !
I suggest you re-read the OP's posts and my response and get focused
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
As far as I have understood the post, he is able to add controls into the a container in the user control (say panel). The control gets added to the user control but can not be seen at design time. It does appear while dragging the control.
I guess the code in the link does the same.
|
|
|
|
|
Here is the first few lines of a UserControl of mine, that allows me to drop controls onto it at design-time.
[
Designer(typeof(ParentControlDesigner))
]
public partial class ExplorerPanel : UserControl
{
private Image headerImage;
private bool collapsible = true;
private HeaderButton headerButton = null;
private Rectangle imageRectangle = Rectangle.Empty;
private Color panelColor;
public ExplorerPanel()
{
InitializeComponent();
SetStyle(ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint | ControlStyles.DoubleBuffer |
ControlStyles.SupportsTransparentBackColor | ControlStyles.ContainerControl, true);
this.BorderStyle = BorderStyle.None;
this.BackColor = Color.Transparent;
this.panelColor = Color.WhiteSmoke;
this.SetupHeaderButton();
}
I hope that there is enough here to enable you to get yours working properly
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank you henry for ur suggestion..
When i am trying to implement the concept of
[ Designer(typeof(ParentControlDesigner)) ]
it is showing an error like
" type or namespace couldnot found are you missing a directive or assembly reference "
So, i haven't got the thing how to implement it. can u help me regarding this....
|
|
|
|
|
To use ParentControlDesigner you will need to add two references to your project.
1) System.Windows.Forms.Design
The IDE might even suggest and add that one for you, if you click somewhere in the middle of ParentControlDesigner , you will see a small rectangle under the final 'r' move the mouse over that and select it from the options offered.
2) System.Design
You will have to add this yourself from the Solution Explorer window. There are a lot of these type of classes that use System.Design, and the only way I know to determine if it is needed is to examine the MSDN documentation.
From my Local MSDN installation
ParentControlDesigner Class
Members Example See Also Send Feedback
Extends the design mode behavior of a Control that supports nested controls.
Namespace: System.Windows.Forms.Design
Assembly: System.Design (in System.Design.dll)
From MSDN on t'web
ParentControlDesigner Class
Base designer class for extending the design mode behavior of a Control that supports nested controls.
For a list of all members of this type, see ParentControlDesigner Members.
System.Object
System.ComponentModel.Design.ComponentDesigner
System.Windows.Forms.Design.ControlDesigner
System.Windows.Forms.Design.ParentControlDesigner
System.Windows.Forms.Design.ScrollableControlDesigner
[Visual Basic]
Public Class ParentControlDesigner
Inherits ControlDesigner
[C#]
public class ParentControlDesigner : ControlDesigner
[C++]
public __gc class ParentControlDesigner : public ControlDesigner
[JScript]
public class ParentControlDesigner extends ControlDesigner
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
ParentControlDesigner provides a base class for designers of controls that can contain child controls. In addition to the methods and functionality inherited from the ControlDesigner and ComponentDesigner classes, ParentControlDesigner enables child controls to be added to, removed from, selected within, and arranged within the control whose behavior it extends at design time.
You can associate a designer with a type using a DesignerAttribute. For an overview of customizing design time behavior, see Enhancing Design-Time Support.
Requirements
Namespace: System.Windows.Forms.Design
Note that the clue is in different places depending on how you are viewing the page.
Hope this helps.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I used the same code but it is not allowing me to drop controls....
|
|
|
|
|
I have just created the simplest control that I could think of. It allows me to drop controls on to it, dock them etc. etc. etc.....
Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace ExplorerBarLibrary
{
[
Designer(typeof(ParentControlDesigner))
]
public partial class TestControl : UserControl
{
public TestControl()
{
InitializeComponent();
}
}
}
and the *.Designer.cs file
namespace ExplorerBarLibrary
{
partial class TestControl
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
private void InitializeComponent()
{
this.SuspendLayout();
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Name = "TestControl";
this.Size = new System.Drawing.Size(148, 148);
this.ResumeLayout(false);
}
#endregion
}
}
If that doesn't work for you, then there is something wrong with your system is all I can think.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
This code is working fine but i need a panel to work like this if you place a panel and try the same code the panel is not holding the controls...
You try to place a single panel as a user control and then try to implement the code such that the panel can hold the controls.. Thats what i need...
Dont think otherwise i am a beginner a trainee in a company and i am asked to do this. I am not expert in .net.
Sorry if am wrong in asking like this.....
|
|
|
|
|
honey.rpk wrote: Dont think otherwise i am a beginner a trainee in a company and i am asked to do this. I am not expert in .net.
Sorry if am wrong in asking like this.....
You are not wrong to ask, at all. Please do not think I was being rude, I was not. I am as confused as you are. I am not an expert in anything.
This next bit is a joke.
You should never aspire to be an expert. 'ex' signifies a has-been and a 'spurt' is a drip under pressure.
I will investigate the Panel thing and will get back to you whatever I find.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|