Problem with SendMessage API call
BlitzPlus Forums/BlitzPlus Programming/Problem with SendMessage API call
| ||
Can somebody please tell me why the following code fails? If it is relevant, my O.S. is Windows ME. width=400 ; Window client width height=300 ; Window client height gap=20 ; Gap between gadgets hwin=CreateWindow("Testing",100,50,width,height,0,33) lbox=CreateListBox(gap,gap,width-gap*2,height-gap*2,hwin) If lbox=0 Then Notify "Didn't create listbox": End AddGadgetItem lbox,"Line 1" AddGadgetItem lbox,"Line 2" items=SendMessage(lbox, $18B, 0, 0) ; LB_GETCOUNT ; Next line should add "2" to the listbox, but adds "0" AddGadgetItem lbox,Str$(items) Repeat Select WaitEvent() Case $803: Exit ; Window close End Select Forever It creates a listbox, populates it with 2 lines of text and then uses the SendMessage() API call to count the number of lines (2) and then display the count as a further line in the listbox. But 0 is displayed, not 2 as I expect. Why? My userlibs folder contains a single .decls file containing the following lines (amongst other lines): .lib "user32" SendMessage%(hwnd%, wMsg%, wParam%, lParam%):"SendMessageA" Also, a further question: How do I create a listbox with style LBS_MULTICOLUMN so that I can send it the message LB_SETCOLUMNWIDTH ? Anthony Jordan |
| ||
Mmm .. I tried it with QueryObject() and it still fails:Const LB_GETCOUNT=$18b width=400 ; Window client width height=300 ; Window client height gap=20 ; Gap between gadgets hwin=CreateWindow("Testing",100,50,width,height,0,33) lbox=CreateListBox(gap,gap,width-gap*2,height-gap*2,hwin) For d=1 To 5 AddGadgetItem lbox,"Line "+d Next i=SendMessage(QueryObject(lbox,1),LB_GETCOUNT,0,0) AddGadgetItem lbox,"Count = "+Str$(i) WaitEvent End For more listbox information have you looked at MSDN Library - ListBoxes ? |
| ||
Hello Syntax, (Regarding the question at the very end of my earlier post) Following your suggestion I have now looked at MSDN Library - Listboxes. This does not help me. I need to know the styles specifically supported by the BlitzPlus CreateListBox command. The BlitzPlus documentation does not list any style parameter, but pressing F1 to get the quick help on CreateListBox in the status bar shows that styles ARE supported. I need to know the style number for LBS_MULTICOLUMN, assuming BlitzPlus accepts this style. Anthony |
| ||
I've no idea want the styles do. Normally the online docs are the most up to date reference. No mention on there though. CreateListBox As for listboxes with columns, I don't think it B+ supports them yet. See this link in the feature requests. |