Results 1 to 35 of 35

Thread: Visual Basic has stopped working. Why?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Visual Basic has stopped working. Why?

    Recently, it is very often that when I am developing into one of my VB6 projects, and then run it to test the new changes, I suddenly get this error:
    https://i.imgur.com/6yd98aP.jpeg
    which shows for one or two seconds, and then shows this:
    https://i.imgur.com/iRMQU6M.jpeg

    Then VB6 closes, and I have to reopen VB6 to continue my work.

    It happens quite very often (maybe about one in three "Run" attempts), when I am working on one specific vbp project.
    It never happens when I am working on other vbp projects.

    Why does this happen?
    And why so often?
    And why only when I work on one specific vbp project?

    Please help.
    Thanks.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Visual Basic has stopped working. Why?

    See General protection fault for likely reasons.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by dilettante View Post
    See General protection fault for likely reasons.
    Thanks.
    I read that article, but as for a solution, I couldn't think of anything that could fix the problem.

    How about the execution properties of VB6.EXE?
    My VB6.EXE has the following properties:
    https://i.imgur.com/oqvLjUg.jpeg

    Are these properties correct?
    Should I change any of them?

    Please help.
    Thanks.
    Ilia

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Visual Basic has stopped working. Why?

    I think it's more likely to be a problem caused by your application.
    Do you use subclassing? External OCX or DLL files?

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Visual Basic has stopped working. Why?

    Have you even tried looking in the Event Log for the crash reason?

    Yes, this is almost certainly your program's fault. You have a bug, probably passing bad parameter values to API calls. Unless you can isolate the problem to a small block of code you can show us there isn't much we can do to help.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by Arnoutdv View Post
    I think it's more likely to be a problem caused by your application.
    Do you use subclassing? External OCX or DLL files?
    I do not use subclassing, but dlls.
    I am going to post all the details including the code in a minute (post #8)
    Thanks for your help

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by dilettante View Post
    Have you even tried looking in the Event Log for the crash reason?

    Yes, this is almost certainly your program's fault. You have a bug, probably passing bad parameter values to API calls. Unless you can isolate the problem to a small block of code you can show us there isn't much we can do to help.
    I am going to post all the details including the code in a minute (post #8)
    Thanks for your help

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Here is the error that I get:
    https://i.imgur.com/LQzDZrI.jpg

    And here are what I get in the Event log:
    https://i.imgur.com/lBctRgA.jpg
    https://i.imgur.com/VP0uDQw.jpg

    And here is the project:
    https://www.mediafire.com/file/qo3qk...st009.zip/file

    Here is how to recreate the problem:
    Step1: Run the project: (Form1 appears)
    Step2: On Form1 click on "Process", or press Alt+P: (Form2 appears)
    Step3: On Form2 click on "Exit", or press Alt+X: (Form2 appears)

    Repeat steps 2 and 3 until that error "Visual basic has stopped working" happens.
    I get it after just one repeat in here.
    You probably will also get it after one repeat. If not then repeat several times until it happens.

    If you don't get the error, then please go to the following code in form2's Form_Load:
    Code:
       For i = 1 To 50
          Load InkEdit1(i)
          InkEdit1(i).Left = InkEdit1(i - 1).Left + InkEdit1(i - 1).Width + 30
          InkEdit1(i).Top = InkEdit1(i - 1).Top
          InkEdit1(i).Visible = True
    
          Load InkEdit2(i)
          InkEdit2(i).Left = InkEdit2(i - 1).Left + InkEdit2(i - 1).Width + 30
          InkEdit2(i).Top = InkEdit2(i - 1).Top
          InkEdit2(i).Visible = True
       Next i
    and change the loop counter from 50 to a larger number for example to 100, 200 or 500

    I have a feeling that this problem has something to do with InkEdit text boxes, but I don't know why and how to fix it.

    Please help.
    Thanks a lot.
    Ilia

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Visual Basic has stopped working. Why?

    InkEdit is a very heavy control. 100 on a Form is crazy.

    If you are only using InkEdit as a Unicode TextBox/RichTextBox you'd be well advised to use its "inkless" counterpart for pre-Vista Windows versions in compiled applications. This is part of the Tablet Ink SDK. To deploy it though you'll want to be sure to use a Fusion manifest in order to isolate it. You don't want to try to install the SDK version of the OCX (InkEd.dll is an OCX, the extension is just a name: there is nothing magical about the OCX extension which is an alias for DLL) on user's systems.

    Most people don't have the SDK and its updates, and proper deployment is beyond them.

    Don't use 100 InkEdit controls. At all.

    If you need a Unicode TextBox (and most people emphatically DO NOT) there are probably better alternatives. Some are free, some cost money.

    But I guess that might impact doing low-ball coding across labor markets, eh?

  10. #10
    New Member
    Join Date
    Jul 2021
    Location
    Washington
    Posts
    1

    Re: Visual Basic has stopped working. Why?

    Is Visual Basic Dead? – Yes, It’s Marked for Death

    In a way, VB6 is dead because it is no longer being developed by Microsoft. Microsoft released the. NET Framework in 2001, along with a new language C# and an updated Visual Basic. Thanks

  11. #11
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Visual Basic has stopped working. Why?

    And what is your point?

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by marryf543 View Post
    In a way, VB6 is dead because it is no longer being developed by Microsoft. Microsoft released the. NET Framework in 2001, along with a new language C# and an updated Visual Basic. Thanks
    Er, I think you mean Microsoft released the Great Pretender, Visual Fred. A .Net language that somewhat superficially resembles VB but really is an entirely different thing.

  13. #13
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Visual Basic has stopped working. Why?

    and change the loop counter from 50 to a larger number for example to 100, 200 or 500
    Are you trying to simulate a grid control with a huge array of InkEdit controls?

  14. #14
    Lively Member
    Join Date
    Nov 2020
    Posts
    67

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by IliaPreston View Post

    Repeat steps 2 and 3 until that error "Visual basic has stopped working" happens.
    I get it after just one repeat in here.
    You probably will also get it after one repeat. If not then repeat several times until it happens.
    But it is obvious that it will go wrong, sooner or later.
    Ilia, ANY controls loaded at runtime, MUST be Unloaded when close the form.

    On the event:
    Code:
    Private Sub Form_Unload(Cancel As Integer)
    of Form2 you have to add the code tu unload InkEdit1 controls.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by Arnoutdv View Post
    Are you trying to simulate a grid control with a huge array of InkEdit controls?
    No. Not a textual grid.
    I am creating something similar to Windows Explorer (showing icons for files).
    The icons are displayed in Pictureboxes.

    However, the name of each file needs to be displayed below its icon.
    To display the file name, I am using an InkEdit, because the file name may be unicode.

    The size of the form and the sizes of icons dictate that there are almost always only 24 icons and therefore only 24 InkEdit textboxes.

    The additional InkEdit textboxes (on the bottom of Form2) are just added for posting the project to this forum, because I noticed that with those additional InkEdit textboxes, the error "Visual Basic has stopped working" would happen after just one or two repeats of steps 2 and 3, whereas without them, I would get the error after 15 to 20 repeats.
    And I wanted to make it easier for everybody in here to observe the problem.

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by LeoFar View Post
    ...
    Ilia, ANY controls loaded at runtime, MUST be Unloaded when close the form.
    ...
    Definitely something that I didn't know.
    And I am so pleased that you mentioned that.
    And I will implement that advice.
    Thanks a lot for your advice.

    However, that is NOT what caused the error "Visual basic has stopped working" in my project.
    Because there are ONLY 24 Pictureboxes and ONLY 24 InkEdit textboxes on Form2 in my project (the additional ones on the bottom of Form2 were just added for posting the project to this forum. The real project does not have them. see my previous post please)

    And those 24 Pictureboxes and InkEdit textboxes are ALL added at design time. NOTHING is loaded at run time.
    The Load statement to dynamically load new Pictureboxes and InkEdit textboxes are put in place only as an anticipation that future versions of the project will decide the number of Pictureboxes and InkEdit Textboxes dynamically.

    In the current version of my project the Pictureboxes and their corresponding InkEdit Textboxes are NOT loaded at runtime because exactly 24 of them are put on the form at design time. So the Load statements do not happen.

    And yet I do get that error (Visual Basic has stopped working) after 15 to 20 repeats of steps 2 and 3.

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Ilia, ANY controls loaded at runtime, MUST be Unloaded when close the form.
    Is it true only about InkEdit Textboxes, or about any simple control for example ordinary textboxes, combo boxes, etc?

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by dilettante View Post
    InkEdit is a very heavy control. 100 on a Form is crazy.

    If you are only using InkEdit as a Unicode TextBox/RichTextBox you'd be well advised to use its "inkless" counterpart for pre-Vista Windows versions in compiled applications. This is part of the Tablet Ink SDK. To deploy it though you'll want to be sure to use a Fusion manifest in order to isolate it. You don't want to try to install the SDK version of the OCX (InkEd.dll is an OCX, the extension is just a name: there is nothing magical about the OCX extension which is an alias for DLL) on user's systems.

    Most people don't have the SDK and its updates, and proper deployment is beyond them.

    Don't use 100 InkEdit controls. At all.

    If you need a Unicode TextBox (and most people emphatically DO NOT) there are probably better alternatives. Some are free, some cost money.

    But I guess that might impact doing low-ball coding across labor markets, eh?
    Thanks for your help.

    So, basically, I am wondering what is the best alternative to an InkEdit textbox in my project.

    I need to display a unicode text in a box.
    No editing is required (for example the user typing anything or pasting anything in there).
    In fact you can see that in the project, the existing InkEdit Textboxes have their "Locked" property set to False.
    So, it is just a DISPLAY of a unicode text.

    With this limited functionality requirement, I am wondering if I have better options or not?

    Please note: I really don't want to use a manifest. I used a manifest last year and I am so dissatisfied with it.

    Is there a simple solution?
    For example:
    - any simple textbox that i can use that does the job?
    - Can I use an ordinary Textbox or RichTextbox and use some API call to display unicode text in it?
    - any other simple option?

    Please help.
    Thanks.
    Ilia

  19. #19
    Lively Member
    Join Date
    Nov 2020
    Posts
    67

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by IliaPreston View Post
    Is it true only about InkEdit Textboxes, or about any simple control for example ordinary textboxes, combo boxes, etc?
    Already written: ANY controls.

  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by LeoFar View Post
    Already written: ANY controls.
    Thanks for your help

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by IliaPreston View Post
    Thanks for your help.

    So, basically, I am wondering what is the best alternative to an InkEdit textbox in my project.

    I need to display a unicode text in a box.
    No editing is required (for example the user typing anything or pasting anything in there).
    In fact you can see that in the project, the existing InkEdit Textboxes have their "Locked" property set to False.
    So, it is just a DISPLAY of a unicode text.

    With this limited functionality requirement, I am wondering if I have better options or not?

    Please note: I really don't want to use a manifest. I used a manifest last year and I am so dissatisfied with it.

    Is there a simple solution?
    For example:
    - any simple textbox that i can use that does the job?
    - Can I use an ordinary Textbox or RichTextbox and use some API call to display unicode text in it?
    - any other simple option?

    Please help.
    Thanks.
    Ilia
    Any help on this issue will be greatly appreciated.
    Thanks.
    Ilia

  22. #22
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: Visual Basic has stopped working. Why?

    Maybe DrawTextExW?

  23. #23

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    I found this code in my own projects (I had probably found it somewhere on the web some years ago):
    Code:
    Public Sub DrawUnicodeOnPicturebox(ByRef Pct As PictureBox, ByVal sText As String)
       Dim rct As RECT
       
      'Pct.ScaleMode = vbPixels         ...... Done in design mode (on the screen instead of in the code)
      'Pct.AutoRedraw = True            ...... Done in design mode (on the screen instead of in the code)
       Pct.Cls
       rct.Top = 0                      'Set Margin
       rct.Left = 0                     'Set Margin
       rct.Right = rct.Left + Pct.Width
       rct.Bottom = rct.Top + Pct.Height
       
       DrawTextW Pct.hDC, StrPtr(sText), Len(sText), rct, DT_WORDBREAK Or DT_CALCRECT
       DrawTextW Pct.hDC, StrPtr(sText), Len(sText), rct, DT_WORDBREAK
       Pct.Refresh
    End Sub
    I just tested it and it works perfectly.
    Then I tried to modify it so that the text could be drawn on an ordinary VB6 Textbox
    Here is the modified version:
    Code:
    Public Sub DrawUnicodeOnTextbox(ByRef T1 As TextBox, ByVal sText As String)
       Dim rct As RECT
       
       T1.Text = ""
       T1.Refresh
       
       rct.Top = 0                      'Set Margin
       rct.Left = 0                     'Set Margin
       rct.Right = rct.Left + T1.Width
       rct.Bottom = rct.Top + T1.Height
       
       DrawTextW T1.hWnd, StrPtr(sText), Len(sText), rct, DT_WORDBREAK Or DT_CALCRECT
       DrawTextW T1.hWnd, StrPtr(sText), Len(sText), rct, DT_WORDBREAK
       T1.Refresh
    End Sub
    But, this one doesn't work.
    It doesn't write anything into the textbox

    I don't know why it doesn't draw the text in there.
    The nature of the job (drawing the text in a certain rectangle on the screen) is the same.
    So, why doesn't it work?
    Please help.
    Thanks.

  24. #24
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: Visual Basic has stopped working. Why?

    In the first example you are drawing to the PictureBoxes hDC (correct). In the second example, you are trying to draw to a TextBoxes hWnd (incorrect). Why are you trying to draw text on TextBox?

  25. #25

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by jpbro View Post
    In the first example you are drawing to the PictureBoxes hDC (correct). In the second example, you are trying to draw to a TextBoxes hWnd (incorrect). Why are you trying to draw text on TextBox?
    Drawing the text on a Picturebox definitely is fine for me.
    However, I just thought why not EXPERIMENT with this idea a bit further to see how I can get it to work for a standard VB6 Textbox as well. (Just to learn something from this, and to enjoy the challenge)
    Bottom line is that if I can't get it to work with a Textbox, I will use the Picturebox, as that works fine for my project.
    But, before giving up on the Textbox, I want to do my best to see if I can get it to work).

    Regarding the hDC and hWnd, unfortunately I don't know the difference (Please forgive me for my ignorance).
    As far as I understand (which is certainly wrong) each one of the hDC and hWnd is the handle of the control, and therefore should be the same thing.
    Not sure though.
    If you could explain the difference, it would be greatly appreciated.

    Thanks.
    Ilia

  26. #26

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Actually, after some experimentation, I found a way to do that (display unicode text in a standard VB6 Textbox).
    And I put it in here, so that it may one day be helpful to someone:
    Code:
    Public Sub DrawUnicodeOnTextbox(ByRef TextBoxToDrawOn As TextBox, ByVal sText As String)
       Dim rct                 As RECT
       Dim TextBoxhDC          As Long
       
       TextBoxToDrawOn.Text = ""
       TextBoxToDrawOn.Refresh
       
       rct.Top = 0                      'Set Margin
       rct.Left = 0                     'Set Margin
       rct.Right = rct.Left + TextBoxToDrawOn.Width
       rct.Bottom = rct.Top + TextBoxToDrawOn.Height
       
       TextBoxhDC = GetDC(TextBoxToDrawOn.hwnd)
       
       DrawTextW TextBoxhDC, StrPtr(sText), Len(sText), rct, DT_WORDBREAK Or DT_CALCRECT
       DrawTextW TextBoxhDC, StrPtr(sText), Len(sText), rct, DT_WORDBREAK
      'TextBoxToDrawOn.Refresh
       
    End Sub

  27. #27

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by jpbro View Post
    Thanks again for your help.

    As I said, the following code does the job:
    Code:
    Public Sub DrawUnicodeOnPicturebox(ByRef Pct As PictureBox, ByVal sText As String)
       Dim rct As RECT
       
      'Pct.ScaleMode = vbPixels         ...... Done in design mode (on the screen instead of in the code)
      'Pct.AutoRedraw = True            ...... Done in design mode (on the screen instead of in the code)
       Pct.Cls
       rct.Top = 0                      'Set Margin
       rct.Left = 0                     'Set Margin
       rct.Right = rct.Left + Pct.Width
       rct.Bottom = rct.Top + Pct.Height
       
       DrawTextW Pct.hDC, StrPtr(sText), Len(sText), rct, DT_WORDBREAK Or DT_CALCRECT
       DrawTextW Pct.hDC, StrPtr(sText), Len(sText), rct, DT_WORDBREAK
       Pct.Refresh
    End Sub
    And I am going to use that in my project.
    But, there is still one problem.
    The line is NOT broken into a new line when it reaches the right border of the Picturebox.

    Even though my code (above) uses the DT_WORDBREAK, it does NOT continue the rest of a long line in a new line.

    Here is a screen print:
    https://i.imgur.com/fQ01NLl.jpeg

    Please help
    Thanks.

  28. #28
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: Visual Basic has stopped working. Why?

    It looks like your Pct.ScaleMode = vbPixels has been commented out, have you set the ScaleMode of the PictureBox to vbPixels in the Properties pane? If not, your ScaleMode is probably vbTwips, and your draw rectangle will be 10-15x the width/height you want as most APIs use Pixels exclusively.

  29. #29

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by jpbro View Post
    It looks like your Pct.ScaleMode = vbPixels has been commented out, have you set the ScaleMode of the PictureBox to vbPixels in the Properties pane? If not, your ScaleMode is probably vbTwips, and your draw rectangle will be 10-15x the width/height you want as most APIs use Pixels exclusively.
    Let me first thank you for your help.

    Yes. I have definitely set the Scalemode to pixels in design mode.
    Here is the test project:
    https://www.mediafire.com/file/yk8nj...st010.zip/file

    And here is a new screen print of this test:
    https://i.imgur.com/AGIp596.jpeg

    As you see, the text is truncated off when it reaches the right border of the pictureboxes.
    It does not continue to the next line.
    It should continue to the next line.
    I don't know how to make that happen.

    Please help
    Thanks a lot.
    Ilia

  30. #30
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Visual Basic has stopped working. Why?

    Maybe this thread can help you further;
    https://stackoverflow.com/questions/...break-a-string
    It’s about the DT_EDITCONTROL constant
    https://docs.microsoft.com/nl-nl/win...ectedfrom=MSDN

  31. #31

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by Arnoutdv View Post
    Maybe this thread can help you further;
    https://stackoverflow.com/questions/...break-a-string
    It’s about the DT_EDITCONTROL constant
    https://docs.microsoft.com/nl-nl/win...ectedfrom=MSDN
    Thanks for your help.

    I used DT_EDITCONTROL
    But, that doesn't work either.

    Please help.
    Thanks.

  32. #32
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: Visual Basic has stopped working. Why?

    Please post your latest code (or small sample), with API & constant declarations.

  33. #33

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by jpbro View Post
    Please post your latest code (or small sample), with API & constant declarations.
    Thanks a lot for your response.

    Here is the new test project:
    https://www.mediafire.com/file/qt0we...st011.zip/file

    Please note that there are three command buttons, each of which using a different function to write to the picture boxes.
    The first two command buttons use DrawTextW and the third one uses DrawTextExW

    None of them does it properly.
    All three of the above codes truncate off the line when it reaches the right border of the Picturebox.
    They must break the line into a new line when it reaches the right border of the Picturebox, but they don't.

    Please help.
    Thanks again
    Ilia

  34. #34
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: Visual Basic has stopped working. Why?

    Thanks for supplying the demo code.

    You are using the PictureBox's Width property which will be in the container control's ScaleMode (in this case Twips). You should use the PictureBox's ScaleWidth property instead (which will be in the PictureBox's ScaleMode units - e.g. Pixels).

    For example:

    Code:
    Public Sub Test1_DrawUnicodeOnPicturebox(ByRef Pct As PictureBox, ByVal sText As String)
       Dim rct As RECT
       
       Pct.Cls
       rct.Top = 0                      'Set Margin
       rct.Left = 0                     'Set Margin
       rct.Right = Pct.ScaleWidth
       rct.Bottom = Pct.ScaleHeight
       
       DrawTextW Pct.hDC, StrPtr(sText), Len(sText), rct, DT_WORDBREAK Or DT_EDITCONTROL
       Pct.Refresh   
    End Sub

  35. #35

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2010
    Posts
    762

    Re: Visual Basic has stopped working. Why?

    Quote Originally Posted by jpbro View Post
    Thanks for supplying the demo code.

    You are using the PictureBox's Width property which will be in the container control's ScaleMode (in this case Twips). You should use the PictureBox's ScaleWidth property instead (which will be in the PictureBox's ScaleMode units - e.g. Pixels).

    For example:

    Code:
    Public Sub Test1_DrawUnicodeOnPicturebox(ByRef Pct As PictureBox, ByVal sText As String)
       Dim rct As RECT
       
       Pct.Cls
       rct.Top = 0                      'Set Margin
       rct.Left = 0                     'Set Margin
       rct.Right = Pct.ScaleWidth
       rct.Bottom = Pct.ScaleHeight
       
       DrawTextW Pct.hDC, StrPtr(sText), Len(sText), rct, DT_WORDBREAK Or DT_EDITCONTROL
       Pct.Refresh   
    End Sub
    Yes. It works fine now.

    Thanks a lot for all your help.
    Ilia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width