• Welcome to Valhalla Legends Archive.
 

Function pointers

Started by brew, August 03, 2007, 12:00 AM

Previous topic - Next topic

brew

So uh, I feel kind of embarrased because I'm asking a question about vb6 but eh..
I want to finish up this old project of mine. I require setting a timer using SetTimer, and you know how it requires a function pointer to what it's supposed to call, right? What if I wanted to pass a certain parameter to that function as well, how would i do this? There's no easy way out really. And I can't pass it by a global variable because I'm going to have multiple timers running at once. Does anyone have any good ideas? What i'm basically trying to do is:

        .....
        lngTimer(zxcv) = SetTimer(frmMain.hWnd, 2, lngTime, AddressOf asdfg)
    End If
End Sub
'it would be very nice if i could do AddressOf asdfg(zxcv) or something on that order
'i'm a bit suprised vb6 doesn't have this kind of functionality, considering how dumbed down it is

Public Sub asdfg(sdfg As Integer)
    On Error GoTo Err
    If UBound(qwerty(sdfg).asdf) = 0 Then
        KillTimer frmMain.hWnd, 2
        Exit Sub
    End If
Err:
End Sub
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

l2k-Shadow

Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

brew

<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

UserLoser

* UserLoser thinks brew didn't catch on

brew

I did, userloser. The third parameter kind of confused me, because I had it byref (it said UINT_PTR) but apparently it didn't like having a byref parameter and never was called? No idea. But i set it to byval and it worked. hmph, go figure. It works great, by the way.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

MyndFyre

#5
Quote from: brew on August 03, 2007, 07:18 PM
I did, userloser.
Are you sure?
Quote from: brew on August 03, 2007, 07:18 PMThe third parameter kind of confused me, because I had it byref (it said UINT_PTR) but apparently it didn't like having a byref parameter and never was called? No idea. But i set it to byval and it worked. hmph, go figure. It works great, by the way.

Doesn't look like UINT_PTR is ByRef to me...

Quote
UINT_PTR -- Unsigned INT_PTR.
  This type is declared in BaseTsd.h as follows:

#if defined(_WIN64)
typedef unsigned __int64 UINT_PTR;
#else
typedef unsigned int UINT_PTR;
#endif

Looks like it's a platform-specific data type based on the size of the machine word for the platform.

Reference.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

brew

Quote from: MyndFyre[vL] on August 05, 2007, 03:46 AM
Quote from: brew on August 03, 2007, 07:18 PM
I did, userloser.
Are you sure?
Quote from: brew on August 03, 2007, 07:18 PMThe third parameter kind of confused me, because I had it byref (it said UINT_PTR) but apparently it didn't like having a byref parameter and never was called? No idea. But i set it to byval and it worked. hmph, go figure. It works great, by the way.

Doesn't look like UINT_PTR is ByRef to me...

Quote
UINT_PTR -- Unsigned INT_PTR.
  This type is declared in BaseTsd.h as follows:

#if defined(_WIN64)
typedef unsigned __int64 UINT_PTR;
#else
typedef unsigned int UINT_PTR;
#endif

Looks like it's a platform-specific data type based on the size of the machine word for the platform.

Reference.

hrm, maybe so!? see, i love that name, UINT_PTR. It makes you think of it as a pointer, but suprise! it isn't!!!! Honestly, you couldn't blame me for trying to make it ByRef. Anyone uninformed of that typedef would think the same thing, too.

Also, just to show how accurate that refrence page you posted is, here's an example of its quality code:

UINT64 Unsigned INT64.
This type is declared in BaseTsd.h as follows:


Copy Code
typedef usigned __int 64 UINT64;


usigned!? Hrm. must be another typedef or something.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

MyndFyre

Quote from: brew on August 06, 2007, 11:32 AM
hrm, maybe so!? see, i love that name, UINT_PTR. It makes you think of it as a pointer, but suprise! it isn't!!!!
Not really that surprising.  Windows typically uses notation PTYPENAME (for instance, PINT32, or PUINT32) for pointer types.  If you were familiar with the Windows Data Types reference page, you would have known that.

