|
Sorry I didn't write clearly, my problem is the following:
I've a form, and controls in it. I want to get the same image that the user sees on the screen. If I don't use graphics, I can use DrawToBitmap method. But what should I do if I use graphics too???
|
|
|
|
|
Hi,
if you do the graphics correctly, you will catch it. Here is a tiny paint instruction:
there are several steps to draw something so it becomes visible on the screen:
1.
decide upon what object you want to draw; it normally is a Control (e.g. a Panel) or a
Form itself. I prefer to add a Panel to a Form, then draw on the Panel.
2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of
your drawing. For a rectangle that could be top and left coordinate, and width+height,
or just a Rectangle. etc.
3.
create a Paint handler for that Panel, and do all your drawing in there, using the
Graphics class and your variables.
4.
when you want to change things, modify the variables and call Panel.Invalidate() or
one of its overloads (for selective invalidation).
5.
If you want to animate things, perform the move (step 4) inside the Tick handler
of a Windows.Forms.Timer
BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.
|
|
|
|
|
Hi,
I want to serialize a control.
I could not Serialize control datatype but I have created a Serializable() class that has a property that holds my control and I tried to Serialize object of that class but still not working.
Here is source.
<Serializable()> Private Class Slide_Master
Dim _Main_Panel As Object
Public Property Main_Panel() As Object
Get
Return _Main_Panel
End Get
Set(ByVal value As Object)
_Main_Panel = value
End Set
End Property
End Class
'Serializable class
'Code for writing in file
Dim sm As New Slide_Master
sm.Main_Panel = CType(pnlMain, Object)
Dim str As IO.Stream = IO.File.OpenWrite(Application.StartupPath + "\chl.dat")
Dim formatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
formatter.Serialize(str, sm)
str.Close()
Help me out
|
|
|
|
|
control class is doesnt have Serializable attribute. so you cant serialiaze i guess. is anyone know other method?
Manikandan.net
[Coding is life]
|
|
|
|
|
please, help me.
i want to add component control: mySQL VB API v2.0.0 in VB6.
But, mySQL VB API is not listed on component control.
How to make it listed?
I've register myVBQL.dll, and could not be loaded...
Please... help me...
|
|
|
|
|
I haven't used VB6 in so long... Try right-clicking the ToolBox, there should be something like "Add/Remove Item". Click it. A dialog should open up and you can find the MySql components, if they're exposed as such...
|
|
|
|
|
Hi
I am not using VB for some time now i do not remember exact menu option but may be the input will give u some idea..
go to project menu u have add component something like that.. There it lets u browse and select the dll to be added
Good luck
|
|
|
|
|
Hello every one
I am having a VB.net 2005 Express application.. I was having some issues with database connection and the way I was handling the errors
Now with some input I am using try and catch… Following is what I want to do
Execute Query
If any DB connection Error Display Retry Msgbox
If retry clicked then close the connection and open it again
If no error the execute the query If error for three times then close the application
Can any one plz help me to put these steps in nested Try and Catch
|
|
|
|
|
Try this concept..
<br />
Public Function YourFunction() as Boolean<br />
Try<br />
If ConnIsOpened then Close<br />
OpenConnection<br />
Execute SQL<br />
CloseConnection <br />
Catch ex as Exception <br />
If(Messagebox.Show("There is some errors, Do you wanna try again?",,,YesNoButton) = YesButton) then<br />
YourFunction()<br />
End If <br />
End Try<br />
End Function
|
|
|
|
|
how to add dynamically the usercontrol's to the page when ever the button click then only add the webusercontrol's to the page
|
|
|
|
|
Try LoadControl("/yourusercontrol.ascx")
|
|
|
|
|
Dynamicaly adding control's with out refreshing the page
|
|
|
|
|
You can only add the javascript or html control without refreshing the page.. If you want to add the server control, I think it will be too difficult.. You may want to check the ASP.NET Ajax...
|
|
|
|
|
use Java script to add the control dynamically, without refreshing the page.
example:
<br />
<div id="panel"></div><br />
<script language="javascript"><br />
var btn=document.createElement("input");<br />
btn.type="button";<br />
btn.value="Click me";<br />
btn.onclick=function()<br />
{<br />
alert("Btn Clicked");<br />
}<br />
panel.appendChild(btn);<br />
</script><br />
Manikandan.net
[Coding is life]
|
|
|
|
|
hi guys ,,
i am having some security issues on dot net 2.0,
i am running exe of my project from a shared location on my lan but i get some
security rellated errors ,"unveriafiable code.", but when in frame configuration i make
trusted level full of the intranet zone i get no error and it works fine, but it gives me more
probelms, do i have to make these setting on individual pc(too hard)?
simply is there any way that i could make my assemblies to run in partial trusted zones?
thansk in advance
|
|
|
|
|
ghumman63 wrote: do i have to make these setting on individual pc(too hard)?
Yes.
ghumman63 wrote: simply is there any way that i could make my assemblies to run in partial trusted zones?
Nope. You'd still have to go to each machine and tell it to trust that assembly.
If the machines are in a domain environment, then it's easy to do with a group policy.
Read this[^], then this[^], and then this[^].
Basically, you have to tell the machines to trust any assembly signed with a certain key.
|
|
|
|
|
thanks for your cincideration,
but any guide about doing that (group policy) any hepling stuff or web link,,
thanks in advance
hello
|
|
|
|
|
|
Can I use a delegate to write to a textbox on a 2nd form from a running subthread on the first form?
For instance, this code works fine to write from the thread to Me.Textbox1. However, if I change Me.Textbox1 to Form2.Textbox1 then the delegate does not write to that textbox on Form2 (no error, just blank textbox).
Thanks!
Public Sub ThreadProcSafe()
Me.SetText("This text was set safely.")
End Sub
Private Sub SetText(ByVal [text] As String)
If Me.TextBox1.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Me.TextBox1.Text = [text]
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.demoThread = New Thread(New ThreadStart(AddressOf Me.ThreadProcSafe))
Me.demoThread.Start()
'Form2.Show()
End Sub
|
|
|
|
|
I think you can. But I've always heard that crossing over threads is not the best, though.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
yes but before you can access the textbox properties, you must do an invoke to get the population of the textbox onto the main thread...
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
|
|
|
|
|
I'd like to be able to load an assembly and then unload it, thereby allowing the user to edit and recompile the assembly (via Codeprovider). Then I want to reload the new recompiled assembly.
But the unload statement below doesn't free the .dll so that I can write to it again.
Is there a way to do this?
thank you!
Dim SubDomain As AppDomain
Dim as1 As Assembly = Reflection.Assembly.ReflectionOnlyLoadFrom(TypeToOpen & ".dll")
StrategyClass = SubDomain.CreateInstanceAndUnwrap(as1.FullName, "Strategies.Strategy")
AppDomain.Unload(SubDomain)
|
|
|
|
|
Hi,
AFAIK AppDomain.Unload is the only way to get rid of a loaded DLL.
|
|
|
|
|
Hello every one
I am new in vb.net and i am doing one simple application to save text file, and i have provide choice to display image in picture box but i am not saving image in file file can only save students name,age,class etc but i am haveing problem to save file,but if i dont load image in picture box then it's works fine again i am not saving image in file it's just for selecting image from file
can some one please help me with this
code is some thing like this (for creating profile)
Private Sub btnProfile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProfile.Click<br />
Dim Response As DialogResult<br />
Dim Age As String<br />
Dim MyString, MidString, MidString2 As String<br />
'get first leter in upper case for text box for name <br />
txtName.Text = StrConv(txtName.Text, VbStrConv.ProperCase)<br />
If Trim(txtName.Text) = "" Then<br />
Response = MessageBox.Show("Please enter your name", "Error", MessageBoxButtons.OK, _<br />
MessageBoxIcon.Error)<br />
If Response = DialogResult.OK Then<br />
txtName.Focus()<br />
Exit Sub<br />
End If<br />
End If<br />
Age = Str(DateDiff("yyyy", DOB, Now))<br />
Message = "Your profile was created on " + ((Format(DateTime, "d MMMM yyyy") + _<br />
" at " + Format(DateTime, "hh : mm tt" + ControlChars.Cr)))<br />
Message += "" + ControlChars.Cr<br />
Message += txtName.Text + " is a student in the " + cboGrade.Text + " grade " + ControlChars.Cr<br />
If rdoMale.Checked Then<br />
Message += "He is " + Age + " years old" + ControlChars.Cr<br />
ElseIf rdoFemale.Checked Then<br />
Message += "She is " + Age + " years old" + ControlChars.Cr<br />
End If<br />
If picStudent.Image Is Nothing Then<br />
Message += "" + ControlChars.Cr<br />
Message += "No picture added " + ControlChars.Cr<br />
Else<br />
Message += "" + ControlChars.Cr<br />
Message += "Your picture was also added in your profile" + ControlChars.Cr<br />
End If<br />
Response = MessageBox.Show(Message, "Student Profile", MessageBoxButtons.OKCancel, _<br />
MessageBoxIcon.Information)<br />
'Add data in to student data file<br />
Call AddStudentData()<br />
'Add student name in to cobmobox<br />
Call AddDataToCombo()<br />
If Response = DialogResult.OK Then<br />
Response = MessageBox.Show("Would you like to creat another profile", "New profile", _<br />
MessageBoxButtons.YesNo, MessageBoxIcon.Question)<br />
'if cancel then reset form<br />
ElseIf Response = DialogResult.Cancel Then<br />
txtName.Text = ""<br />
cboGrade.SelectedIndex = 0<br />
txtName.Focus()<br />
nudDay.Value = 1<br />
dudMonth.SelectedIndex = 0<br />
nudYear.Value = 1951<br />
picStudent.Image = Nothing<br />
Exit Sub<br />
End If<br />
'if new profile and yes then reset form<br />
If Response = DialogResult.Yes Then<br />
txtName.Text = ""<br />
cboGrade.SelectedIndex = 0<br />
txtName.Focus()<br />
nudDay.Value = 1<br />
dudMonth.SelectedIndex = 0<br />
nudYear.Value = 1951<br />
picStudent.Image = Nothing<br />
Exit Sub<br />
End If<br />
If Response = DialogResult.OK Then<br />
txtName.Text = ""<br />
cboGrade.SelectedIndex = 0<br />
txtName.Focus()<br />
picStudent.Image = Nothing<br />
Else : Me.Close()<br />
End If<br />
End Sub
and code for loading image in picture is
Private Sub btnPicture_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPicture.Click<br />
'load picture of student<br />
If dlgOpen.ShowDialog = DialogResult.OK Then<br />
picStudent.Image = Image.FromFile(dlgOpen.FileName)<br />
End If<br />
End Sub
and code for saving students profile,display profile and add students name in combo box is like this
Private Sub AddStudentData()<br />
Dim DataWriter As StreamWriter<br />
FileName = Trim(txtName.Text) + ".txt"<br />
DataWriter = File.CreateText("StudentData\" + FileName)<br />
DataWriter.WriteLine(Message)<br />
DataWriter.Close()<br />
cboData.Items.Add(FileName)<br />
<br />
End Sub<br />
Private Sub AddDataToCombo()<br />
cboData.Items.Clear()<br />
Dim files() As String = Directory.GetFiles(Application.StartupPath + "\StudentData")<br />
For i As Integer = 0 To files.Length - 1<br />
cboData.Items.Add(Path.GetFileNameWithoutExtension(files(i)))<br />
Next<br />
If files.Length = 0 Then<br />
cboData.Text = "Empty Student Database"<br />
Else<br />
cboData.Text = "Select name to display profile"<br />
End If<br />
End Sub<br />
Private Sub DisplayData()<br />
Dim DataReader As StreamReader<br />
DataReader = File.OpenText("StudentData\" + cboData.SelectedItem.ToString + ".txt")<br />
FileName = DataReader.ReadToEnd<br />
MessageBox.Show(FileName, "Student Database", MessageBoxButtons.OK, MessageBoxIcon.Information)<br />
DataReader.Close()<br />
End Sub
any help please
have a nice X-mas and new year to all
thanks
|
|
|
|
|
Instead of posting the entire code, just post the trouble spot. What is the problem you are having?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|