wmismail Posted June 12, 2009 Share Posted June 12, 2009 Yazımızda üzerinde çalışmakta olduğunuz yada , belirli bir sorgu sonucunda kullanıcıya aktardığınız formu nasıl yazdırabileceğimizi anlatıyor olacağız. İlk olarak formumuza bir tane buton ve printDocument nesnesi ekleyelim. Bunu dışında çıktıda görmek istediklerinizi ekleyebilirsiniz. Formun tasarım işlemi tamamlandıktan sonra formumuzun görüntüsünü resme dönüştürme işlemi ile devam edelim. [C#] [System.Runtime.InteropServices.DllImport("gdi32.dll")]public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);private Bitmap memoryImage;private void CaptureScreen(){Graphics mygraphics = this.CreateGraphics();Size s = this.Size;memoryImage = new Bitmap(s.Width, s.Height, mygraphics);Graphics memoryGraphics = Graphics.FromImage(memoryImage);IntPtr dc1 = mygraphics.GetHdc();IntPtr dc2 = memoryGraphics.GetHdc();BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);mygraphics.ReleaseHdc(dc1);memoryGraphics.ReleaseHdc(dc2);}[/CODE]Yukarıdaki fonksiyon ile formumuzun görünümünü Bitmap nesnesi olan memoryImage değişkenine atamış olduk. Şimdide butonumuza tıklandığında eklemiş olduğumuz printDocument nesnesinin print fonksiyonundan yararlanacağız.[CODE]private void button1_Click(object sender, EventArgs e){CaptureScreen();printDocument1.Print();}private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e){e.Graphics.DrawImage(memoryImage, 0, 0);}[/CODE]Tahir MUTLU Link to comment Share on other sites More sharing options...
mahoni Posted June 12, 2009 Share Posted June 12, 2009 sadece bir öneri ancak crystal report ile yazdırma yaptırmak daha kolay ve mantıklı değil mi?. Link to comment Share on other sites More sharing options...
wmismail Posted June 12, 2009 Author Share Posted June 12, 2009 sadece bir öneri ancak crystal report ile yazdırma yaptırmak daha kolay ve mantıklı değil mi?. Mantıklı ve kolay. Ancak sorunla karşılaştığında destek alamayabilirsni. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.