Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Subclassing crashing VB, as always. | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 1518/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-06-04 08:14 AM Link | Quote
I swear, Windoze's API was programmed by a team of retarded monkeys on crack. No, wait, that's an insult to crack-addicted retarded monkeys.

After subclassing the window procedure to trap 4th and 5th mouse buttons because VB doesn't for some dumb reason, I have this code:

If iMsg = &H200& Then
Form1.Form_MouseMove wParam, -1, lParam And 65535, lParam \ 65536
Else
Debug.Print Hex$(hWnd), Hex$(iMsg), Hex$(wParam), Hex$(lParam)
WindowProc = CallWindowProc(ProcOld, hWnd, iMsg, wParam, lParam)
End If


The code fires the MouseMove event when it gets a mouse message, otherwise it lets Windoze handle it. As soon as it tries to execute the MouseMove event, VB crashes without any sort of error message. Why is it doing this?
neotransotaku

Baby Mario
戻れたら、
誰も気が付く
Level: 87

Posts: 1328/4016
EXP: 6220548
For next: 172226

Since: 03-15-04
From: Outside of Time/Space

Since last post: 11 hours
Last activity: 1 hour
Posted on 09-06-04 11:51 AM Link | Quote
is there a better way to monitor how VB travels through that if expression? like...what VB statement in that if expression causes VB to crash?
dan

Snap Dragon
Level: 43

Posts: 165/782
EXP: 534516
For next: 30530

Since: 03-15-04

Since last post: 20 hours
Last activity: 14 hours
Posted on 09-07-04 12:43 AM Link | Quote
Google it. There's a million half decent tutorials on the subject Ok, maybe a million is an exaggeration.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 1524/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-07-04 01:34 AM Link | Quote
Originally posted by neotransotaku
is there a better way to monitor how VB travels through that if expression? like...what VB statement in that if expression causes VB to crash?

Yes, I uncommented them one at a time, it's when it calls MouseMove that causes the crash.
Squash Monster

New Age Retro Hippie
Togateiru Fohku Kohgeki!!
GRUNGE no HAMSTER otona bite
Peace love and turnpike!

Level: 40

Posts: 384/677
EXP: 430507
For next: 10802

Since: 03-15-04
From: Maryland (of the Country Between Canada and Mexico)

Since last post: 5 hours
Last activity: 5 hours
Posted on 09-08-04 12:28 AM Link | Quote
Why would you uncomment them one at a time instead of using the step command (F8)?

And nope, I have no clue what's wrong with it.
neotransotaku

Baby Mario
戻れたら、
誰も気が付く
Level: 87

Posts: 1329/4016
EXP: 6220548
For next: 172226

Since: 03-15-04
From: Outside of Time/Space

Since last post: 11 hours
Last activity: 1 hour
Posted on 09-08-04 03:07 AM Link | Quote
have you taken a look at what MouseMove accepts and doesn't accept? as a programmer, you have to assume that when you use API, the API is correct. Not unless you are 100% sure what you are giving it is valid. If that is the case, then this is where bug reports are welcomed by people who program the API.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 1534/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-08-04 06:53 AM Link | Quote
If it were an invalid parameter, it would show an error message wouldn't it? Trying to use F8 didn't work; VB wouldn't respond to keypresses when it broke.
neotransotaku

Baby Mario
戻れたら、
誰も気が付く
Level: 87

Posts: 1337/4016
EXP: 6220548
For next: 172226

Since: 03-15-04
From: Outside of Time/Space

Since last post: 11 hours
Last activity: 1 hour
Posted on 09-08-04 09:56 AM Link | Quote
you are working with the WindowsAPI and that is written in what language? C? with C, if it looks like data, it will use it. I'm in a project that uses a C++ DLL from a VB DLL. I can define the available C++ functions anyway I want in C++ and it will run. Whether it runs correctly is a different story.

In short, when it comes to running C stuff from other language, if it is in memory and in a valid area, anything goes.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 1541/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-09-04 07:48 AM Link | Quote
The point of your 1337 post being...?
neotransotaku

