problem in VB6

Q&A for Visual Basic, Visual Basic .NET, and PowerBasic developers using DPlot

Moderator: DPlotAdmin

Post Reply
walleye3313
Posts: 28
Joined: Sat Jun 04, 2005 9:00 am

problem in VB6

Post by walleye3313 »

David,

i'm back at it agian, and now i am using your exapmle from btest2 to draw a plot into a form. i simply imported your example into my code and remmed my code, now i get the bitmap in the picture box but i also get Jr opening up and showing the plot at the same time.

maybe you can spot the problem?

my code to send the plot along with what i rem'ed:

Code: Select all

'send the plot to screen
    d.Version = DPLOT_DDE_VERSION
    d.DataFormat = DATA_3DR
    d.MaxCurves = 1
    d.MaxPoints = i
    d.NumCurves = 1
    d.ScaleCode = SCALE_LINEARX_LINEARY
    d.Title1 = plotname
    d.Title2 = mydate
    d.Title3 = ""
    d.XAxis = "Latitude"
    d.YAxis = "Longitude"
        
    cmds = "[Caption(" & Chr$(34) & "Preview Plot" & Chr$(34) & ")]"
    cmds = cmds & "[ContourAxes(1)][ContourGrid(0)][ContourLevels(" & spacing & "," & shallow & "," & deep & ")]"
    cmds = cmds & "[FontPoints(1,10)][FontPoints(6,10)][DocMaximize()]"

'put the test stuff in here:

ret = GetClientRect(Picture1.hwnd, rcPic)
    If (hBitmap <> 0) Then
        ret = DeleteObject(hBitmap)
        hBitmap = 0
    End If
    If DocNum <> 0 Then
        ret = DPlot_Command(DocNum, "[FileClose()]")
    End If
    DocNum = DPlot_Plot(d, 0&, Node(0, 0), cmds)
    If (DocNum > 0) Then
        DPM.SIZE = Len(DPM)
        hBitmap = DPlot_GetBitmapEx(DocNum, rcPic.Right - rcPic.Left, rcPic.Bottom - rcPic.Top, DPM)
        ' NOTE: If we want to get Z values from the document (HasMetrics=3), we CANNOT close it.
        ' ret = DPlot_Command(DocNum, "[FileClose()]")
      HasMetrics = 3   ' NOTE: This won't work for 3D, since we can't get X and Y from mouse position
    End If
    Call Picture1_Paint

'>>end of test stuff here
'    ret = DPlot_Plot(d, 0&, Node(0, 0), cmds)

'send the plot to bitmap
'    d.Version = DPLOT_DDE_VERSION
'    d.DataFormat = DATA_3DR
'    d.MaxCurves = 1
'    d.MaxPoints = i
'    d.NumCurves = 1
'    d.ScaleCode = SCALE_LINEARX_LINEARY
'    d.Title1 = plotname
'    d.Title2 = mydate
'    d.Title3 = ""
'    d.XAxis = "Latitude"
'    d.YAxis = "Longitude"
'
'    cmds = "[Caption(" & Chr$(34) & "Contour Stylist Preview Plot" & Chr$(34) & ")]"
'    cmds = cmds & "[ContourAxes(1)][ContourGrid(0)][ContourLevels(" & spacing & "," & shallow & "," & deep & ")]"
'    cmds = cmds & "[FontPoints(1,10)][FontPoints(6,10)][DocMaximize()]"
'    ret = DPlot_Plot(d, 0&, Node(0, 0), cmds)
    

i'm suspicious of the line that reads " DocNum = DPlot_Plot(d, 0&, Node(0, 0), cmds)"

but that does not create a problem in your example??

also later i pasted in :

Code: Select all

