Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Help needed converting a VB6 Project

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-12-2008, 02:52 PM
Junior Member
 
Join Date: Sep 2008
Posts: 15
Default Help needed converting a VB6 Project

Hi Guys,
Any help would be great.

How can I do the following:
PictureBox Arrays:
Bug(0) to Bug(7)

for i = vaderst to vaderfin
bug(i).Left = looperx:Bug(i).Top = loopery
next


Image Arrays:
imaBugSplat(0) to imgBugSplat(7)
Bug(BKI) = imgBugSplat(KI) '<---KILLS BUGS DEAD

I am also having trouble with this line:
Randomize Val(Right(Time$, 2)) / 3.17412

Line's and Shapes's were easy to convert:
pen1.Color = cGold
line(160,150,160,350)

Sub Line(x1,y1,x2,y2)
drawer.DrawLine(pen1.Value,x1,y1,x2,y2)
drawer.Refresh(x1-x2,y1-y2,x1-x2,y1-y2)
End Sub


Can we Use/Create VB6 Class Modules

Is their an equivelent of the following:

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long,_
ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long,_
ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long


Thanks in advance,

Andrew.
Reply With Quote
  #2 (permalink)  
Old 10-12-2008, 07:23 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

VB6 PictureBoxes are Image controls in Basic4ppc.
Create 7 images (at the beginning of your program):
Code:
    'create 7 image controls
