Contractor UK Bulletin Board  PayStream

Go Back   Contractor UK Bulletin Board > Contractor UK Forums > Technical
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 14th July 2008, 08:33   #11
zeitghost
More fingers than teeth
 
zeitghost's Avatar
 
Join Date: Jul 2005
Posts: 14,808
Default

Indeed.

It's a 3.5" floppy, I'll have you know... really up to the minute here...
zeitghost is offline   Reply With Quote
Old 14th July 2008, 08:33   #12
zeitghost
More fingers than teeth
 
zeitghost's Avatar
 
Join Date: Jul 2005
Posts: 14,808
Default

Code:
VERSION 2.00
Begin Form frmWfaxdisp 
   Caption         =   "Weather Fax Display Program"
   ClientHeight    =   5820
   ClientLeft      =   1095
   ClientTop       =   1770
   ClientWidth     =   7365
   Height          =   6510
   Left            =   1035
   LinkTopic       =   "Form1"
   ScaleHeight     =   388
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   491
   Top             =   1140
   Width           =   7485
   Begin CommonDialog CMDialog1 
      Left            =   2160
      Top             =   6600
   End
   Begin PictureBox picDisplay 
      Align           =   1  'Align Top
      AutoSize        =   -1  'True
      BorderStyle     =   0  'None
      DrawMode        =   4  'Not Copy Pen
      Height          =   9000
      Left            =   0
      Picture         =   WFAXDISP.FRX:0000
      ScaleHeight     =   600
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   491
      TabIndex        =   0
      Top             =   0
      Width           =   7365
   End
   Begin Menu mnuFile 
      Caption         =   "File"
      Begin Menu mneSelect 
         Caption         =   "Select File"
      End
      Begin Menu mnuSep2 
         Caption         =   "-"
      End
      Begin Menu mnuSave 
         Caption         =   "Save File"
      End
      Begin Menu mnuSep1 
         Caption         =   "-"
      End
      Begin Menu mnuExit 
         Caption         =   "E&xit"
      End
   End
End
Option Explicit
'File Open/Save Dialog Flags
 Const OFN_READONLY = &H1&
 Const OFN_OVERWRITEPROMPT = &H2&
 Const OFN_HIDEREADONLY = &H4&
 Const OFN_NOCHANGEDIR = &H8&
 Const OFN_SHOWHELP = &H10&
 Const OFN_NOVALIDATE = &H100&
 Const OFN_ALLOWMULTISELECT = &H200&
 Const OFN_EXTENSIONDIFFERENT = &H400&
 Const OFN_PATHMUSTEXIST = &H800&
 Const OFN_FILEMUSTEXIST = &H1000&
 Const OFN_CREATEPROMPT = &H2000&
 Const OFN_SHAREAWARE = &H4000&
 Const OFN_NOREADONLYRETURN = &H8000&

