views:

496

answers:

3

I have the following code to generate a ComboBox:

HWND h = CreateWindowEx("COMBOBOX", "Text", CBS_DROPDOWN | WS_CHILD, WS_EX_CLIENTEDGE, ParentWnd, 0, 0, 200, 24);

The combobox is created on my form no problem, however if I try resizing it with the following it won't work:

SetWindowPos(h, 0, 0, 0, NewWidth, OldHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);

Any idea why would this happen? It seems to resize the wrong portion of the combobox which is somehow transparent.

I have been trying for days with different things, it is probably something stupid but I cannot put my finger on it.

Best Regards, Alain Deschenes http://www.arianesoft.ca

A: 

Are you redrawing the whole window after resizing it?

Assaf Lavie
Yes I am. h$ = NewControlEx(0, "COMBOBOX", NULL, "TEXT", CBS_DROPDOWN | WS_CHILD, WS_EX_CLIENTEDGE, Parent.Handle, 0, 0, 200, 24); log(h$); ShowWindow(h$, SW_SHOW); SetWindowPos(h$, 0, 100, 100, 500, 24, SWP_NOZORDER | SWP_NOACTIVATE); InvalidateRect(h$, NULL, True);This code is written in PPL (my own language) and it uses CreateWindowEx() in NewControlEx().
Kornalius
Ouch formatting is not very nice in Comments. Any other way I can post in my own thread?
Kornalius
A: 

Which part of the combo box isn't resizing? The text box, or the dropdown?

The dropdown can be resized with the CB_SETDROPPEDWIDTH message.

Mark Ransom
The Edit part, not the dropdown list.
Kornalius
I would love to be able to send a screenshot, is there any way I can?
Kornalius
+2  A: 

Guys, I found it... There is something in my NewControlEx() C function that is not working properly. I have used:

h$ = CreateWindowEx(0, "COMBOBOX", "TEXT", CBS_DROPDOWN | WS_CHILD, 10, 10, 400, 24, Parent.Handle, 0, Instance%, NULL);
SetWindowPos(h$, 0, 100, 100, 400, 32, SWP_NOZORDER | SWP_NOACTIVATE);
ShowWindow(h$, SW_SHOW);
InvalidateRect(h$, NULL, True);

This works like it should. Sorry for the trouble.

It turned out to be the WM_SIZE: event handling that was not processing the original wndproc and returned right away.

Best Regards, Alain Deschenes http://www.arianesoft.ca

Kornalius