Is there any thing different about using GetWindowLong with a ComboBox as compared with any other control? More specifically, does the ComboBox have a GWL_USERDATA dword like all of the other controls?

The line of code I am using is:



invoke GetWindowLong,eax,GWL_USERDATA
Posted on 2003-07-12 22:10:24 by msmith
It appears that the ComboBox uses GWL_USERDAT for itself.

I was using this word for all of my controls to hold a pointer to a desciptor block for each control to hold position, colors, etc..

The scheme works well for all but combobox.
Posted on 2003-07-13 17:11:22 by msmith
How about superclassing? As long as combo boxes don't use the memory reserved with the cbWndExtra parameter in WNDCLASS structure...
Posted on 2003-07-17 13:10:54 by QvasiModo
I already changed the code before you made your post.

I put the structures into a linked list which works fine.

I may try your idea later since it requires less code and would be faster than the linked list. (The linked list is fast enough that you can't tell the difference)
Posted on 2003-07-20 23:48:59 by msmith
Hi msmith,

I have tried extensive tests with ComboBoxes and there seems to be no problem with using GWL_USERDATA, it must be that something is overwriting your data. I have used the following test :
invoke GetDlgItem,hDlg,1005

mov hcbobox,eax

invoke SetWindowLong,hcbobox,GWL_USERDATA,100

invoke SendMessage,hcbobox,CB_ADDSTRING,0,OFFSET szTest
invoke SendMessage,hcbobox,CB_ADDSTRING,0,OFFSET szTest
invoke SendMessage,hcbobox,CB_ADDSTRING,0,OFFSET szTest
invoke SendMessage,hcbobox,CB_ADDSTRING,0,OFFSET szTest

invoke GetWindowLong,hcbobox,GWL_USERDATA >>> result = 100

invoke SendMessage,hcbobox,CB_DELETESTRING,0,0
invoke SendMessage,hcbobox,CB_DELETESTRING,0,0
invoke SendMessage,hcbobox,CB_DELETESTRING,0,0
invoke SendMessage,hcbobox,CB_DELETESTRING,0,0

invoke GetWindowLong,hcbobox,GWL_USERDATA >>> result = 100

Tried selecting strings in various ways and everything worked. I would check your code as it does not appear to be the properties of the combo box. Tested both DropDownList and DropDownCombo types
Posted on 2003-07-21 01:09:20 by donkey
Donkey,

The code in your tests would have worked fine on mine also.

The problem occurs when reacting to a ctlcolor event.
Posted on 2003-07-21 08:55:31 by msmith
Again, I was using the following WM_CTLCOLOR messages in the message loop and everything was colored OK.

.ELSEIF eax==WM_CTLCOLORSTATIC
mov eax,hBrushEnabled
ret

.ELSEIF eax==WM_CTLCOLOREDIT
mov eax,hBrushEnabled
ret

.ELSEIF eax==WM_CTLCOLORLISTBOX
mov eax,hBrushEnabled
ret

There was no change in the return value.
Posted on 2003-07-21 12:30:45 by donkey