Announcement

Collapse
No announcement yet.

DDT Question(s)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DDT Question(s)

    Hi All,

    A couple of problems I'm having with a VERY simple DDT app. It consists of a single Edit control and this is what I'm trying to acheive.

    Use the desktop back and fore colors in the edit control. I can set the colours manually Ok using SetBkColor etc, but am unsure how I translate %COLOR_DESKTOP to a color these API's understand?

    There is only one control on the Dialog, but I can TAB off it... to where does focus go?

    Lastly, when the Dialog/Edit control is first shown, it has all the text preselected. I've tried to turn this of with an EM_SETSEL wparam = -1, tried in initidialog, and WM_SETFOCUS, neither changed this autoselect behaviour. Can it be done?

    Any suggestions most gratefully accepted


    ------------------
    ---
    Regards, Tim, http://www.aquatee.com

  • #2
    GetSysColor(%COLOR_DESKTOP) does the trick. Following works for me,
    to reset selection and put caret at the end pos. As for TAB in single
    line edit, it selecyts the text. To trap VK_TAB, one probably need to
    subclass the edit control and catch it in WM_KEYDOWN (I think).

    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Test of colors and selection removal in an edit control
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    %ID_TEXT = 20
    DECLARE CALLBACK FUNCTION DlgProc() AS LONG
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Create dialog and controls, etc
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION PBMAIN () AS LONG
      LOCAL hDlg AS LONG
      DIALOG NEW 0, "Edit test ",,, 180, 38, %WS_SYSMENU, 0 TO hDlg
      CONTROL ADD TEXTBOX, hDlg, %ID_TEXT, "Press tab to select text", _
                           4, 4, 168, 14, %WS_CHILD, %WS_EX_CLIENTEDGE CALL DlgProc
      DIALOG SHOW MODAL hDlg CALL DlgProc
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Main callback
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION DlgProc() AS LONG
      STATIC hBrush AS LONG
     
      SELECT CASE CBMSG
         CASE %WM_INITDIALOG
            hBrush = CreateSolidBrush(GetSysColor(%COLOR_DESKTOP))
            CONTROL SET FOCUS CBHNDL, %ID_TEXT                      '<- first set focus to edit
            CONTROL SEND CBHNDL, %ID_TEXT, %EM_SETSEL, 65000, 65000 '<- then set caret to end pos, whatever..
             
         CASE %WM_CTLCOLOREDIT
            SetBkColor CBWPARAM, GetSysColor(%COLOR_DESKTOP)
            SetTextColor CBWPARAM, GetSysColor(%COLOR_HIGHLIGHTTEXT) '<- not sure this is correct color..
            FUNCTION = hBrush
     
         CASE %WM_DESTROY
            DeleteObject hBrush
      END SELECT
     
    END FUNCTION

    ------------------


    [This message has been edited by Borje Hagsten (edited March 27, 2001).]

    Comment


    • #3
      Thanks Borje!

      GetSysColor(%COLOR_DESKTOP) does the trick. Following works for me,
      to reset selection and put caret at the end pos. As for TAB in single
      line edit, it selecyts the text. To trap VK_TAB, one probably need to
      subclass the edit control and catch it in WM_KEYDOWN (I think).
      Thanks, I'll look into that.

      Code:
      SetTextColor CBWPARAM, GetSysColor(%COLOR_HIGHLIGHTTEXT) '<- not sure this is correct color..
      [/B]
      No, it seems *no* color is the "right" one. I'm guessing that the OS doesn't have a set color for desktop foreground, but must base it on current desktop color. I've only seen white or black icon text in my testing, and those have not matched up to any of the listed system colors in some cases.

      Does anyone know how the desktop icon foreground text color is determined? I can't find any mention of it in the win32 docs - maybe I'm looking for the wrong thing though... (still, but less so now)


      ------------------
      ---
      Regards, Tim, http://www.aquatee.com

      Comment


      • #4
        Hi Borje,

        To trap VK_TAB, one probably need to
        subclass the edit control and catch it in WM_KEYDOWN (I think).
        That did the trick for that issue, thanks!

        Now there is only the desktop icon text color to work out and I can get some sleep



        ------------------
        Regards, Tim, http://www.aquatee.com

        Comment

        Working...
        X