Private Sub Picture1_Paint()
Dim bm As BITMAP
    Dim hbmpOld As Long
    Dim hdc As Long
    Dim hdcMem As Long
    Dim ret As Long

    If hBitmap <> 0 Then
        hdc = GetDC(Picture1.hwnd)
        hdcMem = CreateCompatibleDC(hdc)
        If (hdcMem <> 0) Then
            hbmpOld = SelectObject(hdcMem, hBitmap)
            ret = GetObject(hBitmap, Len(bm), bm)
            
            'ret = SetBkMode(hdc, 1)
            'ret = SetBkColor(hdc, RGB(255, 255, 255))
            
            ret = BitBlt(hdc, rcPic.Left, rcPic.Top, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY)
            ret = SelectObject(hdcMem, hbmpOld)
            ret = DeleteDC(hdcMem)
        End If
        ret = ReleaseDC(Picture1.hwnd, hdc)
    End If

End Sub
which is working fine after i rem'ed out those two lines. i am happy with what i see on the screen, just don't want the Jr screen to open, any ideas?

thanks again,
jerry
walleye3313
Posts: 28
Joined: Sat Jun 04, 2005 9:00 am

Post by walleye3313 »

after all of that, i think i found the problem, i need to delete docMaximize() from the cmds string don't I?


cheers
jerry
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Jerry,
Take another look at the example. In the Form_Load event, it is starting DPlot (or DPlot Jr) in a hidden state. That's what the initial 1 does in the call to DPlot_Start. I'm starting it there so that it only needs to be started once, and it stays open (though hidden). If you don't call DPlot_Start with the hidden parameter then any other calls will start DPlot (or DPlot Jr), and it won't be hidden.

You'll also want to duplicate what is done in the Form_Terminate event, shutting down DPlot Jr if it was your application that started it.
Visualize Your Data
support@dplot.com
walleye3313
Posts: 28
Joined: Sat Jun 04, 2005 9:00 am

Post by walleye3313 »

Thanks David that did it.

I now have the plot down to almost exactly what i need. i have three more changes to make, or figure out how to work around.

can I:

1. change all of the colors of the contours to black? once before you posted that i should use [Color(-1,0,0,0)] to make all contours black. but when i tried that i got no change. when i read the help for the color command it appears that it applies to curves and not contours? anyway i found [ContourColorScheme(method)] which would allow for a custom color scheme using [ContourCustomColors(color1,color2,...,color[n-1],color[n])] can i use those in combination to make all my contours black? how would i set up the color1,color2, etc to make that happen? and what wwould happen if there are more than 16 contours which could happen. if this is not do-able then i have a work around in mind that i will try.

2. get rid of the axes scale values?

3. get rid of the black line around the plot?

thanks again for all your help.

jerry
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

1. change all of the colors of the contours to black?
Think of the colors specified with ContourCustomColors as a palette that each interval's color will be interpolated from, rather than color assignments for each interval. If you only specify 2 colors (say red and blue) and have 3 intervals, for example, then the first line will be red, the second will be magenta, and the third will be blue.

In your case you only want 1 color, so that's all you need to specify:
[ContourColorScheme(2)][ContourCustomColors(0)]
2. get rid of the axes scale values?
If you just want to eliminate the numbers, right-click on numbers along the axis and select 'None' for the number format. If you don't want to draw the axes at all, under Contour Plot Options uncheck the "Axes" box (and in this case there's no need to set the number format, numbers won't be drawn.)
3. get rid of the black line around the plot?
Got ahead of myself :-)
Visualize Your Data
support@dplot.com
walleye3313
Posts: 28
Joined: Sat Jun 04, 2005 9:00 am

Post by walleye3313 »

David,

thanks a bunch, i got 1. and 2. squared away.

3 however, hmmmm....

i can turn off the axes in DplotJr using the menu, i could not find an equivalent command to do the same, does one exsist? if not, now worries because i found where i can set the axes color to white which will be an acceptable workaround for what i am trying to do. my strategy is to determine which bits in the bitmap are black and if i turn the axes white they won't show up when i go looking for black! so i can get it done from here if that command is not available.

thanks,
jerry
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

ContourAxes(0)
Visualize Your Data
support@dplot.com
walleye3313
Posts: 28
Joined: Sat Jun 04, 2005 9:00 am

Post by walleye3313 »

OH YEAH!!!!


I finally got it,

well OK: YOU finally got it for me, now lets see if i can get the rest of this thing done this week.

Thanks again,
Jerry
Post Reply