Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: .Net Remoting return Object help Pin
bmasephol2-Jul-04 3:06
bmasephol2-Jul-04 3:06 
GeneralWhy Add and Remove button of propertyGrid disabled Pin
god4k1-Jul-04 6:48
god4k1-Jul-04 6:48 
GeneralRe: Why Add and Remove button of propertyGrid disabled Pin
Heath Stewart2-Jul-04 2:29
protectorHeath Stewart2-Jul-04 2:29 
General_42TabbedControl Validation Pin
RobertVG1-Jul-04 5:18
RobertVG1-Jul-04 5:18 
GeneralTabbedControl Validation Pin
RobertVG1-Jul-04 11:32
RobertVG1-Jul-04 11:32 
GeneralWindows Forms and Role Based Security Pin
OMalleyW1-Jul-04 5:14
OMalleyW1-Jul-04 5:14 
GeneralWord 2003 Pin
Giles1-Jul-04 4:34
Giles1-Jul-04 4:34 
QuestionHow to find out printable area? Pin
Pain_Elemental1-Jul-04 4:19
Pain_Elemental1-Jul-04 4:19 
I'm trying to find out the printable area of my printer.

The first try was this:
void OnPrintPageBoard(object obj, PrintPageEventArgs ppea)
{
    Graphics   grfx  = ppea.Graphics;
    grfx.PageUnit = GraphicsUnit.Millimeter;

    RectangleF rectf = new RectangleF(
        ppea.MarginBounds.Left -
        (ppea.PageBounds.Width - grfx.VisibleClipBounds.Width) / 2,
        ppea.MarginBounds.Top -
        (ppea.PageBounds.Height - grfx.VisibleClipBounds.Height) / 2,
        ppea.MarginBounds.Width,
        ppea.MarginBounds.Height);

    Pen myPen = new Pen(Color.Black,1);
    grfx.DrawRectangle(myPen,rectf.X, rectf.Y,rectf.Width,rectf.Height);
}


But this didn't work at all.
Second try was this:
void OnPrintPageBoard(object obj, PrintPageEventArgs ppea)
{
    Graphics   grfx  = ppea.Graphics;

    RectangleF rectf = new RectangleF(
        ppea.MarginBounds.Left -
        (ppea.PageBounds.Width - grfx.VisibleClipBounds.Width) / 2,
        ppea.MarginBounds.Top -
        (ppea.PageBounds.Height - grfx.VisibleClipBounds.Height) / 2,
        ppea.MarginBounds.Width,
        ppea.MarginBounds.Height);

    //get printable area in millimeters
    double dPrintableAreaX  = PrinterUnitConvert.Convert(rectf.X, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter)/10;
    double dPrintableAreaY  = PrinterUnitConvert.Convert(rectf.Y, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter)/10;
    double dPrintableAreaWidth  = PrinterUnitConvert.Convert(rectf.Width, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter)/10;
    double dPrintableAreaHeight  = PrinterUnitConvert.Convert(rectf.Height, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter)/10;

    //switch output to millimeters
    grfx.PageUnit = GraphicsUnit.Millimeter;

    Pen myPen = new Pen(Color.Black,1);
    grfx.DrawRectangle(myPen, (float)dPrintableAreaX, (float)dPrintableAreaY, (float)dPrintableAreaWidth, (float)dPrintableAreaHeight);
}


This worked, but the rectangle is way smaller than I expected! If I draw for example like grfx.DrawRectangle(myPen, 0, 0, 100, 100), the rectangle is more at the border of the page.


I also don't understand, why the values of the rectf of my first example don't have the same value as dPrintableAreaX,dPrintableAreaY,dPrintableAreaWidth,dPrintableAreaHeight of my second example. Should be millimeters either way, shouldn't it?

Best Regards
Bernd R.

The light at the end of the tunnel has been switched off temporarily due to budget problems...
AnswerRe: How to find out printable area? Pin
Pain_Elemental1-Jul-04 4:37
Pain_Elemental1-Jul-04 4:37 
AnswerRe: How to find out printable area? Pin
misterbear1-Jul-04 23:05
misterbear1-Jul-04 23:05 
GeneralDTS package Pin
Member 11509011-Jul-04 2:47
Member 11509011-Jul-04 2:47 
GeneralRe: DTS package Pin
Nick Parker1-Jul-04 4:07
protectorNick Parker1-Jul-04 4:07 
GeneralPocket PC\Telnet Pin
Schkin30-Jun-04 23:43
Schkin30-Jun-04 23:43 
GeneralRe: Pocket PC\Telnet Pin
Mike Dimmick1-Jul-04 0:04
Mike Dimmick1-Jul-04 0:04 
GeneralThe FlexGrid component Pin
saud_a_k30-Jun-04 23:34
saud_a_k30-Jun-04 23:34 
GeneralRe: The FlexGrid component Pin
Nick Parker1-Jul-04 4:18
protectorNick Parker1-Jul-04 4:18 
GeneralRe: The FlexGrid component Pin
saud_a_k1-Jul-04 18:19
saud_a_k1-Jul-04 18:19 
GeneralRe: The FlexGrid component Pin
saud_a_k1-Jul-04 23:44
saud_a_k1-Jul-04 23:44 
GeneralBefore Resize Pin
bouli30-Jun-04 22:55
bouli30-Jun-04 22:55 
GeneralRe: Before Resize Pin
Heath Stewart1-Jul-04 4:56
protectorHeath Stewart1-Jul-04 4:56 
GeneralRe: Before Resize Pin
bouli1-Jul-04 5:00
bouli1-Jul-04 5:00 
GeneralRe: Before Resize Pin
Dave Kreskowiak1-Jul-04 5:24
mveDave Kreskowiak1-Jul-04 5:24 
GeneralRe: Before Resize Pin
bouli1-Jul-04 5:35
bouli1-Jul-04 5:35 
GeneralRe: Before Resize Pin
Dave Kreskowiak1-Jul-04 5:49
mveDave Kreskowiak1-Jul-04 5:49 
GeneralRe: Before Resize Pin
bouli1-Jul-04 5:44
bouli1-Jul-04 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.