For i = 0 To 7 
    AddImage(
"Form1","Image" & i,x,y,width,height)
Next
Move images:
Code:
    For i = vaderst To vaderfin
    Control(
"Image" & i).Left = looperx
    Control(
"Image" & i).Top = loopery
Next
You can store the images (not controls) in an ImageList and then assign these images to the image controls when needed:
Code:
Control("Image" & BKI) = ImageList.Item(KI)
What values do you expect from the Randomize statement?
It is not possible to use VB6 class modules..
Basic4ppc can only interact with .Net modules (c# or VB.Net)
There is no equivalent to BitBlt.
Reply With Quote
  #3 (permalink)  
Old 10-13-2008, 11:55 AM
Junior Member
 
Join Date: Sep 2008
Posts: 15
Default Re Help Needed converting a VB6 Project

Hi Erel,

Thank you for your speedy and helpfull responce.

The code samples you provided work a treat.

The Randomize statement is used to generate randome enemy fire
by setting and resetting the tmrTimer_EnemyFire Subroutine.

Any chance that you or one of your many Library coders could
create a Basic4ppc bitblt dll?

Thanks again.

Regards,
Andrew
Reply With Quote
  #4 (permalink)  
Old 10-13-2008, 02:09 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

There are several image libraries available.
I'm not familiar enough with bitblt. What do you need it for? Maybe there is already an alternative way.
Reply With Quote
  #5 (permalink)  
Old 10-13-2008, 04:49 PM
Junior Member
 
Join Date: Sep 2008
Posts: 15
Default

Hi again Erel,

Please find below as requested!

BitBlt quite simply makes copies of portions of the screen.
This is done by accessing the Windows hDC and other low level mind numbing things.
This is similar to your:


drawer.New1("Form1",true)
rectSrc.New1(0,0,bmp.Width,bmp.Height) 'The source rectangle.
rectDest.New1(120,120,36,32)
drawer.DrawImage1(bmp.Value,rectSrc.Value,rectDest .Value,true)
Form1.DrawString("Try to catch the smiley",12,10,10,200,50,cBlack)


It is a very fast routine, you dont get the flickering as you do in tha above routine
This has been on the go since VB3 and I still use it in VB6:

Declare the functions that are in the GDI32.DLL file so we can use them in VB.NET.

Declare Auto Function BitBlt Lib "GDI32.DLL" ( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Int32) As Boolean

Private Function copyRect(ByVal src As PictureBox, _
ByVal rect As RectangleF) As Bitmap

'Get a Graphics Object from the form

Dim srcPic As Graphics = src.CreateGraphics

'Create a EMPTY bitmap from that graphics

Dim srcBmp As New Bitmap(src.Width, src.Height, srcPic)

'Create a Graphics object in memory from that bitmap

Dim srcMem As Graphics = Graphics.FromImage(srcBmp)

'get the IntPtr's of the graphics

Dim HDC1 As IntPtr = srcPic.GetHdc

'get the IntPtr's of the graphics

Dim HDC2 As IntPtr = srcMem.GetHdc

'get the picture

BitBlt(HDC2, 0, 0, rect.Width, _
rect.Height, HDC1, rect.X, rect.Y, 13369376)

'Clone the bitmap so we can dispose this one

copyRect = srcBmp.Clone()

'Clean Up

srcPic.ReleaseHdc(HDC1)
srcMem.ReleaseHdc(HDC2)
srcPic.Dispose()
srcMem.Dispose()
srcMem.Dispose()
End Function


Then all we need to do is call the function to return the image we want:

Dim bmp = CType(copyRect(src, _
New RectangleF(0, 0, 50, src.Height)), Bitmap)
dest.Image = bmp.CloneShorthand:

-or-
dest.Image = CType(copyRect(src, _
New RectangleF(0, 0, 50, src.Height)), Bitmap).Clone


Regards,
Andrew.
Reply With Quote
  #6 (permalink)  
Old 10-13-2008, 06:40 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Thanks.
Maybe I will get to it later.
However if anyone is interested in building such a library it shouldn't be too complicated.
Alex Yakhnin blog has a post about it: Alex Yakhnin - Creating a screen snapshot in CF v2.
Reply With Quote
  #7 (permalink)  
Old 10-13-2008, 08:44 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Erel View Post
However if anyone is interested in building such a library it shouldn't be too complicated.
That's what I thought but! .... .... there is some hidden twist that I don't presently understand. having obtained the hdcs for a couple of .NET Bitmaps I can BitBlt BLACKNESS and WHITENESS onto the destination bitmap but even thought BtBlt returns true (success) it won't pick up the contents of the source bitmap for SRCCOPY and the other SRC... raster ops. I have no idea why I'll look again tomorrow - my brain's hurting!
Reply With Quote
  #8 (permalink)  
Old 10-13-2008, 08:51 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
That's what I thought but! .... .... there is some hidden twist that I don't presently understand. having obtained the hdcs for a couple of .NET Bitmaps I can BitBlt BLACKNESS and WHITENESS onto the destination bitmap but even thought BtBlt returns true (success) it won't pick up the contents of the source bitmap for SRCCOPY and the other SRC... raster ops. I have no idea why I'll look again tomorrow - my brain's hurting!
Oops. There are many simple looking computer problems that end with huge efforts.
How about this one:
Can you write a program that receives some code and checks if this code always stop?
http://en.wikipedia.org/wiki/Halting_problem
Reply With Quote
  #9 (permalink)  
Old 10-14-2008, 08:34 AM
Junior Member
 
Join Date: Sep 2008
Posts: 15
Default

agraham,

It seems that you have taken up the bitblt challenge!

Find below the site I use for code snippets, it has another article on bitblt
which may solve the problem you are finding!

CodeProject: Using BitBlt to Copy and Paste graphics. Free source code and programming help

This link has the code example and a demo project, the code is related to my
earlier post.

If you have a problem let me know.

Regards,
Andrew.
Reply With Quote
  #10 (permalink)  
Old 10-14-2008, 01:21 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Drewpeu View Post
If you have a problem let me know.
Lots of problems interoperating from GDI+ to GDI which explains the odd behaviour I have observed while experimenting. INFO: Interoperability Between GDI and GDI+. The key paragraph is "Using GDI on a GDI+ Graphics Object Backed by a Bitmap"

A concise summary of a highly technical situation.

An hDC from a .NET Graphics for a Bitmap created by Graphics.FromImage(Bitmap) is effectively write-only as the underlying bitmap is not initialised. Therefore you can draw on it but not use it as a source.

An hDC from a .NET Graphics for a Control created by Control.CreatGraphics().GetHdc() is both readable and writeable as a physical bitmap exists on the screen.

Therefore BitBlt can be used for screen capture using the SRCCOPY rasterop to a destination bitmap and for very little else as the combinatorial rasterops do not have a destination to read. For this reason the the BitBlt way of achieving tranparency and animation won't work as it relies on the combinatorial rasterops SRCAND and SRCPAINT

GDI gurus may have a way round this but I am afraid that I don't know enough about GDI (and don't want to learn either) so I'll have to give up for now.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting date to ticks value mozaharul Questions (Windows Mobile) 3 10-22-2008 09:51 AM
Have a look to the project and please correct me. mozaharul Questions (Windows Mobile) 2 10-13-2008 03:02 AM
Problem Converting CSV to SQLite tcgoh Questions (Windows Mobile) 5 11-01-2007 02:50 AM
Battery Saver project Cableguy Questions (Windows Mobile) 1 07-12-2007 07:02 PM
specifying datatypes when converting table to SQLite DB Steve Questions (Windows Mobile) 1 06-14-2007 04:56 AM


All times are GMT. The time now is 07:45 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0