Valhalla Legends Forums Archive | Visual Basic Programming | Re: Function pointers

AuthorMessageTime
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:
[code]
        .....
        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
[/code]
August 3, 2007, 5:00 AM
l2k-Shadow
http://msdn2.microsoft.com/en-us/library/ms644907.aspx
August 3, 2007, 5:16 AM
BreW
[quote author=l2k-Shadow link=topic=16921.msg171365#msg171365 date=1186118160]
http://msdn2.microsoft.com/en-us/library/ms644907.aspx
[/quote]
Uh, thanks
August 3, 2007, 1:40 PM
UserLoser
[me=UserLoser]thinks brew didn't catch on[/me]
August 3, 2007, 10:28 PM
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.
August 4, 2007, 12:18 AM
Myndfyr
[quote author=brew link=topic=16921.msg171385#msg171385 date=1186186681]
I did, userloser.
[/quote]
Are you sure?
[quote author=brew link=topic=16921.msg171385#msg171385 date=1186186681]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.[/quote]

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:
[code]
#if defined(_WIN64)
typedef unsigned __int64 UINT_PTR;
#else
typedef unsigned int UINT_PTR;
#endif
[/code]
[/quote]
Looks like it's a platform-specific data type based on the size of the machine word for the platform.

Reference.
August 5, 2007, 8:46 AM
BreW
[quote author=MyndFyre[vL] link=topic=16921.msg171402#msg171402 date=1186303561]
[quote author=brew link=topic=16921.msg171385#msg171385 date=1186186681]
I did, userloser.
[/quote]
Are you sure?
[quote author=brew link=topic=16921.msg171385#msg171385 date=1186186681]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.[/quote]

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:
[code]
#if defined(_WIN64)
typedef unsigned __int64 UINT_PTR;
#else
typedef unsigned int UINT_PTR;
#endif
[/code]
[/quote]
Looks like it's a platform-specific data type based on the size of the machine word for the platform.

Reference.
[/quote]

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:
[code]
UINT64 Unsigned INT64.
This type is declared in BaseTsd.h as follows:


Copy Code
typedef usigned __int 64 UINT64;
[/code]

usigned!? Hrm. must be another typedef or something.
August 6, 2007, 4:32 PM
Myndfyr
[quote author=brew link=topic=16921.msg171413#msg171413 date=1186417962]
hrm, maybe so!? see, i love that name, UINT_PTR. It makes you think of it as a pointer, but suprise! it isn't!!!!
[/quote]
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 author=brew link=topic=16921.msg171413#msg171413 date=1186417962]
Honestly, you couldn't blame me for trying to make it ByRef. Anyone uninformed of that typedef would think the same thing, too.
[/quote]
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 author=brew link=topic=16921.msg171413#msg171413 date=1186417962]
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.
[/quote]
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.
August 7, 2007, 3:05 AM
BreW
[quote author=MyndFyre[vL] link=topic=16921.msg171416#msg171416 date=1186455942]
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]
Oh wow, that's great that you study microsoft's datatype refrence pages. What about the people who don't?

[quote author=MyndFyre[vL] link=topic=16921.msg171416#msg171416 date=1186455942]
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?
[/quote]
Not really

[quote author=MyndFyre[vL] link=topic=16921.msg171416#msg171416 date=1186455942]
The idea behind the _PTR-nomenclature names is to provide you with data types of size relative to the machine word size.
[/quote]
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.)
August 7, 2007, 3:57 PM
UserLoser
brew, get a new hobby
August 7, 2007, 4:16 PM
Explicit[nK]
[quote author=brew link=topic=16921.msg171427#msg171427 date=1186502258]
[quote author=MyndFyre[vL] link=topic=16921.msg171416#msg171416 date=1186455942]
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]
Oh wow, that's great that you study microsoft's datatype refrence pages. What about the people who don't?

[quote author=MyndFyre[vL] link=topic=16921.msg171416#msg171416 date=1186455942]
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?
[/quote]
Not really

[quote author=MyndFyre[vL] link=topic=16921.msg171416#msg171416 date=1186455942]
The idea behind the _PTR-nomenclature names is to provide you with data types of size relative to the machine word size.
[/quote]
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.)
[/quote]

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.
August 7, 2007, 6:57 PM
Quarantine
Whoa, here I thought brew was finally starting to come around and make something useful of himself.

Silly me.
August 7, 2007, 7:26 PM
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...
August 8, 2007, 12:29 AM
l2k-Shadow
they are over the fact that you try to find faults in everything else but yourself.
August 8, 2007, 1:35 AM
Myndfyr
[quote author=brew link=topic=16921.msg171438#msg171438 date=1186532958]
So what, am I supposed to study over MSDN like myndfyre over here?
[/quote]
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.
August 8, 2007, 2:51 AM
Quarantine
Myndy is only second to me on the awesome meters.
August 8, 2007, 5:58 AM
rabbit
And Warrior is only second to me.  I am the awesomest, too.  There is no one awesomer than me.  Well, okay.  Maybe Ron Jeremy.
August 8, 2007, 2:24 PM
UserLoser
[quote author=rabbit link=topic=16921.msg171449#msg171449 date=1186583098]
And Warrior is only second to me.  I am the awesomest, too.  There is no one awesomer than me.  Well, okay.  Maybe Ron Jeremy.
[/quote]

Oh wow, Ron Jeremy
August 8, 2007, 10:11 PM
rabbit
[quote author=UserLoser link=topic=16921.msg171460#msg171460 date=1186611119]
[quote author=rabbit link=topic=16921.msg171449#msg171449 date=1186583098]
And Warrior is only second to me.  I am the awesomest, too.  There is no one awesomer than me.  Well, okay.  Maybe Ron Jeremy.
[/quote]

Oh wow, Ron Jeremy
[/quote]That's what she said :P
August 9, 2007, 12:34 AM
Explicit[nK]
[quote author=brew link=topic=16921.msg171438#msg171438 date=1186532958]
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...
[/quote]

You're just being ignorant on your part if you don't read into the details... and by the way, my post wasn't negative.  If anything, I was being constructive.

Some advice: don't ask for help if you're going to dismiss input as irrelevant or incoherent, and actual constructiveness as a personal attack.
August 17, 2007, 8:44 PM
Newby
[quote author=UserLoser link=topic=16921.msg171429#msg171429 date=1186503365]
brew, get a new hobby
[/quote]

omg I agreed with userloser for once. brew, that means you must really suck.
August 18, 2007, 4:22 PM
warz
how long have we been telling brew these things? /sigh
August 19, 2007, 7:11 PM
rabbit
I've been saying this stuff since Day 0.  Jerks.
August 19, 2007, 7:45 PM

Search