[comp.windows.ms.programmer] Good hash function on window handle?

al@well.sf.ca.us (Alfred Fontes) (05/07/91)

Has anybody come up with an exceptionally good hash function for a table
keyed on the handle returned by CreateWindow()?

Al Fontes
al@well.sf.ca.us
uunet!apple!well!al

kend@data.UUCP (Ken Dickey) (05/09/91)

al@well.sf.ca.us (Alfred Fontes) writes:

>Has anybody come up with an exceptionally good hash function for a table
>keyed on the handle returned by CreateWindow()?

I suggest that instead of putting the handle in a table, you put the
table in the handle.

[i.e. use the cbWndExtra bytes and {Set,Get}WindowLong() to
save/restore an index or data handle.  Then use the window handle
itself to get to your info.]


-Ken Dickey				kend@data.uucp

cadsi@ccad.uiowa.edu (CADSI) (05/09/91)

From article <488@data.UUCP>, by kend@data.UUCP (Ken Dickey):
> al@well.sf.ca.us (Alfred Fontes) writes:
> 
>>Has anybody come up with an exceptionally good hash function for a table
>>keyed on the handle returned by CreateWindow()?
> 
> I suggest that instead of putting the handle in a table, you put the
> table in the handle.
>

I have a class this does this if you want it.
If you wanna store HANDLES in the table (which is itself a HANDLE) this
table will handle that too.  All you have to supply the map and compare
functions as a sort of sub-class.
No real big deal, Just lock the handle the HashTable class
gives you for mapping and lock both during the compare.

|----------------------------------------------------------------------------|
|Tom Hite					|  The views expressed by me |
|Manager, Product development			|  are mine, not necessarily |
|CADSI (Computer Aided Design Software Inc.	|  the views of CADSI.       |
|----------------------------------------------------------------------------|

cadsi@ccad.uiowa.edu (CADSI) (05/09/91)

From article <1991May9.061744.6829@ccad.uiowa.edu>, by cadsi@ccad.uiowa.edu (CADSI):
> From article <488@data.UUCP>, by kend@data.UUCP (Ken Dickey):
>> al@well.sf.ca.us (Alfred Fontes) writes:
>> 
>>>Has anybody come up with an exceptionally good hash function for a table
>>>keyed on the handle returned by CreateWindow()?
>> 
>> I suggest that instead of putting the handle in a table, you put the
>> table in the handle.
>>
> 
> I have a class this does this if you want it.
> If you wanna store HANDLES in the table (which is itself a HANDLE) this
> table will handle that too.  All you have to supply the map and compare
> functions as a sort of sub-class.
> No real big deal, Just lock the handle the HashTable class
> gives you for mapping and lock both during the compare.

I think I apologize to Mr. Bandwidth.  I misread that last post I responded
to.  I have not come up with a good map function based on the handle from
CreateWindow.  I just have a hashtable for the taking.  No more bandwidth....

|----------------------------------------------------------------------------|
|Tom Hite					|  The views expressed by me |
|Manager, Product development			|  are mine, not necessarily |
|CADSI (Computer Aided Design Software Inc.	|  the views of CADSI.       |
|----------------------------------------------------------------------------|

al@well.sf.ca.us (Alfred Fontes) (05/11/91)

kend@data.UUCP (Ken Dickey) writes:

>[i.e. use the cbWndExtra bytes and {Set,Get}WindowLong() to
>save/restore an index or data handle.  Then use the window handle
>itself to get to your info.]

This is a good idea, but it won't work for pre-registered classes,
such as controls and the MDI client window.

davidds@microsoft.UUCP (David D'SOUZA) (05/13/91)

You don't need a hash function.  If you registered the Window class, you
simply need to allocate extra window words and use that to store your 
additional data. Check out the SetWindowWord and GetWindowWord inaddition
to the CLASS struct.

If you didn't register the Window class, use the Window properties. Check
out the SetProp, GetProp, and RemoveProp functions.

-Dave




In article <24607@well.sf.ca.us> al@well.sf.ca.us (Alfred Fontes) writes:
>Has anybody come up with an exceptionally good hash function for a table
>keyed on the handle returned by CreateWindow()?
>
>Al Fontes
>al@well.sf.ca.us
>uunet!apple!well!al