sory
كنت حاب أساعد بس ماعرفت
بالتوفيق إن شاء الله
- الإهدائات >> | |
إضافه إهداء |
sory
كنت حاب أساعد بس ماعرفت
بالتوفيق إن شاء الله
لسعني
جـــــ JeDDaH ــــده
وما إتغيرت
حكمة عجبتنيمن يتكلم كثيراً : إما أنه يعرف كثيراً .. وإما أنه يكذب كثيراً
&
يخاطبني السفيه بكل قبح وآسف أن أكون له مجيباً
يزيد سفاهة وأزيد حلماً كعود زاده الإحراق طيباً
http://www.facebook.com/hmf2010
سلام
انتي في الكود طالبة منه يخرج من البرنامج مهما كان خيار المستخدم
لازم تسوي شرط عشان يخرج إذا ضغط على Yes فقط
جربي الكود هذا:
كود:Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim answer As MsgBoxResult answer = MsgBox("عزيزي المستخدم هل أنت متأكد من الخروج", MsgBoxStyle.YesNo) If answer = MsgBoxResult.Yes Then End Else Exit Sub End If End Sub
اهلا محمد ..
فكرت في الشرط .. بس ما كنت عارفة ايش استخدم فية يعني ..
زي
As MsgBoxResult
ما أخدنا أخدنا as enteger
و as string
وزيها كتير زي الي في المرفق
بس ما في As MsgBoxResult
دراسة نص كم ..
وكمان ماكنت راح أعرف .. exit sub نهائيا
الله يسعدك ويديك العافية يارب ..
بس معلية والله ان شاء الله يكون أخر شي >>>>
ما قلتلي على حكاية الطباعه .. قتلك مشي الحال لاكن لمن أطبع تنطبعلي صفحة بيضا مو نفس الفورم ..
وشكرا والله مررررررة كتير ,,,
[align=center][/align]
أهلين فراولة
بالنسبة للطباعة جربي الكود اللي هنا:
http://www.vb-helper.com/howto_net_p...orm_image.html
وإن شاء الله يضبط معك..
سلام عليكم <<
محمد .. جربت الأكواد ..
اصلا بالقوة فهمتها ..
كود:Private Sub m_PrintDocument_PrintPage(ByVal sender As _ Object, ByVal e As _ System.Drawing.Printing.PrintPageEventArgs) Handles _ m_PrintDocument.PrintPage
بالقوة فهمت أنوا اخر سطر هوة الكود ..
بس حرف الـ M الي في بداية الكود .. عجيبة ..
يقولي في الكود خطأ ..
مو كل الكود ..m_PrintDocument.PrintPage
لا بس من هنا m_PrintDocument
حاططلي تحتها خط أزرق ..
أهلين فراولة
طبعاً الكود مو تاخذيه كوبي بيست مثل ما هو.. أكيد ما رح يشتغل
لازم تغيري بعض الأشياء في الكود عشان يتوافق مع مشروعك..
بالنسبة للـ M ما فيها غلط... هذا اسم المتغير مو ضروري تغيريه..
شوفي أنا عدلت عليه شوية أشياء وصار كذا:
كود:Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal _ hdcDest As IntPtr, ByVal nXDest As Integer, ByVal _ nYDest As Integer, ByVal nWidth As Integer, ByVal _ nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc _ As Integer, ByVal nYSrc As Integer, ByVal dwRop As _ System.Int32) As Boolean Private Const SRCCOPY As Integer = &HCC0020 ' Variables used to print. Private m_PrintBitmap As Bitmap Private WithEvents m_PrintDocument As Printing.PrintDocument ' Print the picture. Private Sub btnPrint_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnPrint.Click ' Copy the form's image into a bitmap. m_PrintBitmap = GetFormImage() ' Make a PrintDocument and print. m_PrintDocument = New Printing.PrintDocument m_PrintDocument.Print() End Sub Private Function GetFormImage() As Bitmap ' Get this form's Graphics object. Dim me_gr As Graphics = Me.CreateGraphics ' Make a Bitmap to hold the image. Dim bm As New Bitmap(Me.ClientSize.Width, _ Me.ClientSize.Height, me_gr) Dim bm_gr As Graphics = me_gr.FromImage(bm) Dim bm_hdc As IntPtr = bm_gr.GetHdc ' Get the form's hDC. We must do this after ' creating the new Bitmap, which uses me_gr. Dim me_hdc As IntPtr = me_gr.GetHdc ' BitBlt the form's image onto the Bitmap. BitBlt(bm_hdc, 0, 0, Me.ClientSize.Width, _ Me.ClientSize.Height, _ me_hdc, 0, 0, SRCCOPY) me_gr.ReleaseHdc(me_hdc) bm_gr.ReleaseHdc(bm_hdc) ' Return the result. Return bm End Function ' Print the form image. Private Sub m_PrintDocument_PrintPage(ByVal sender As _ Object, ByVal e As _ System.Drawing.Printing.PrintPageEventArgs) Handles _ m_PrintDocument.PrintPage ' Draw the image centered. Dim x As Integer = e.MarginBounds.X + _ (e.MarginBounds.Width - m_PrintBitmap.Width) \ 2 Dim y As Integer = e.MarginBounds.Y + _ (e.MarginBounds.Height - m_PrintBitmap.Height) \ 2 e.Graphics.DrawImage(m_PrintBitmap, x, y) ' There's only one page. e.HasMorePages = False End Sub
طبعاً بالإضافة للكود لازم تسحبي الـ PrintDocument من التول بوكس
وكمان تسحبي زر Button ولازم يكون اسمه btnPrint في خانة Name على اليمين عشان هذا هو الاسم المستخدم للزر في الكود..
جربيه عندك وإن شاء الله رح يطبع الفورم 100%
مو كأنوا طول الكووود ..
وكمان مني فاهمتوا كيف راح اشرحوا الله يسلمك ويسعدك ..
معليش دووووخت بس استحملني الله يخليك
شوووووووكرن ....
التعديل الأخير تم بواسطة فرولة لذيذة ; 30-12-2007 الساعة 12:31 AM
انتي شكلك تغيبي عن المحاضرات
الكود هو نفسه اللي في الموقع وأنا ما عدلت إلا أشياء بسييييطة
وعموماً هو يشرح نفسه والكومنتس موجودة فيه..
شوفي:
الجزء السابق عبارة عن تصريح للدالة BitBlt وهي دالة خاصة بنظام التشغيل ويندوز وظيفتها نقل قيمة معينة (صورة الفورم في مشروعنا هذا) من جهة معينة (الشاشة) إلى جهة معينة أخرى (الطابعة)كود:Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal _ hdcDest As IntPtr, ByVal nXDest As Integer, ByVal _ nYDest As Integer, ByVal nWidth As Integer, ByVal _ nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc _ As Integer, ByVal nYSrc As Integer, ByVal dwRop As _ System.Int32) As Boolean Private Const SRCCOPY As Integer = &HCC0020
المقطع السابق تعيين للمتغيرات المستخدمة في الفورمكود:' Variables used to print. Private m_PrintBitmap As Bitmap Private WithEvents m_PrintDocument As Printing.PrintDocument
المقطع السابق يحتوي على الدالة الخاصة بزر "طباعة" ووظيفتها الحصول على نسخة من الفورم على شكل صورة وتنفيذ أمر الطباعةكود:' Print the picture. Private Sub btnPrint_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnPrint.Click ' Copy the form's image into a bitmap. m_PrintBitmap = GetFormImage() ' Make a PrintDocument and print. m_PrintDocument = New Printing.PrintDocument m_PrintDocument.Print() End Sub
كود:Private Function GetFormImage() As Bitmap ' Get this form's Graphics object. Dim me_gr As Graphics = Me.CreateGraphics ' Make a Bitmap to hold the image. Dim bm As New Bitmap(Me.ClientSize.Width, _ Me.ClientSize.Height, me_gr) Dim bm_gr As Graphics = me_gr.FromImage(bm) Dim bm_hdc As IntPtr = bm_gr.GetHdc ' Get the form's hDC. We must do this after ' creating the new Bitmap, which uses me_gr. Dim me_hdc As IntPtr = me_gr.GetHdc ' BitBlt the form's image onto the Bitmap. BitBlt(bm_hdc, 0, 0, Me.ClientSize.Width, _ Me.ClientSize.Height, _ me_hdc, 0, 0, SRCCOPY) me_gr.ReleaseHdc(me_hdc) bm_gr.ReleaseHdc(bm_hdc) ' Return the result. Return bm End Function
المقطع السابق هو الكود الخاص بالدالة BitBlt
يعني يشرح للدالة خطوات تكوين صورة للفورم
كود:' Print the form image. Private Sub m_PrintDocument_PrintPage(ByVal sender As _ Object, ByVal e As _ System.Drawing.Printing.PrintPageEventArgs) Handles _ m_PrintDocument.PrintPage ' Draw the image centered. Dim x As Integer = e.MarginBounds.X + _ (e.MarginBounds.Width - m_PrintBitmap.Width) \ 2 Dim y As Integer = e.MarginBounds.Y + _ (e.MarginBounds.Height - m_PrintBitmap.Height) \ 2 e.Graphics.DrawImage(m_PrintBitmap, x, y) ' There's only one page. e.HasMorePages = False End Sub
المقطع الأخير هذا هو اللي يحدد خصائص الطباعة.. يعني مثلاً يعطي الأمر بطباعة الفورم وتوسيطه في الصفحة..
بس هذا باختصار.. وتقدري تزودي كلمتين من عندك
[align=center]شووووووووووكرن
[/align]
الذين يشاهدون الموضوع الآن: 1 (0 من الأعضاء و 1 زائر)