Announcement

Collapse
No announcement yet.

DDT: Common control not shown

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

  • DDT: Common control not shown

    Hi,

    I'm checking out DDTs (and James Fuller's excellent RC2DDT to get the .BAS source).
    Although it works fine for standard controls, no common control shows up in the dialog (the dialog does run, though: It's just empty.)
    I searched the archives, and the only tip I found was adding a %WS_VISIBLE (although the object is specified with Show in MS Dev Studio).

    => What does InitCommonControls() actually do? As it's a SUB, I can't check a return value.

    Code:
    #COMPILE EXE
    #DIM ALL
    #REGISTER NONE
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMMCTRL.INC"
    
    %IDC_RICHEDIT1 = 1000
    
    CALLBACK FUNCTION IDD_DIALOG1_CB AS LONG
      SELECT CASE CBMSG
        CASE %WM_INITDIALOG
          SendMessage CBHNDL,%WM_SETICON,1,LoadIcon(0,BYVAL %IDI_APPLICATION)
      END SELECT
    END FUNCTION
    
    FUNCTION PBMain () AS LONG
      DIM hDlg                              AS LONG
      DIM lRetVal                           AS LONG
    
      InitCommonControls
    
      DIALOG NEW 0, _
                "Dialog", _
                0, _
                0, _
                186, _
                95, _
                %DS_MODALFRAME OR %WS_POPUP OR %WS_CAPTION OR %WS_SYSMENU, _
                , TO hDlg
    
      CONTROL ADD "RICHEDIT", _
                  hDlg, _ 
                  %IDC_RICHEDIT1, _
                  "", _
                  7, _
                  64, _
                  40, _
                  14, _
                  %WS_VISIBLE OR %ES_AUTOHSCROLL OR %WS_BORDER OR %WS_TABSTOP, _
    
      DIALOG SHOW MODAL hDlg,CALL IDD_DIALOG1_CB TO lRetVal
    
    END FUNCTION
    Thx
    FF.

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

  • #2
    Frederic,

    InitCommonControls is obsolete try looking at msdn on:

    INITCOMMONCONTROLSEX

    also you need to load library via LoadLibrary

    This should work for you

    Code:
    #COMPILE EXE
    #DIM ALL
    #REGISTER NONE
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMMCTRL.INC"
    
    %IDC_RICHEDIT1 = 1000
    
    CALLBACK FUNCTION IDD_DIALOG1_CB AS LONG
      SELECT CASE CBMSG
        CASE %WM_INITDIALOG
          SendMessage CBHNDL,%WM_SETICON,1,LoadIcon(0,BYVAL %IDI_APPLICATION)
      END SELECT
    END FUNCTION
    
    FUNCTION PBMAIN () AS LONG
      DIM hDlg                              AS LONG
      DIM lRetVal                           AS LONG
      LOCAL hRichEd AS LONG
      LOCAL CC1 AS INIT_COMMON_CONTROLSEX
      
      hRichEd = LoadLibrary("RICHED32.DLL")
      CC1.dwSize=SIZEOF(CC1)
      CC1.dwICC=%ICC_WIN95_CLASSES
      INITCOMMONCONTROLSEX CC1
    
      DIALOG NEW 0, _
                "Dialog", _
                0, _
                0, _
                186, _
                95, _
                %DS_MODALFRAME OR %WS_POPUP OR %WS_CAPTION OR %WS_SYSMENU, _
                , TO hDlg
    
      CONTROL ADD "RichEdit", _
                  hDlg, _
                  %IDC_RICHEDIT1, _
                  "", _
                  0, _
                  0, _
                  186, _
                  95, _
                  %WS_CHILD OR %WS_VISIBLE OR %ES_MULTILINE OR %WS_VSCROLL OR %WS_HSCROLL OR %ES_AUTOVSCROLL OR %ES_WANTRETURN OR %ES_NOHIDESEL, %WS_EX_CLIENTEDGE
      DIALOG SHOW MODAL hDlg,CALL IDD_DIALOG1_CB TO lRetVal
    
    END FUNCTION

    ------------------
    -Greg
    -Greg
    [email protected]
    MCP,MCSA,MCSE,MCSD

    Comment


    • #3
      That did it :-)

      Two things to note for those struggling with an invisible Rich Edit child in a dialog:
      1. You must use the following code _before_ creating the dialog:
      LOCAL hRichEd AS LONG
      LOCAL CC1 AS INIT_COMMON_CONTROLSEX

      hRichEd = LoadLibrary("RICHED32.DLL")
      CC1.dwSize=SIZEOF(CC1)
      CC1.dwICC=%ICC_WIN95_CLASSES
      INITCOMMONCONTROLSEX CC1

      Create_IDD_DIALOG1 0

      2. In the CONTROL ADD "RICHEDIT" section, add the following, missing params: %WS_VISIBLE OR %WS_CHILD

      Thx a bunch
      FF.

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

      Comment

      Working...
      X