* This is a runnable program, * written by >L< to show * how to drop down a combobox * programmatically on demand * lots of * meaningless setup code here -- * all the important code is in * the myCombo class definition * below, and the only really * important line is in the * DropMeDown method, marked * with the symbols *&* yyy = CREATEOBJECT("form") yyy.ADDOBJECT("t","textbox") yyy.T.VISIBLE = .T. yyy.ADDOBJECT("x","myCombo") yyy.ADDOBJECT("l","label") WITH yyy.x .VISIBLE = .T. .LEFT = 30 .TOP = 30 .ADDITEM("cherries") .ADDITEM("peaches") ENDWITH WITH yyy.l .VISIBLE = .T. .TOP = .Parent.Height - (.Height*3) .WordWrap = .T. .Caption = "For this demo, you can press F10"+CHR(13)+; "at any time to make the combo pop down."+CHR(13)+; "Ordinarily you'd do it programmatically." .Height = .Height * 3 .Width = .Parent.Width ENDWITH PUSH KEY CLEAR ON KEY LABEL f10 yyy.x.DropMeDown() yyy.SHOW(1) POP KEY RETURN DEFINE CLASS myCombo AS COMBOBOX oForm = NULL * style = 0 && doesn't matter PROC INIT THIS.SetFormRef() ENDPROC PROC SetFormRef * go up through containers LOCAL oObj oObj = THIS DO WHILE ISNULL(THIS.oForm) IF TYPE("oObj.Parent") = "O" oObj = oObj.PARENT IF UPPER(oObj.BASECLASS) == "FORM" THIS.oForm = oObj ENDIF ELSE EXIT ENDIF ENDDO ENDPROC PROC DropMeDown IF NOT ISNULL(THIS.oForm) ASSERT THIS.oForm.SCALEMODE = 3 * this next section not necessary if you aren't going * to save and restore mouse pos: LOCAL liRow, liCol, lcWindowClause lcWindowClause = WONTOP() IF UPPER(lcWindowClause) == UPPER(THIS.oForm.NAME) liRow = MROW(lcWindowClause) liCol = MCOL(lcWindowClause) lcWindowClause = " WINDOW "+lcWindowClause ENDIF * end of unnecessary stuff *&* * here's the only really meaningful line, * and THIS.oForm could be THISFORM: MOUSE CLICK AT OBJTOCLIENT(THIS,1) + 2, ; OBJTOCLIENT(THIS,2)+OBJTOCLIENT(THIS,3) - 2 ; WINDOW (THIS.oForm.NAME) ; PIXELS * start of more unnecessary stuff IF NOT EMPTY(liRow) MOUSE AT liRow, liCol &lcWindowClause ENDIF * end of unnecessary stuff ENDIF ENDPROC ENDDEFINE