Combo box problems with Win32Lib 45R.
- Posted by John Cannon <jzcndd at EARTHLINK.NET> Apr 22, 2000
- 476 views
--Message-Boundary-15470 Content-type: text/plain; charset=US-ASCII Content-description: Mail message body Greetings! I am trying to use a dropdown combo with long strings (ie, full filespecs). The always-visible part of the control cannot be more than 180 pixels wide, but I need to at least see the full filespec while it is being selected. I've seen combo boxes where the listbox (the part that drops down) is much wider than the edit control part (the part that is always visible). I have tried using CB_SETDROPPEDWIDTH to accomplish this, but I cannot get it to work. Then I discovered something strange. If you drop down the listbox by clicking the little arrow, and while the box is down, you move the main window, the listbox does not move with its parent window! What's up with that? I've included a small demo. My version of Win32Lib.ew is 45R and I have it at 45R/win32lib.ew. You may have to modify your include line. I'm running Windows 95 version B. Any comments, suggestions, work-arounds, explanations, etc. appreciated. John Cannon --Message-Boundary-15470 Content-type: text/plain; charset=US-ASCII Content-description: Text from file 'combo.exw' include 45R/win32lib.ew without warning constant CB_GETDROPPEDCONTROLRECT = 338, CB_GETDROPPEDSTATE = 343, CB_GETDROPPEDWIDTH = 351, CB_SETDROPPEDWIDTH = 352 constant win = create (Window, "Combo Test", 0, Default, Default, 400, 420, 0), spl = create (LText, "", win, 4, 4, 380, 240, 0), com = create (Combo, "", win, 4, 260, 200, 200, 0), out = create (LText, "", win, 4, 290, 380, 60, 0), okb = create (PushButton, "OK", win, 4, 360, 60, 20, 0), die = create (PushButton, "Close", win, 70, 360, 60, 20, 0) sequence list list = {"Abc", "Easy", "as", "123", "This one is supposed to be extremely long and run out of the combobox...", "more", "and more", "and another", "take that!", "ok", "enough already"} procedure loadwin () sequence s s = "Trying to show very long items in a dropdown...\n\n" & "Try dropping down the combo box below by clicking its arrow, and then, while it is " & "open, move the main window by dragging the titlebar. The dropdown does not move with the main window! " & "Very strange bug somewhere, but where?\n\n" & "Click OK to send some messages to the combobox. " & "CB_GETDROPPEDWIDTH and CB_SETDROPPEDWIDTH " & "do not work as I expect them to, but they are not returning errors " & "(CB_ERR = -1) either. " & "I had hoped to allow the dropdown to be wider than the edit portion " & "to accommodate very long strings. I've seen it done elsewhere, but it doesn't work " & "like this, though. What's wrong?\n\n" & "I need to be able to put filenames with full paths in " & "the dropdown list, but the edit control part " & "(the part that always is visible) cannot be " & "over 180 pix wide. Any ideas? " & "I am running Windows 95 version b with Win32lib version 45R.\n\n" & "Any help appreciated!" setText (spl, s) -- Stores strings in combo box. for i = 1 to length (list) do addItem (com, list[i]) end for setIndex (com, 4) end procedure onOpen[win] = routine_id ("loadwin") procedure OKButton () atom a, b, x1, x2, y1, y2, ok sequence f f = "Result from sendMessage ..CB_GETDROPPEDCONTROLRECT is\n (%d,%d) to (%d,%d)\n" & "Result from sendMessage ..CB_GETDROPPEDWIDTH is %d.\n" & "Result from sendMessage ..CB_SETDROPPEDWIDTH is %d." a = allocate (SIZEOF_RECT) ok = sendMessage (com, CB_GETDROPPEDCONTROLRECT, 0, a) x1 = fetch (a, rectLeft) y1 = fetch (a, rectTop) x2 = fetch (a, rectRight) y2 = fetch (a, rectBottom) free (a) a = sendMessage (com, CB_GETDROPPEDWIDTH, 0, 0) b = sendMessage (com, CB_SETDROPPEDWIDTH, 300, 0) setText (out, sprintf (f, {x1, x2, y1, y2, a, b})) end procedure onClick[okb] = routine_id ("OKButton") procedure DieButton() closeWindow (win) end procedure onClick[die] = routine_id ("DieButton") WinMain (win, Normal) --Message-Boundary-15470--