Click here to Skip to main content
15,917,964 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe30-May-12 16:31
kentuckyjoe30-May-12 16:31 
QuestionHow to semd sms more than 160 character in 0ne SMS? Pin
rusydan.khir15-May-12 4:04
rusydan.khir15-May-12 4:04 
AnswerRe: How to semd sms more than 160 character in 0ne SMS? Pin
Dave Kreskowiak15-May-12 4:21
mveDave Kreskowiak15-May-12 4:21 
GeneralRe: How to semd sms more than 160 character in 0ne SMS? Pin
rusydan.khir16-May-12 6:15
rusydan.khir16-May-12 6:15 
GeneralRe: How to semd sms more than 160 character in 0ne SMS? Pin
Dave Kreskowiak16-May-12 7:04
mveDave Kreskowiak16-May-12 7:04 
GeneralRe: How to semd sms more than 160 character in 0ne SMS? Pin
rusydan.khir19-May-12 5:04
rusydan.khir19-May-12 5:04 
AnswerRe: How to semd sms more than 160 character in 0ne SMS? Pin
johnjeric22-May-12 19:39
johnjeric22-May-12 19:39 
QuestionPaint Event Problem Pin
Clark Kent12315-May-12 3:52
professionalClark Kent12315-May-12 3:52 
I have a Picture Box where I use GDI+ to draw lines, circles, etc on. What I have noticed recently is that my other GUI components such as buttons, option boxes, labels, etc. on the same form are not displaying correctly. What I mean by that is they are all black until I click on them or resize the form then it will display properly. However, if I minimize the form then restore the form the GUI components will turn black again.

I did some googling and found out that there seems to be problem with a threading issue. I pin pointed it to my picture box paint event handler. If I comment out the entire event everything displays properly minus what I need to paint in my picture box.

My thinking was maybe I should do some multi-threading so I can get the best of both worlds objects painted in the picture box and my GUI components displaying properly on initial form load.

The first piece of code is my original code with the black showing components. I have tried to use threading in hopes that this will remedy my situation. Because of my limited (near 0) knowledge of threading this may not be the best piece of code. What I get in the threading code is the error picture for my picture box (large red "x" on white background).

VB
'Original Code before threading change.

Private Sub Picture1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Picture1.Paint

myGraphicObject = e.Graphics
myGraphicObject.Clear(Picture1.BackColor)
Draw_GDI_Related_Things_Function()

End Sub

'Threading piece of code
Private Sub Picture1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Picture1.Paint
System.Threading.Monitor.Enter(myGraphicObject)
myGraphicObject= e.Graphics
myGraphicObject.Clear(Picture1.BackColor)

'Draw_GDI_Related_Things_Function uses myGraphicObject to draw unto the picture box.
m_threadDraw = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf Draw_GDI_Related_Things_Function))

m_threadDraw.Start()
System.Threading.Monitor.Exit(myGraphicObject)
End Sub


Keep in mind that the above code is a before and after.

Can someone help me to understand what I am doing wrong?

Thanks.
AnswerRe: Paint Event Problem Pin
Dave Kreskowiak15-May-12 4:13
mveDave Kreskowiak15-May-12 4:13 
QuestionRe: Paint Event Problem Pin
Clark Kent12316-May-12 2:22
professionalClark Kent12316-May-12 2:22 
AnswerRe: Paint Event Problem Pin
Dave Kreskowiak16-May-12 4:54
mveDave Kreskowiak16-May-12 4:54 
GeneralRe: Paint Event Problem Pin
Clark Kent12316-May-12 4:56
professionalClark Kent12316-May-12 4:56 
GeneralRe: Paint Event Problem Pin
Dave Kreskowiak16-May-12 7:05
mveDave Kreskowiak16-May-12 7:05 
GeneralRe: Paint Event Problem Pin
Clark Kent12316-May-12 7:27
professionalClark Kent12316-May-12 7:27 
AnswerRe: Paint Event Problem Pin
Luc Pattyn15-May-12 14:31
sitebuilderLuc Pattyn15-May-12 14:31 
GeneralRe: Paint Event Problem Pin
Clark Kent1238-Nov-12 4:30
professionalClark Kent1238-Nov-12 4:30 
QuestionChanging JPG in picturebox with loop Pin
Dr David Johnson PhD14-May-12 12:02
Dr David Johnson PhD14-May-12 12:02 
AnswerRe: Changing JPG in picturebox with loop Pin
Dave Kreskowiak14-May-12 13:18
mveDave Kreskowiak14-May-12 13:18 
GeneralRe: Changing JPG in picturebox with loop Pin
Dr David Johnson PhD14-May-12 15:29
Dr David Johnson PhD14-May-12 15:29 
AnswerRe: Changing JPG in picturebox with loop Pin
Luc Pattyn14-May-12 15:43
sitebuilderLuc Pattyn14-May-12 15:43 
GeneralRe: Changing JPG in picturebox with loop Pin
Dr David Johnson PhD14-May-12 17:14
Dr David Johnson PhD14-May-12 17:14 
AnswerRe: Changing JPG in picturebox with loop Pin
Luc Pattyn14-May-12 17:34
sitebuilderLuc Pattyn14-May-12 17:34 
GeneralRe: Changing JPG in picturebox with loop Pin
Dr David Johnson PhD14-May-12 17:59
Dr David Johnson PhD14-May-12 17:59 
GeneralRe: Changing JPG in picturebox with loop Pin
dg6yhw1115-May-12 6:38
dg6yhw1115-May-12 6:38 
GeneralRe: Changing JPG in picturebox with loop Pin
Dr David Johnson PhD15-May-12 11:24
Dr David Johnson PhD15-May-12 11:24 

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.