Baby Mario
戻れたら、
誰も気が付く
Level: 87

Posts: 1339/4016
EXP: 6220548
For next: 172226

Since: 03-15-04
From: Outside of Time/Space

Since last post: 11 hours
Last activity: 1 hour
Posted on 09-10-04 09:12 AM Link | Quote
the API isn't doing error checking and VB can't do much in terms of error checking for C code because the best it can do is to make sure your parameters pass the type checking for the function call. Whether the values are valid values to use in the API call is a different story.

So, why don't you call MouseMove with values you know should work in that if expression. If that works, then you know the values you are passing it that are bad, not the API function itself.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 1543/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-11-04 10:58 PM Link | Quote
Yeah, I tried that. I personally think it's a threading issue, or some such thing, but then I'd have to wonder how subclassing could even work without crashing.
Kyoufu Kawa
I'm not bad. I'm just drawn that way.
Level: 70

Posts: 677/2481
EXP: 3008456
For next: 7355

Since: 03-19-04
From: Catgirl Central

Since last post: 14 hours
Last activity: 13 hours
Posted on 09-12-04 02:53 PM Link | Quote
I prefer to use VBAccellerator's Subclassing and Timer Assistant for this shit. Subclassing without the crashes.

I use it in RS-Ball to prevent horizontal resizing.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 1555/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-17-04 03:14 AM Link | Quote
Hmm... I think that (while testing some multithreading experiments) I've discovered one of the most important rules of multithreading in VB: No two threads can reference the same function at any time. (Subclassing counts as multithreading, because a different thread calls the function.) For example, if your new thread calls a function, and at any time after that the original thread calls it, the program will crash. I'm not sure why this is (and it certainly limits functionality), but it seems to hold true throughout my experiments. Declare a function in a module somewhere and create a new thread. Have the new thread call this function, it should work fine. Now have the original thread call this function later, VB crashes. This doesn't seem to apply to variables (I managed to make one thread change the BG colour while the other changed the title, both in endless loops). The biggest problem I've found is that VB seems to crash whenever the second thread is terminated. (That, and the farking Data View window just popped up out of nowhere and appears every time I start VB now. )

BTW, if anyone knows how to play tones out of the sound card (given a specific frequency and length, being able to play multiple tones at once, and not pausing the program until it's done), I need to know.
Cellar Dweller

Flurry
!!!
Level: 27

Posts: 140/269
EXP: 107817
For next: 8342

Since: 03-15-04
From: Arkansas

Since last post: 16 days
Last activity: 34 min.
Posted on 09-17-04 10:54 AM Link | Quote
Originally posted by HyperHacker
BTW, if anyone knows how to play tones out of the sound card (given a specific frequency and length, being able to play multiple tones at once, and not pausing the program until it's done), I need to know.


I think that the Windows sound API offers some way to play a sound data buffer in the background and call back to the application when the sound data is about to run out. I could be wrong about this. I have not even looked at the Windows sound API in many years.

If that is the case, then I think that the best thing to do is create two or three sound buffers and synthesize the waveforms to a buffer that is not currently being played. Store the phase of the waveforms in the list of active tones so that there will be no click when a buffer starts playing.

Be sure not to write sound synthesis code in a language that does array bounds checking, automatic array resizing, or dynamic typing. Also, avoid floating point math if possible. Heed these warnings lest your program lag behind the sound card or excessively consume CPU cycles.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 1563/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 09-19-04 05:03 AM Link | Quote
I've never really seen anything like that. I think DirectX has a function you could do that with, but I dunno how to use it and Google is no help. I managed to make it play a WAV, and there's a frequency adjust function (raise or lower the pitch), so I tried making a WAV of a constant 8000hz tone, since the default frequency was 8000 it makes the math pretty damn easy. But when I did that the default frequency changed to like 22000. Plus, I'd prefer not using a WAV at all.
As for lag or excessive CPU usage, it's not a big deal, I'm only trying to play a tone for like half a second. (Making a phone dialer program. )
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - Subclassing crashing VB, as always. | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.009 seconds.