Quote from: brew on August 06, 2007, 11:32 AM
Honestly, you couldn't blame me for trying to make it ByRef. Anyone uninformed of that typedef would think the same thing, too.
As I stated, all of that information is available on the Windows Data Types reference page.  That makes "anyone uninformed" rather "ignorant," wouldn't you say?  The idea behind the _PTR-nomenclature names is to provide you with data types of size relative to the machine word size.

Quote from: brew on August 06, 2007, 11:32 AM
Also, just to show how accurate that refrence page you posted is, here's an example of its quality code:

usigned!? Hrm. must be another typedef or something.
So you're going to pick on the QA ability of Microsoft on its tens of thousands of pages of material and documentation, but you can't find information on whether a data type should be passed by reference?

I mean, just so everyone's clear.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

brew

Quote from: MyndFyre[vL] on August 06, 2007, 10:05 PM
Not really that surprising.  Windows typically uses notation PTYPENAME (for instance, PINT32, or PUINT32) for pointer types.  If you were familiar with the Windows Data Types reference page, you would have known that.
Oh wow, that's great that you study microsoft's datatype refrence pages. What about the people who don't?

Quote from: MyndFyre[vL] on August 06, 2007, 10:05 PM
As I stated, all of that information is available on the Windows Data Types reference page.  That makes "anyone uninformed" rather "ignorant," wouldn't you say?
Not really

Quote from: MyndFyre[vL] on August 06, 2007, 10:05 PM
The idea behind the _PTR-nomenclature names is to provide you with data types of size relative to the machine word size.
That idea is such a good idea. Much like most of microsoft's other good ideas (.NET, Windows Me, Vista, XP SP2, help and support center, VC++ 6's IDE, etc.)
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

UserLoser


Explicit

#10
Quote from: brew on August 07, 2007, 10:57 AM
Quote from: MyndFyre[vL] on August 06, 2007, 10:05 PM
Not really that surprising.  Windows typically uses notation PTYPENAME (for instance, PINT32, or PUINT32) for pointer types.  If you were familiar with the Windows Data Types reference page, you would have known that.
Oh wow, that's great that you study microsoft's datatype refrence pages. What about the people who don't?

Quote from: MyndFyre[vL] on August 06, 2007, 10:05 PM
As I stated, all of that information is available on the Windows Data Types reference page.  That makes "anyone uninformed" rather "ignorant," wouldn't you say?
Not really

Quote from: MyndFyre[vL] on August 06, 2007, 10:05 PM
The idea behind the _PTR-nomenclature names is to provide you with data types of size relative to the machine word size.
That idea is such a good idea. Much like most of microsoft's other good ideas (.NET, Windows Me, Vista, XP SP2, help and support center, VC++ 6's IDE, etc.)

Stop typing as if you're a know-it-all, then.  First, you try to correct someone who is obviously more experienced and knows what he's talking about.  Then you try to brush it off and say that it's not your fault that you don't read the datatype references page as much as he does.

Seems to me like you're trying to find any excuse possible to save face just because you overlook small, but imperative details.

Like I told you before: read, read, read, then write.
I'm awake in the infinite cold.

[13:41:45]<@Fapiko> Why is TehUser asking for wang pictures?
[13:42:03]<@TehUser> I wasn't asking for wang pictures, I was looking at them.
[13:47:40]<@TehUser> Mine's fairly short.

Warrior

Whoa, here I thought brew was finally starting to come around and make something useful of himself.

Silly me.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

brew

So what, am I supposed to study over MSDN like myndfyre over here?
I don't get what these 3 negative posts in a row are really about...
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

l2k-Shadow

they are over the fact that you try to find faults in everything else but yourself.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

MyndFyre

Quote from: brew on August 07, 2007, 07:29 PM
So what, am I supposed to study over MSDN like myndfyre over here?
Guess that's why I'm a senior developer with a degree not even a year old that's not in my field making almost double the average salary for someone my age (23), just a year out of school.

But hey, you can continue to make underhanded jabs at me and look like an idiot while you do it.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.