Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / DB Pro inside VB.net App

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th May 2007 19:27 Edited at: 17th May 2007 19:31
I created this thread to discuss this topic, as the original by Jasuk70 is too old to post in.

For reference, this is Jasuk70's original post:

http://forum.thegamecreators.com/?m=forum_view&t=68687&b=1

And this is IanM's utility post, which is also a necessary part of this discussion:

http://forum.thegamecreators.com/?m=forum_view&b=18&t=85209&p=0


The Issue
==========

I have this code working to an extent. I have used Jason's framework, and changed the application to my own.
Next, I changed the enhancements File Map commands and replaced them with IanM's Memory Bank equivalents, as suggested by Wolf. This does indeed bring the whole thing to life, and the heartbeat works. The mouse coordinates are passed and messages can be exchanged.

The problem is that I now have a black DB Pro screen, rather than my application. As you can see in the image below, I had a visible screen, until I replaced the Memory Bank commands...



I have tracked this down to the following line of code in Jason's ProcessMessage() function:

aMessage=bank String$(cMAPSEND,0, 1024)

This retrieves the message from the memory bank in order to respond. I think it is probably the bank size that causes the problems.
In the VB app, it is 2048 bytes. I have tried this value, and also 1024 to prevent it running over. The data itself is about 10 bytes long, but could be any length. With the original File Map commands, no size was required so I have nothing to relate it to.
Other similar commands work, such as the heartbeat. But here, I know the length is exactly 4 bytes. Hence my reasoning that the length is the issue.

Any profound thoughts on the matter?

General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 17th May 2007 19:40
1p

I have AMD Athlon X2 5200+, Geforce 7600GS, 2GB Ram, 240GB HDD and one hell of a headache
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 17th May 2007 20:33
Batvink,
One thing to be careful of (and might be what is causing your problem)....
If you run the VB app and it starts you DBpro app, your DBpro App may get started in the Visual Basic editor INSTEAD of your VB application. To prevent this from happening, make sure you actually close the form in your Visual Basic editor. This problem still gets me all of the time. You can hear "Doh!" a lot when I work on my GUI because of this issue.

Another reccomendation. In your DBpro app's display settings, make sure you select "Hidden" as the display mode. This will prevent DBpro from fighting with VB to be active. It still displays, it just doesn't try to become the active window.
Also, another thing to note. You have to pass all of the user input through VB to your DBpro app. So, that means any key presses and/or mouseclicks have to come through VB to DB. This complicates things on DBpro's side a bit, but it is worth the effort.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th May 2007 21:07
I'd also suggest that you don't use strings to pass events unless you actually need to pass a string. If you were sending event across the network, then it may be warranted to avoid byte-order issues, but not when passing data through memory.

The size parameters for the bank string commands were a deliberate design decision on my part - I did it that way to avoid accidental overwriting of data further into the bank, and to avoid attempting to read a string where the terminating null byte had been overwritten.

If you specify 10 characters and attempt to write 11, the overflow characters are silently dropped. If you specify 10 characters and only attempt to write 5, then the final 5 characters in the bank are filled with nulls. In that case, when you attempt to read 10 characters, you will only get the 5 you actually wrote.

Here's a small test program you can play around with:


The bank is filled with random bytes, then a string is written to it, and finally, the bytes are displayed (columns are byte number, value before, value after).

Try changing the size of the bank to a value under 11 to see how it's handled. Don't increase above 30 unless you increase your resolution.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th May 2007 21:31 Edited at: 17th May 2007 21:34
make sure you actually close the form in your Visual Basic editor
select "Hidden" as the display mode
You have to pass all of the user input through VB to your DBpro app. So, that means any key presses and/or mouseclicks have to come through VB to DB

I spent an hour reading and implementing Jason's stuff, so I have most of it covered. I've now also made it hidden, which I hadn't done.

Ian - the strings are actually being sent successfully. I am outputting the data to the screen, and it's all in tact. But when I add that 1 line to read the string, the screen goes black

[EDIT] DOH!!!! I can't believe what the problem was, given that Wolf has already told me that this is the biggest issue with DBP in a VB app.

The message is actually a "Resize WIndow" trigger. So the window gets resized and DBP loses everything, just as it would with a normal DBP app.

Time to add my object reload function to the mix, methinks.

Thanks guys.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th May 2007 21:59
Are you changing the resolution when you get a resize? You might consider just changing the window size instead with SET WINDOW SIZE - that doesn't cause any media to be unloaded because it doesn't change the resolution.

Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 17th May 2007 22:13
Quote: "Are you changing the resolution when you get a resize? You might consider just changing the window size instead with SET WINDOW SIZE - that doesn't cause any media to be unloaded because it doesn't change the resolution."


I'm pretty sure that if you do that the DBpro window becomes disconnected from the VB control.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th May 2007 01:31
SET WINDOW SIZE gives the window a border and a title bar unfortunately.

This is coming together quite nicely. I can pick up the mouse movement and clicks, and have converted some of my camera movements to prove I can do what I used to do when it was standalone.

I have a simple question though How do I set the mouse position in VB? I want the mouse to stay where it is when I click and drag in the DBPro window.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd May 2007 19:37
I have tried to stop the mouse moving under certain circumstances (clicking and draging the scene). But when I do, the mouse "jumps" to a different position initially. I'm doing it as part of the VB code, anyone see my problem?

This is the Mouse module, which incorporates the calls to movingthe mouse programmatically:


In the MouseDown event of the DBPro container, I save the coordinates:


and in the MouseMove event, I keep moving the mouse back from whence it came:


BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd May 2007 23:18
OK, I found the cursor class. I still have issues, but that is with the comms side of the setup. Brainache

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Jun 2007 16:10 Edited at: 5th Jun 2007 16:10
I've asked this question in IanM's thread, but it may be just as relevant here. It's about getting / setting integers and floats in Shared memory in VB.

Quick question about file banks...you can WRITE BANK FLOAT and WRITE BANK INTEGER, and obviously get BANK FLOAT and get BANK INTEGER.
Does anyone know what the VB.net equivalents are? There only seems to be SharedMemory.getByte, SharedMemory.SetByte, and SharedMemory.ToString - no Singles or Integers

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Jun 2007 15:10
I don't know if this will help, but I came across this today while browsing through the CodeProject site : http://www.codeproject.com/dotnet/ShareImageAcrossProcesses.asp

It's C# but I don't think you'll have too much trouble porting/interpreting it for VB.NET

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Jun 2007 17:01
Thanks IanM. JohnY showed me some valuable stuff with the BitConverter class yesterday, which I have working today. I plan to post an improved version of Jasuk70's code once I have it perfected. There's nothing wrong with the original, in fact there is so much untapped potential in it that I am just starting to discover.

The link you posted gives me more ideas for this method. The potential for sharing web cams and other resources is interesting.

Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 20th Jun 2007 04:57
Would anyone mind translating the VB.NET code to C#?

http://3dfolio.com

Login to post a reply

Server time is: 2024-04-26 22:56:44
Your offset time is: 2024-04-26 22:56:44