Code:
Sub AddLine (ByVal hWnd As Dword, ByVal nID As Long, SendText As Asciiz) Local ListCount As Long, pvParam As Long Control Set Focus hWnd, %IDC_SEND ' initial focus to another ctl Control Send hWnd, nID, %LB_GETCOUNT, 0, 0 To ListCount If ListCount > 500 Then Control Send hWnd, nID, %LB_DELETESTRING, 0, 0 : Decr ListCount Control Send hWnd, nID, %LB_ADDSTRING, 0, VarPtr(SendText) Control Send hWnd, nID, %LB_SETCURSEL, ListCount, 0 Control Set Focus hWnd, %IDC_EDIT1 ' data in, shift focus to edit ctl End Sub
With the mod to Sub AddLine, that is the other control - not the main window??
Even though the list box appears to have focus when a new line is added (new line is highlighted) it doesn't
- check in WM_COMMAND..
Code:
If CbCtl = %IDC_LISTBOX1 Then If CbCtlMsg = %LBN_SETFOCUS Then WinBeep 800, 50 End If End If
Leave a comment: