|
You have to sit down between the shrubs besides the road your application, trying to avoid noises so you don't scare it off. Then, when the control emerges from its hideout, hit it hard with a club on its head, but avoid injuring it too bad, then put it into your bmp-format, which you hopefully brought along with you in a suitable size.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
you cant work with screen shot
this code will work out for coz this code will take control as bitmap
so if its works tell me if not i'll give some other suggesstion
manavharsh@yahoo.com my mail id
there is one more option to print the control also
its an vb.net code with vb
Imports System.Drawing.Printing
Imports System.Drawing.Imaging
Public Class Form1
Private m_PrintBitmap As Bitmap
Private WithEvents m_PrintDocument As PrintDocument
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
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
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnprint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprint.Click
m_PrintBitmap = GetFormImage()
' Make a PrintDocument and print.
m_PrintDocument = New PrintDocument
m_PrintDocument.DefaultPageSettings.Landscape = True
m_PrintDocument.Print()
End Sub
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
End Class
|
|
|
|
|
Just wondering, if I have an app.config file with a range of values including:
<add key="DeleteEmails" value="no">
If this entry is deleted from the config file, what will be returned if I try to read from it in my program?
|
|
|
|
|
It will crash, you need to write code that catches this exception and returns a default.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
I am making an appliaction where i need to open a file and save it in different place.
Now the file type is .doc, so i need to open the file in MS Word (Its a stand alone application and user may use MS Word 2003 or 2007), with in the application or out side the application, till now i am comfortable to do. The problem raises when its time to save the application.
When i am trying to save it through MS Word, it actually show the save dialog box. Which has to be blocked as i need to save the file only at one particular location, through code.
Can any one tell me how to block Save button (New and Open are always bloked by default) (OR) block Standard tool bar in MS Word. And to block Menu bar in MS Word.
Any help would be greet...
It very urgent please help me...
Jats
|
|
|
|
|
Hi can you post the code you're using to save the file. I might be able to help with that.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Here is the code to save the contents in a different file...
Here is the code, Add reference to Microsoft Word 11.0 Library
<br />
Imports Microsoft.Office.Interop.Word<br />
Imports System.Data<br />
Imports System.Data.OleDb<br />
Imports System.Data.SqlClient<br />
Imports System.Configuration<br />
<br />
<br />
Public Class form1<br />
Dim WithEvents wordApp As New Microsoft.Office.Interop.Word.Application<br />
Dim WithEvents doc As New Microsoft.Office.Interop.Word.Document<br />
Dim strSaveFile As String = "C:\Test\Retrive_the_data.doc"<br />
<br />
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
'Create a Word App<br />
<br />
wordApp.Visible = False<br />
<br />
With wordApp<br />
.Documents.Open(strSaveFile)<br />
'Clipboard.SetText("lpt ", TextDataFormat.Text)<br />
'wordApp.Selection.InsertParagraph()<br />
'wordApp.Selection.Paste()<br />
<br />
Dim strsaveasfile As String = "c:\Test\retry.doc"<br />
Try<br />
If (strSaveFile <> String.Empty) And (Not (IsNothing(strSaveFile))) Then<br />
.ActiveDocument.SaveAs(strSaveFile)<br />
.ActiveDocument.SaveAs(strsaveasfile)<br />
End If<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
<br />
.Visible = True<br />
.Activate()<br />
End With<br />
<br />
System.Runtime.InteropServices.Marshal.ReleaseComObject(wordApp)<br />
End Sub<br />
<br />
End Class<br />
Now i just have to deactivate the Save as button in MS Word.
And if it is possible i would also like to block Title bar and Menu bar.
Jats
modified on Friday, April 18, 2008 8:23 AM
|
|
|
|
|
I see what you're trying to do. As far as I know what you're trying to do is pretty impossible. But what you can do is that you can change read only property.
With wordApp
.Documents.Open(strSaveFile, , <font color="blue">True</font>)
That parameter makes your document READ ONLY, but you cannot block save box.
By looking at code, it seems like you want something that user can only read but not change right? If this is a case then why not convert your doc to PDF and then show that!! They wont be able to do anything.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Actually thats not what i want to do.
The operation i want to perform is to open a document from a location say 'loc1' and after making the changes save it to 'loc2' but both locations have to be handled by Application I cannot allow user to save it in another location as if it is done I cannot track the documents for generating final report combining all the docs.
So what i am actually doing is i am taking the input file (doc1) from loc1 and saving it as doc2 in loc2.
And then oppening doc2 from loc2 so that user can make changes and click save. and it just updates the present document that is... Doc2 in Loc2.
Thats all...
But in case the user makes save as operation then it will lead to problem while generating reports...
Basically Doc1 and soon in Loc1 are templates and Doc2 and soon in Loc2 are mofiled files related to a particular project.
Jats
|
|
|
|
|
Hi,
I want to know how can we hash the password that we have got from user to save in database(SQL server) ? I want the exact code that I must write !
I formerly in ASP 2003 use this code:
<br />
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5")<br />
but in VB 2005 I don't know how I can do it.
please help. tanx !
|
|
|
|
|
That method is still available.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You're better off not using System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile as you'll have to include the System.Web reference in you're project. Try using the SHA1 hash algorithm instead:
<br />
Imports System.Security.Cryptography<br />
Imports System.Text<br />
<br />
Public Shared Function GeneratePasswordHash(ByVal password As String) As String<br />
Dim pwdData As Byte() = Encoding.UTF8.GetBytes(password)<br />
Dim sha As SHA1 = New SHA1Managed<br />
<br />
Dim hashData As Byte() = sha.ComputeHash(pwdData)<br />
sha.Clear()<br />
<br />
Return Convert.ToBase64String(hashData)<br />
Return Encoding.UTF8.GetString(hashData)<br />
<br />
End Function<br />
modified on Saturday, April 19, 2008 5:30 AM
|
|
|
|
|
Thank U so much Rob Smiley.
I try that.
|
|
|
|
|
Rob Smiley wrote: Return Encoding.UTF8.GetString(hashData)
That doesn't work. The hash data is not an utf-8 encoded string, so you can't decode it into a string.
If you want the data as a string, you can use base 64:
Return Convert.ToBase64String(hashData)
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yeah, you're right. Probably should have tested this before posting
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
b4 this my prgm running ok.. and i don't do any editing. after a few days, when i try to add data in my databse, there was a msg "runtime error" about my web.config.. my customErrors mode="off", so i change my mode to RemoteOnly.. but another problem come out. it says that "String or binary data would be truncated. The statement has been terminated" and then the source error is :
Line 623: cmd.Connection.Open()
Line 624: cmd.ExecuteNonQuery() <-- this line r in red colour
Line 625: cmd.Connection.Close()
this happen after i key in my data and i want to add the data to my database... helpp me pls...
|
|
|
|
|
I'm sorry, but that's not really all that helpful. This tells me that:
1 - you want to run some SQL
2 - if it ran some data somewhere would be truncated
3 - it throws an error
I can't tell you more than that, and I'd hope you could work that out for yourself. I'd say this means one of your parameters is too big, which in turn makes me syspect that you're string mashing SQL, which probably means your code is open to all sorts of attacks. But, hard to say if you are not showing the pertinent code.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
this is my coding.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim _kod As String
Dim Pemanggil As String
Dim Negeri As String
Dim run_no As String
Pemanggil = TextBox10.Text.Trim
Negeri = TextBox4.Text.Trim
If Kod.Text.Length > 0 And Nama.Text.Length > 0 And TextBox4.Text.Length > 0 And TextBox10.Text.Length > 0 And No_Tel.Text.Length > 0 And Masalah.Text.Length > 0 And Penyelesaian.Text.Length > 0 And TextBox9.Text.Length > 0 Then
Dim myConn As New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim MySQL As String = "INSERT INTO Senarai_Log(docNo,Tarikh,Kod_Koop,Nama_Koop,Nama_Koop1,Negeri,Nama,No_Tel,Masalah,Penyelesaian,Tindakan) Values (@docNo,@Tarikh,@Kod_Koop,@Nama_Koop,@Nama_Koop1,@Negeri,@Nama,@No_Tel,@Masalah,@Penyelesaian,@Tindakan)"
Dim cmd As SqlCommand = New SqlCommand(MySQL, myConn)
cmd.Parameters.Add(New SqlParameter("@Tarikh", SqlDbType.NVarChar, 250))
cmd.Parameters("@Tarikh").Value = System.DateTime.Now.Date
cmd.Parameters.Add(New SqlParameter("@Kod_Koop", SqlDbType.NVarChar, 250))
cmd.Parameters("@Kod_Koop").Value = Kod.Text.Trim
cmd.Parameters.Add(New SqlParameter("@Nama_Koop", SqlDbType.NVarChar, 250))
cmd.Parameters("@Nama_Koop").Value = Nama.Text.Trim
cmd.Parameters.Add(New SqlParameter("@Nama_Koop1", SqlDbType.NVarChar, 250))
cmd.Parameters("@Nama_Koop1").Value = Nama1.Text.Trim
cmd.Parameters.Add(New SqlParameter("@Negeri", SqlDbType.NVarChar, 250))
cmd.Parameters("@Negeri").Value = Negeri
cmd.Parameters.Add(New SqlParameter("@No_Tel", SqlDbType.Char, 50))
cmd.Parameters("@No_Tel").Value = No_Tel.Text.Trim
cmd.Parameters.Add(New SqlParameter("@Masalah", SqlDbType.Char, 250))
cmd.Parameters("@Masalah").Value = Masalah.Text.Trim
cmd.Parameters.Add(New SqlParameter("@Penyelesaian", SqlDbType.NVarChar, 250))
cmd.Parameters("@Penyelesaian").Value = Penyelesaian.Text.Trim
cmd.Parameters.Add(New SqlParameter("@Tindakan", SqlDbType.Char, 50))
cmd.Parameters("@Tindakan").Value = TextBox9.Text.Trim
cmd.Parameters.Add(New SqlParameter("@Nama", SqlDbType.Char, 50))
cmd.Parameters("@Nama").Value = Pemanggil
cmd.Parameters.Add(New SqlParameter("@docNo", SqlDbType.NVarChar, 50))
cmd.Parameters("@docNo").Value = System.DateTime.Now.ToString("yyyyMMdd") & Kod.Text & GetRunNo().ToString("D4")
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
Label3.Text = "MAKLUMAT TELAH DISIMPAN."
Label3.Visible = True
Else
Label3.Text = "SILA PENUHKAN MEDAN KOSONG."
Label3.Visible = True
End If
Clear()
End Sub
this button suppose to add all the data that i've key in, put in table "Senarai_Log". i have try this prgm 10 time and there's nothing wrong with it. but today when i try to add the data, the error msg about the web.config appear, when i change the customerrors mode, the error for string and binary msg appear.
|
|
|
|
|
Check the lengths of the parameters/ values against the corresponding database columns. Thats usually the problem, data longer than the column supports.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I never specify lengths like this, I just add the parameters directly and let the framework, work it out for me.
I would suggest that it would be great for you to do some study, you may want to read the article I link to in my sig, it explains how best to get help when you have an error message you cannot understand.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thank you. i have found the problem. the article really help.
|
|
|
|
|
I have an application that I have been working on for a while now and suddenly something that was working fine just fails - the global module!
The items I have been tweaking lately are not related at all to the global module and I had been running and rerunning the app over and over when one time it just stopped - with that error. It fails on the first attempt to access a public routine to create the DB connection , or other variables.
Does anyone know what could have caused it - I mean I honestly made no changes involving the module at all!
I'd show source code, but I can't think of anything relevant to show.
jooooo
|
|
|
|
|
What error?? Is this a Public Module or Public Class exposing Public Shared methods??
Try dropping the module or class file from the project and readding it.
|
|
|
|
|