SetFocus / ZOrder / OnInitialize

Started by fred_tomke · 2009-04-08 12:49 UTC · 4 replies · SMF topic #705

Hello,

I have a form with only three buttons. Depending on the latest button the user has clicked the next time this button should have the Initial focus. When reading the great online help there is written that I shouldn't use SetFocus method within OnInitialize event. But ZOrder method doesn't seem to have any effect? What else can I do to set the focus to a control within OnInitialize event?

Fred
Are you calling ZOrder from within OnIntialize, or from your button's OnClicked handler?
I call it within OnInitialize:


(defun c:start_of_codesnippet ()
  (defun c:signothek_sc_assistent_cmdatend_OnInitialize (/)
    (dcl_Control_SetPicture signothek_sc_assistent_cmdatend_pb_draw (if (= intTopol 1) 186 184))
    (dcl_Control_SetCaption signothek_sc_assistent_cmdatend_pb_draw (if (= intTopol 1) "Neues Flächenobjekt\r\nsofort zeichnen" "Neues Linienobjekt\r\nsofort zeichnen"))

    (cond
      ((= intDoAfter 3) (dcl_Control_ZOrder signothek_sc_assistent_cmdatend_pb_ov 1))
      ((= intDoAfter 2) (dcl_Control_ZOrder signothek_sc_assistent_cmdatend_pb_acad 1))
      (T (dcl_Control_ZOrder signothek_sc_assistent_cmdatend_pb_draw 1))
    ); cond
  ); c:signothek_sc_assistent_cmdatend_OnInitialize

  (defun c:signothek_sc_assistent_cmdatend_pb_ov ()
    (dcl_form_close signothek_sc_assistent_cmdatend 3)
  ); c:signothek_sc_assistent_cmdatend_pb_ov

  (defun c:signothek_sc_assistent_cmdatend_pb_draw ()
    (dcl_form_close signothek_sc_assistent_cmdatend 1)
  ); c:signothek_sc_assistent_cmdatend_pb_draw

  (defun c:signothek_sc_assistent_cmdatend_pb_acad ()
    (dcl_form_close signothek_sc_assistent_cmdatend 2)
  ); c:signothek_sc_assistent_cmdatend_pb_acad

  (if (not (setq intDoAfter (ReadFromRegistry "Planzeichenkatalog" "AssistLastCmdAtEnd"))) (setq intDoAfter 2))
  (setq intDoAfter (dcl_form_show signothek_sc_assistent_cmdatend))
  (WriteToRegistry "Planzeichenkatalog" "AssistLastCmdAtEnd" intDoAfter)
   
  (cond
    ((= intDoAfter 3) (SelectObjectInDatabase))
    ((= intDoAfter 1) (DrawNewObject))
  ); cond

); end of codesnippet


Fred
This problem is caused by a bug in the ZOrder method, now fixed for the next build.
Thanks, Owen, great!