Sub mneSelect_Click ()
'dim nestring( 800,400 ) as string
 Dim filenum As Integer
 Dim input_char As String
 Dim R, G, B As Integer       'point colour
 Dim X, Y           'point location
 Dim loop_count As Long
 Dim file_byte_count As Long
 
 frmGetFile.cboFileType.AddItem "Fax Files (*.DUP)"
 frmGetFile.cboFileType.ListIndex = 0
 frmGetFile.Show 1

 MsgBox frmGetFile.Tag
 If frmGetFile.Tag = "" Then Exit Sub

 filenum = FreeFile

 Open frmGetFile.Tag For Binary As #filenum
 file_byte_count = LOF(filenum)

 Debug.Print file_byte_count

 X = 1
 Y = 1

 For loop_count = 1 To file_byte_count Step 1
 input_char = Input$(1, #filenum)

 'MsgBox "input char " + Hex$(Asc(input_char))
 R = Asc(input_char)
 G = Asc(input_char)
 B = Asc(input_char)

 frmWfaxdisp.picDisplay.PSet (X, Y), RGB(R, G, B) 'firkle pixel

 X = X + 1
 If X > 1599 Then 	'end of line?
    X = 0
    Y = Y + 1		'new line
    DoEvents
 End If

 If Y > frmWfaxdisp.picDisplay.ScaleHeight Then 'bottom of window?
 MsgBox "got to end of picturebox"
 Y = 0
 End If

 Next

 'frmWfaxdisp.picDisplay.AutoRedraw = True 'didn't work...

End Sub

Sub mnuExit_Click ()
 End
End Sub

Sub mnuSave_Click ()

Dim filetosave As String


CMDialog1.DialogTitle = "Save As"
CMDialog1.Flags = OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST
CMDialog1.Filter = "All Pictures|*.bmp;*.wmf;*.ico"
CMDialog1.Action = 2

'store name of file to save
filetosave = CMDialog1.Filename
If filetosave = "" Then Exit Sub

MsgBox filetosave
'just in case, set up error handler
On Error GoTo notSaved

'save the picture in picDisp to the file specified in filetosave
SavePicture frmWfaxdisp.picDisplay.Picture, filetosave
Exit Sub

notSaved:
MsgBox "Could not save file " + filetosave, 48, "File Save Error"
Resume Next

End Sub

Sub picDisplay_Change ()
 MsgBox "changed"
End Sub
zeitghost is offline   Reply With Quote
Old 14th July 2008, 08:34   #13
zeitghost
More fingers than teeth
 
zeitghost's Avatar
 
Join Date: Jul 2005
Posts: 14,808
Default

There you are... have a good larf...
zeitghost is offline   Reply With Quote
Old 14th July 2008, 17:49   #14
NickFitz
Super poster
 
NickFitz's Avatar
 
Join Date: Jun 2007
Location: Your local branch
Posts: 2,779
Default

First, you need to set the AutoRedraw property to True before you do the drawing - the system then knows to keep track of what you draw. Otherwise, it expects you to have a Paint event handler that will redraw it every time.

You can check if this is the problem by hiding the window behind another window and then bringing it to the front again - if the PictureBox isn't redrawn, then change the code to set AutoRedraw before drawing, and try again - it should now work as expected.

(The hide/show test may also be graphics-driver-dependant, so do the AutoRedraw thing even if it seems unnecessary after the first hide/show test.)

If that's working but it's still not saving correctly, try changing
Code:
SavePicture frmWfaxdisp.picDisplay.Picture, filetosave
to
Code:
SavePicture frmWfaxdisp.picDisplay.Image, filetosave
and see if that works.

Finally, some people claim that setting the PictureBox's Picture property to the value of its Image property will work, but that sounds a bit voodoo chicken to me - also, the VB docs seem to suggest that the Picture property is read-only at runtime. But if all the above fails, give that a try - revert the change to the SavePicture call as well if you try this.
NickFitz is offline   Reply With Quote
Old 14th July 2008, 21:40   #15
zeitghost
More fingers than teeth
 
zeitghost's Avatar
 
Join Date: Jul 2005
Posts: 14,808
Default

Danke.

I shall try that tomorrow.

I frigged about with that image thingie last week to no great avail... but then I don't know what I'm doing anyway...

I loaded up my, er, "copy" of VB3 pro today, coz it's got the MSCOMM thingie in it...

I've hacked about with the VBTERM example & have it writing stuff to a Picture that I've added.

It actually shows the range of the pll chip is quite limited, I may have to shift some bits in the PIC to restore it to something more applicable.

Or alternatively, I may attempt to use the external VRef I designed onto the board...
zeitghost is offline   Reply With Quote
Old 15th July 2008, 08:45   #16
zeitghost
More fingers than teeth
 
zeitghost's Avatar
 
Join Date: Jul 2005
Posts: 14,808
Default

Quote:
Originally Posted by NickFitz View Post
First, you need to set the AutoRedraw property to True before you do the drawing - the system then knows to keep track of what you draw. Otherwise, it expects you to have a Paint event handler that will redraw it every time.

You can check if this is the problem by hiding the window behind another window and then bringing it to the front again - if the PictureBox isn't redrawn, then change the code to set AutoRedraw before drawing, and try again - it should now work as expected.
Yup.

Did that, it now redraws ok... still doesn't save the image though...

I'm onto the next suggestion now, with the .Image thingie instead of the .Picture thingie...

This is so exciting...
zeitghost is offline   Reply With Quote
Old 15th July 2008, 08:53   #17
zeitghost
More fingers than teeth
 
zeitghost's Avatar
 
Join Date: Jul 2005
Posts: 14,808
Default

Yes! Yes! Yes!.... the .Image thing does the business...
zeitghost is offline   Reply With Quote
Old 15th July 2008, 08:58   #18
zeitghost
More fingers than teeth
 
zeitghost's Avatar
 
Join Date: Jul 2005
Posts: 14,808
Default

Muchos gracias...
zeitghost is offline   Reply With Quote
Old 15th July 2008, 14:14   #19
NickFitz
Super poster
 
NickFitz's Avatar
 
Join Date: Jun 2007
Location: Your local branch
Posts: 2,779
Default

Quote:
Originally Posted by zeitghost View Post
Muchos gracias...
HTH

You'd never guess that I've never done any VB programming, would you
NickFitz is offline   Reply With Quote
Old 15th July 2008, 14:16   #20
DaveB
Super poster
 
DaveB's Avatar
 
Join Date: Oct 2005
Posts: 4,164
Default

Quote:
Originally Posted by NickFitz View Post
HTH

You'd never guess that I've never done any VB programming, would you
Tell Bob and the rest of the Mumbai posse well done
__________________
Sometimes the appropriate response to reality is to go insane.
- Philip K. Dick
DaveB is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT. The time now is 06:11.


Advertisers
PayStream

CUK Navigation

Contractor Alliance
Formed a new Ltd Co?

20% off business insurance
£10 off Bauer & Cottrell contract reviews
Find co-workers & client introductions

Increase your value to clients here

Fast Company Formation
Same day online company formation £75 + VAT

Form your Ltd Co Here

Contractor Services


 
Content Relevant URLs by vBSEO 2.4.0 © 2005, Crawlability, Inc.