PiggyBank1974
Member
- Joined
- Sep 28, 2004
- Messages
- 7
Hi there,
Im trying to convert some of my VB6 code to VB.net, but im having a problem getting the following code to work(Create the region).
this is the VB6 code:
Here is the vb.net code
It seams to load the ata ok but does not create the region, could anybody shed any light on the subject.
I would use SetWindowRgn but I dont know how to get a HWND for a usercontrol in vb.net.
Any help would be great.
the pig..
Im trying to convert some of my VB6 code to VB.net, but im having a problem getting the following code to work(Create the region).
this is the VB6 code:
Code:
Dim FileNum As Long
Dim RegionBufferSize As Long
Dim RegionBuffer() As Byte
Dim Width As Long
Dim Height As Long
Dim TempString As String
Dim Plain As String
Dim RegionHandle As Long
Dim a As Long
Open the region file and extract the region buffer
FileNum = FreeFile
If Index >= 0 And Index <= 60 Then
Plain = "6-"
Else
Plain = "9-"
End If
TempString = Trim$(Plain & Trim$(Str$(Degree) & ".rgn"))
Debug.Print "Index" & index & " " & App.Path + "\\" + TempString
Open App.Path + "\\DataFiles\\Regions\\" + TempString For Binary Access Read As #FileNum
RegionBufferSize = LOF(FileNum)
If RegionBufferSize > 8 Then
ReDim RegionBuffer(RegionBufferSize - 9)
Get #FileNum, 1, Width
Get #FileNum, 5, Height
Get #FileNum, 9, RegionBuffer
Close #FileNum
Else
Close #FileNum
Exit Sub
End If
Create the region from the region buffer, and apply it to the window
RegionHandle = ExtCreateRegion(ByVal 0, RegionBufferSize, RegionBuffer(0))
If oldRgn Then
DeleteObject oldRgn
End If
oldRgn = SetWindowRgn(UserControl.hwnd, RegionHandle, True)
Here is the vb.net code
Code:
Private Sub LoadRegion()
Dim FileNum As Integer
Dim RegionBufferSize As Integer
Dim RegionBuffer() As Byte
Dim Width As Integer
Dim Height As Integer
Dim TempString As String
Dim Plain As String
Dim RegionHandle As Integer
Dim f As System.IO.File
If f.Exists(Application.StartupPath & "\\Region\\" + CardID.ToString + ".rgn") = True Then
Dim BR As System.IO.BinaryReader
Dim FS As System.IO.FileStream
FS = New System.IO.FileStream(Application.StartupPath & "\\Region\\" + CardID.ToString + ".rgn", System.IO.FileMode.Open, System.IO.FileAccess.Read)
BR = New System.IO.BinaryReader(FS)
BR.BaseStream.Seek(0, System.IO.SeekOrigin.Begin)
RegionBufferSize = CInt(FS.Length)
ReDim RegionBuffer(RegionBufferSize - 9)
Width = BR.ReadInt32
Height = BR.ReadInt32
RegionBuffer = BR.ReadBytes(RegionBuffer.Length)
BR.Close()
FS.Close()
End If
Create the region from the region buffer, and apply it to the window
RegionHandle = API_Calls.ExtCreateRegion(0, RegionBufferSize, RegionBuffer(0))
Me.Region.FromHrgn(New System.IntPtr(RegionHandle))
End Sub
It seams to load the ata ok but does not create the region, could anybody shed any light on the subject.
I would use SetWindowRgn but I dont know how to get a HWND for a usercontrol in vb.net.
Any help would be great.
the pig..