Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb 2008 drawline not working in Vista

Posted on 2009-04-12
5
Medium Priority
?
328 Views
Last Modified: 2013-11-08
What am I missing here?

I am using Visual Basic Express 2008.

I have a working pilot logbook and flight planning application, which was written, compiled, and functions well in Windows XP on my old PC.

The application  uses e.graphics.drawline, e.graphics.drawcircle, e.graphics.drawarc, e.graphics.drawellipse and e.graphics.drawrectangle to draw a simple flight plan chart.

When I compile the code and run it on my new laptop (Sony Vaio VGN-NS15G) none of the lines, arcs, circles or rectangles appear. There are no runtime errors.

The rest of the programme runs fine on the laptop. It is just the graphics functions that are ignored so I am assuming it is a result of some setting or switch that I have missed  to make the graphics visible on the Vista laptop.

What am I overlooking?

0
Comment
Question by:bantamb20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 2000 total points
ID: 24129260
I'm guessing from you example that the lines etc. are being drawn in the OnPaint event. What type of control are you painting onto? Also, have you added a breakpoint in the OnPaint event to verify that it's being executed?

A workaround could be to create a bitmap on which you draw your flight plan, and then set the bitmap as the Image for a PictureBox control. The bonus with doing this is that you only have to draw the image once, not ever time the control gets redrawn, and also you'll be able to save the image (if you're so inclined)
0
 

Author Comment

by:bantamb20
ID: 24132731

I am painting to the form  using the form_paint subroutine, not OnPaint.
This process works fine in the XP environment.

First the DrawAll sub is executed, which contains the various subs to draw each portion of the flight plan. This enabled me to debug the earlier version easily, and allows users to choose various overlays, add text for latitude and longitude, names of places and so on.
All this worked fine in  XP.

I have checked with breakpoints, and yes it is executing all the code.

I have attached the form_paint code, the DrawAll sub, and the simplest of the  other subs it calls, the DrawBorder sub.

Your suggestions of using OnPaint and drawing to a bitmap are good ones. I will investigate and see what's involved to change the present method of drawing the plan.

I am going flying today so won't be able to complete the task now, but will get on to it asap.

Cheers


 
    ' ==================================================================
    '  paint this form and draw the flight track and other little bits
    ' ------------------------------------------------------------------
    Private Sub frmShowMap_Paint(ByVal sender As Object, ByVal e As  _
    System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
 
        Try
 
            If bGo Then
                Cursor = Cursors.WaitCursor
                DrawAll(e)
            End If
 
        Catch ex As Exception
            Cursor = Cursors.Default
            MsgBox(ex.Message)
        End Try
 
        Cursor = Cursors.Default
 
    End Sub
 
 
 
    ' ==================================================================
    '  draw background map, aircraft tracks, zone, area boundaries,text 
    ' ------------------------------------------------------------------
    Private Sub DrawAll(ByVal e As PaintEventArgs)
 
        Try
            If bGo = True Then
                bGo = False
 
                ' draw debugging grid
                DrawGraticule(e)
 
                ' draw border around map area
                DrawBorder(e)
 
                ' draw nz background map
                DrawNZMap(e, bShowMap)
 
                ' draw latitude and longitude grid
                DrawGrid(e, bShowGrid)
 
 
                ' draw airport control zones CTR. if files exist and zones in area, draw them
                If CTZFindFiles() And CTZonesInArea() Then CTZonesDraw(e, bShowCTZones)
 
                ' draw danger areas 
                DrawDanger(e)
 
                ' draw temporary airspace restrictions
                DrawTempo(e)
 
                ' draw tracks and aerodromes and waypoints
                DrawTracks(e, bShowTrack)
 
                ' write mag heading or distance and leg time text along track line 
                DrawText(e, bShowText)
 
            End If
 
        Catch ex As Exception
            MsgBox(ex.Message & " drawmap error")
        End Try
 
    End Sub
 
 
 
    ' ==========================================================
    '  draw border around map
    ' ----------------------------------------------------------
    Private Sub DrawBorder(ByVal e As PaintEventArgs)
        Try
            e.Graphics.DrawRectangle(Pens.Black, 2, 2, MEWIDTHH, MEHEIGHT)
        Catch ex As Exception
            MsgBox(ex.Message & " --- drawborder")
        End Try
 
    End Sub

Open in new window

0
 
LVL 15

Expert Comment

by:oobayly
ID: 24132776
Now that's a hobby/job I wouldn't mind having.

If the Paint event doesn't do the job, I very much doubt that the OnPaint override would do the job. I can only imagine it's an effect of the Aero interface. Not that I've seen any mention of there being issues with drawing on a form's graphics object in Vista.
0
 

Author Comment

by:bantamb20
ID: 24142166

I have re-written the map display section to draw to a bitmap and display it on  a picture box.  It works well thanks

[The flying (microlights) and the coding are both hobbies . . .  one more expensive than the other]
0
 

Author Closing Comment

by:bantamb20
ID: 31569395
The programme now works well in Vista as well as XP with this bitmap solution, it's a sunny day ... time to go flying and turn some petrol into noise . . . cheers
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question