|
IIRC, a long time ago I did this by basically getting the window's handle then calling SetParent() to change its parent to be my app. I figure there was more to it but maybe that will get you started.
|
|
|
|
|
I did a significant amount of programming in QBasic, though that was when I was much younger. I'm trying to move on up, and have 'began' developing many games in visual basic... though most never got beyond the setup phase.
I've been working for some time on a pool game, but am having several problems. I'm not looking for anyone to parse through my code, but included it all in case it is needed. I specifically need help with my trig functions.
The last function in my code (where I need help) is for a timer, with which I reference its interval for my acceleration and velocity formulas. They seem to be working ok. As I understand it, my ATN() function should be returning an angle based on change in y value divided by change in x value updated each interval of time.
I have 6 separate displays for each ball on my screen to show:
x position
y position
distance between it and all other balls (while dragging)
velocity as I drag it around
acceleration as I drag it around
and angle as I drag it around
The problem is that the display for angle only ever shows a -1, 0, 1 (and the very rare 2 for some reason). After I let go of the ball, it flies off (as desired) in the direction it was launched, however the angle seems to be constrained to (guessing) 0, 30, 45, 60 and 90 for each quadrant. I'm afraid that this is based on my using the Sin or Cosine of the velocity and angle it was traveling when I let go of the ball, but I'm really at a loss as to why... it all looks correct to me.
(I also can't get any balls that are hit by my ball dragging across them to move, but that is really a problem I can likely figure out once I get this first issue resolved).
Also, any tips on how to modularize my code better would be appreciated, but I would need pretty specific tips... I've tried creating my own functions before, but they become as bloated as the rest of my code as I am forced to add new things to it periodically.
my e-mail address is cmikaiti@yahoo.com if anyone wishes to contact me personally, where I would be happy to send you the actual files if it helps.
Thanks for any and all helps, tips, and constructive criticism.
-Chris Mikaitis
My current code (messy and uncommented, unfortunately) is as follows:
Option Explicit
Dim x1, y1 As Integer
Dim i, j As Integer
Dim Drag As Boolean
Dim BallNum, GrabbedBall As Integer
Dim VGrabbedBall(1 To 10), AGrabbedBall(1 To 10), AngleGrabbedBall(1 To 10) As Long
Dim VHitBall(1 To 10), AHitBall(1 To 10), AngleHitBall(1 To 10) As Long
Dim BallDirx(1 To 10), balldiry(1 To 10) As Integer
Dim OldX, OldY, OldVelocity As Long
Private Sub Command1_Click()
For _
i = 1 To BallNum
Unload Ball(i)
Unload BallXVal(i)
Unload BallYVal(i)
Unload Proximity(i)
Unload Velocity(i)
Unload Acceleration(i)
Unload Angle(i)
Next i
Unload Form1
End Sub
Private Sub Form_Load()
Randomize
x1 = 0
y1 = 0
i = 0
j = 0
OldX = 0
OldY = 0
OldVelocity = 0
BallNum = 5
GrabbedBall = 1
Drag = False
For _
i = 1 To 10
VGrabbedBall(i) = 0
AGrabbedBall(i) = 0
Next i
For _
i = 1 To BallNum
Load Ball(i)
Do
Ball(i).Left = Int(Rnd(1) * 15000)
Ball(i).Top = Int(Rnd(1) * 11000)
Ball(i).Visible = True
Loop Until _
Ball(i).Left > Table.Left And _
Ball(i).Left + Ball(i).Width < Table.Left + Table.Width And _
Ball(i).Top > Table.Top And _
Ball(i).Top + Ball(i).Height < Table.Top + Table.Height
Load BallXVal(i)
BallXVal(i).Text = Ball(i).Left + 0.5 * Ball(i).Width
BallXVal(i).Visible = True
BallXVal(i).Top = BallXVal(i - 1).Top + BallXVal(i - 1).Height
Load BallYVal(i)
BallYVal(i).Text = Ball(i).Top + 0.5 * Ball(i).Height
BallYVal(i).Visible = True
BallYVal(i).Top = BallYVal(i - 1).Top + BallYVal(i - 1).Height
Load Proximity(i)
Proximity(i).Visible = True
Proximity(i).Top = Proximity(i - 1).Top + Proximity(i - 1).Height
Proximity(i).Text = 0
Load Velocity(i)
Velocity(i).Visible = True
Velocity(i).Top = Velocity(i - 1).Top + Velocity(i - 1).Height
Velocity(i).Text = 0
Load Acceleration(i)
Acceleration(i).Visible = True
Acceleration(i).Top = Acceleration(i - 1).Top + Acceleration(i - 1).Height
Acceleration(i).Text = 0
Load Angle(i)
Angle(i).Visible = True
Angle(i).Top = Angle(i - 1).Top + Angle(i - 1).Height
Angle(i).Text = 0
Next i
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
For i = 1 To BallNum
If _
X > Ball(i).Left And _
X < Ball(i).Left + Ball(i).Width And _
Y > Ball(i).Top And _
Y < Ball(i).Top + Ball(i).Height Then
If _
Button = 1 Then
x1 = X - Ball(i).Left
y1 = Y - Ball(i).Top
Drag = True
GrabbedBall = i
Ball(i).BorderColor = &HFF&
End If
End If
Next i
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If _
Drag = True Then
For _
i = 1 To BallNum
Proximity(i).Text = Sqr(((Ball(GrabbedBall).Left - Ball(i).Left) ^ 2) + (Ball(GrabbedBall).Top - Ball(i).Top) ^ 2)
If _
0.5 * Ball(GrabbedBall).Width + 0.5 * Ball(i).Width > _
Sqr(((Ball(GrabbedBall).Left - Ball(i).Left) ^ 2) + (Ball(GrabbedBall).Top - Ball(i).Top) ^ 2) Then
Ball(GrabbedBall).Top = Y - y1
Ball(GrabbedBall).Left = X - x1
BallXVal(GrabbedBall).Text = Ball(GrabbedBall).Left + 0.5 * Ball(GrabbedBall).Width
BallYVal(GrabbedBall).Text = Ball(GrabbedBall).Top + 0.5 * Ball(GrabbedBall).Height
Command1.Caption = "hit"
VHitBall(i) = VGrabbedBall(GrabbedBall)
AHitBall(i) = AGrabbedBall(GrabbedBall)
AngleHitBall(i) = AngleGrabbedBall(GrabbedBall)
End If
Next i
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Drag = False
Ball(GrabbedBall).BorderColor = &H0&
X = 0
Y = 0
x1 = 0
y1 = 0
End Sub
Private Sub Timer1_Timer()
If Drag = True Then
If Ball(GrabbedBall).Left <> OldX Then
AngleGrabbedBall(GrabbedBall) = Atn((Ball(GrabbedBall).Top - OldY) / (Ball(GrabbedBall).Left - OldX))
End If
Angle(GrabbedBall).Text = AngleGrabbedBall(GrabbedBall)
VGrabbedBall(GrabbedBall) = Sqr((Ball(GrabbedBall).Left - OldX) ^ 2 + (Ball(GrabbedBall).Top - OldY) ^ 2 / Timer1.Interval)
Velocity(GrabbedBall).Text = VGrabbedBall(GrabbedBall)
If OldX > Ball(GrabbedBall).Left Then
BallDirx(GrabbedBall) = -1
Else: BallDirx(GrabbedBall) = 1
End If
OldX = Ball(GrabbedBall).Left
OldY = Ball(GrabbedBall).Top
AGrabbedBall(GrabbedBall) = (VGrabbedBall(GrabbedBall) - OldVelocity) / Timer1.Interval
Acceleration(GrabbedBall).Text = AGrabbedBall(GrabbedBall)
OldVelocity = VGrabbedBall(GrabbedBall)
End If
For i = 1 To BallNum
Ball(i).Left = Ball(i).Left + BallDirx(i) * Cos(AngleGrabbedBall(i)) * VGrabbedBall(i)
Ball(i).Top = Ball(i).Top + BallDirx(i) * Sin(AngleGrabbedBall(i)) * VGrabbedBall(i)
If VGrabbedBall(i) < 10 Then
VGrabbedBall(i) = 0
Else
VGrabbedBall(i) = 0.9 * VGrabbedBall(i)
End If
If Ball(i) <> Ball(GrabbedBall) Then
Ball(i).Left = Ball(i).Left + BallDirx(i) * Cos(AngleHitBall(i)) * VHitBall(i)
Ball(i).Top = Ball(i).Top + BallDirx(i) * Sin(AngleHitBall(i)) * VHitBall(i)
VHitBall(i) = 0.9 * VHitBall(i)
End If
Next i
End Sub
|
|
|
|
|
Hi,
I haven't studied your code in any detail, but I wonder how you want to get by
without using real numbers; after all trig functions such as sin() and atn()
work with reals, often limited to the range [-1,+1] so how would you want integers
to cope with that?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
That was precisely my problem... I can't believe it was so simple.
Thanks,
-Chris Mikaitis
|
|
|
|
|
I'm really new to VB.net development and I've gotten my application to work pretty well on my development machine. Here is where is gets weird: I use the Publish menu option to create a ClickOnce installation on a USB key. I plug the key into my first non-development computer and run the setup.exe; everything works smoothly. I can run my application from the start menu. What I need to find is the location of where all the installed files are located. I have to make a change to the .config file where my db connection string is defined and I have to make sure that all of my Crystal Reports are stored in the right directories.
When I use the find files feature in Windows Explorer, I can't find my application installed on the computer anywhere !! I can find the reference to the shortcut that launches the report but I can't tell where the shortcut is pointing.
Where is my application ?
Thanks.
|
|
|
|
|
Hey David, I believe the files go in the "application cache." The parent directory may be marked as hidden and that's why you aren't finding them. I don't have an example of a location because I quit using ClickOnce sometime back but at the bottom of this page[^] there is a screenshot of a MsgBox() that shows the installed location. I'd figure your app is in a nearby folder.
|
|
|
|
|
Am new to VB, and i really want to get my hands on programming in VB is ant one intrested in helping me out in term of e-books cos my project is base on VB
|
|
|
|
|
Hi,
welcome to this site.
I hope you mean VB.NET, and not VB; VB is an ancient language by todays standards.
There are plenty of people here that are willing to help you with VB.NET for sure.
I'm more of a C# guy.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hello
I am using vb.net 2003 so is it possbile to create masked text box like vb.net 2005
and if yes then any clue
any help
waiting for your rep.
have a nice time
|
|
|
|
|
Hi,
of course you can create your own control that behaves like a MaskedTextBox in .NET 2;
hust derive your class from TextBox and add the appropriate methods and properties.
You can use the .NET 2.0 documentation to get your inspiration.
You could even download the ssCLI (shared source, Google it) and see how Microsoft did it.
But you should be able to do it yourself from scratch too.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
hi all,
i want to create a report in crystal reports in the following format.
Liabilities Assets
----------- ------
Capital Account 15100.00 Fixed Assts 5000.00
Sundry Creditors 2000.00 Sundry debtors 3000.00
i have created a report but it gives me results in different style. like
Liabilities Assets
=========== =======
0.00 Fixed Assets 5000.00
0.00 Sundry debtors 5000.00
Capital Account 15100.00 0.00
Sundry Creditors 2000.00 0.00
but i want it in above style.
any help would be appreciated.
thanks.
rmshah
Developer
|
|
|
|
|
You could probably create your report with two sub-reports - one for the Liabilities and the other for the Assets.
HTH.
|
|
|
|
|
hi ChandraRam,
Thanks a lot for your kind support. i have done, but i am not handle the account which have balance= 0
i have written a formula Like:
if fieldDr>0 then
variable=fieldDr;
but still it shows account with zero balance in cr report.
Thanks again,
rmshah
Developer
|
|
|
|
|
I remember that there were some properties like SuppressWhenZero and SuppressBlankLines (don't know which version had these) - maybe you could try those?
|
|
|
|
|
Hi all,
i make one software in vb.net and now i give it to my clients, but i want that they use my software only for 30 days - means make it trial version and for full version they have to buy from me.
Can any one help me in this matter ??
Thanks in advance..
Rana k.j.
|
|
|
|
|
hi,
you can Create Registry key for your application. within your registry key, you can set parameter for trial and registered version.
For more detail, visit Working with Windows Registry using VB.NET
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
modified on Saturday, March 29, 2008 7:15 AM
|
|
|
|
|
Hello Rupesh Kumar,
Thanks for replying.
I read the article that u send me and thanks for that, but as u said that within registry key u have to set parameter for trial and registerd version. So Can u explain me in detail that where i have to put the code of key creation and how it is checked for trial and registerd version???
u can send me sample code at my another email id: krishrana17@gmail.com
Thanks
Rana krishnraj
|
|
|
|
|
hi,
you put code for key creation at load event of application startup form. Follow step
1. first check whether registry key is created or not ?
2. if not, then create registry key and set some parameter like FirstUsedDate, lastUsedDate, VersionType etc.
3. if registry key is already created, then check firstUsedDate and add trial day to this date. now after adding days if validation period is over or current date is lower than the FirstUsedDate, then change version type to "trialexpired"
use above logic for trial .You can use some other logic
one more thing, by mistake i can copy wrong link in previous post but now this is correct. so read this link.
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
You are looking in the right direction, but what is stopping people from modifying the key manually using regedit and using the unrestricted version?
I reccommend that when you sell the full version, you sell it with a password (preferably one the client chooses). This can be stored on your database, and on the client's computer
|
|
|
|
|
hi,
generally i stored the value in encrypted form . so user can not modify the value. if user will try to modify these value, then application does not works (Because decrypt method does not produce proper value)
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Oh, right.
It's just that the way it was written made it look otherwise
|
|
|
|
|
Hello Rupesh Kumar,
Thanks again for replying.
as u said in the previous post, u send some link but i can't find any link in yr post.
so by mistake r u forgot to put the link here ??
Rana k.j.
|
|
|
|
|
|
Hello Rupesh Kumar,
I had done my thing using an example that u had sent me in prev. post and thanks again for your help.
and one more thing to ask to u that as u said to Farah sahad that if u encrypt yr key then its difficult to user to change that value. but here my question is that if i use SHA512 algo. to encrypt my value then how can i decrypt it? I mean is there any algo. for decrypt my value ?????
regards,
krishnraj
Rana k.j.
|
|
|
|
|
Don't use SHA512. SHA512 is a ONE WAY HASH algo, meaning that you can't "decrypt" it. You have to use an ENCRYPTION algo such as Triple DES or AES.
|
|
|
|
|