No announcement yet.

Dissapearing Textbox

  • Filter
  • Time
  • Show
Clear All
new posts

  • Dissapearing Textbox

    I am trying to create a textbox with read-only attributes.

    Control Add Textbox, hDlg, %MesgBox, "", 130, 15, 320, 15

    The above command displays the textbox but the textbox is not "read-only". When I append %ES_READONLY like so . . .

    Control Add TextBox, hDlg, %MesgBox, "", 130, 15, 320, 15, %ES_READONLY

    the textbox dissappears from the dialog. It is still there but not visible. Any ideas as to what I am doing wrong?
    As always, any and all help and input is very much appreciated

    Wesley Brown

    ps: Eariler today I ran across the "transparent frame" problem but found the answer by searching the forum. What I found out was that %WS_EX_TRANSPARENT must be appended to "Control Add Frame" commands so that whatever is behind the window will not show through. Are these two problems even remotely related or am I just lucky ?


  • #2
    If you look at the description of window-styles for the text-box
    you will notice that you either do not enter anything, to get the default style
    or you have to include at least %WS_CHILD or %WS_VISIBLE
    This is the default (according to documentation) for textboxes
    Textbox	%WS_TABSTOP, %WS_BORDER,	50810080
    so why not try
    Control Add TextBox, hDlg, %MesgBox, "", 130, 15, 320, 15,50810080 or  %ES_READONLY
    mailto:[email protected][email protected]</A>

    mailto:[email protected][email protected]</A>


    • #3
      Thanks for taking the time to reply Fred. When I tried your suggestion, every object on the dialog became read-only (16 buttons, 33 checkboxes) . . . . and the textbox that I'm trying to create with this command was still invisible. Any other suggestions?




      • #4
        Wesley --
        A background of READ-ONLY is gray (as default; it possible to change to any).
        Because you specified "style", DDT takes your "style" and "exstyle".
        Your exstyle = 0, means - no border.
        Try to use (for example)
        instead of alone %ES_READONLY

        E-MAIL: [email protected]


        • #5
          Thanks for your help Semen. Oh what a difference a comma makes. For example:

          Control Add TextBox, hDlg, %MesgBox, "", 130, 15, 320, 16, %ES_READONLY, %WS_EX_CLIENTEDGE (which works fine)


          Control Add TextBox, hDlg, %MesgBox, "", 130, 15, 320, 16, %ES_READONLY Or %WS_EX_CLIENTEDGE (combining style& and exstyle& with OR Vs a comma)

          I originally tried to use %WS_EX_CLIENTEDGE in my program, but for simplicity reasons I left it off of the original post. The reason it didn't work was because I used OR to separate %ES_READONLY and %WS_EX_CLIENTEDGE rather than a comma.

          With that issue solved . . . I also want to make the background white, and change the font size of the textbox. Is that simply done? Or should that be the topic of a new post?

          Thank you for your help and patience. I sincerely appreciate it.

          Wes Brown



          • #6
            I mixed two old training codes.

               #Compile Exe
               #Register None
               #Dim All
               #Include "Win32Api.Inc"
               %ID_FRAME = 100
               %ID_Label1 =  101
               %ID_Label2 =  102
               %ID_Text1 = 201
               %ID_TEXT2 = 202
               %ID_Button = 301
               Function MakeFont(Font As Asciiz, Charset As Long, Bold As Long, Italic As Long, PointSize As Long) As Long
                  Local hDC      As Long
                  Local CyPixels As Long
                  hDC = GetDC(%HWND_DESKTOP)
                  CyPixels  = GetDeviceCaps(hDC, %LOGPIXELSY)
                  ReleaseDC %HWND_DESKTOP, hDC
                  Function = CreateFont(MulDiv(PointSize, CyPixels, 72), 0, 0, 0, Bold, Italic, 0, 0, _
               End Function
               CallBack Function hDlg_CB()
                  Dim hFont1 As Long, hFont2 As Long
                  Dim BrushLtBr As Static Long, BrushWhite As Static Long, BrushBlue As Static Long
                  Select Case CbMsg
                     Case %WM_INITDIALOG
                        BrushLtBr  = CreateSolidBrush (&H80C0FF)
                        BrushWhite = CreateSolidBrush (%White)
                        BrushBlue  = CreateSolidBrush (%Blue)
                        hFont1 = MakeFont ("Times New Roman", %ANSI_CHARSET, %FW_BOLD, %False, 12)
                        Control Send CbHndl, %ID_TEXT1, %WM_SETFONT, hFont1, 0
                        hFont2 = MakeFont ("Courier New", %ANSI_CHARSET, %FW_NORMAL, %True, 16)
                        Control Send CbHndl, %ID_TEXT2, %WM_SETFONT, hFont2, 0
                     Case %WM_DESTROY
                        DeleteObject BrushLtBr
                        DeleteObject BrushWhite
                        DeleteObject BrushBlue
                        DeleteObject hFont1
                        DeleteObject hFont2
                     Case %WM_CTLCOLORDLG
                        Function = BrushLtBr
                     Case %WM_CTLCOLORSTATIC, %WM_CTLCOLOREDIT
                        Select Case GetDlgCtrlId(CbLparam)
                           Case %ID_Text1
                              SetTextColor CbWparam, %Blue
                              SetBkColor CbWparam, %White
                              Function = BrushWhite
                           Case %ID_TEXT2
                              SetTextColor CbWparam, %White
                              SetBkColor CbWparam, %Blue
                              Function = BrushBlue
                           Case %ID_Label1, %ID_FRAME
                              SetBkMode CbWparam, %TRANSPARENT
                              SetTextColor CbWparam, &H80
                              Function = BrushLtBr
                           Case %ID_Label2
                              SetTextColor CbWparam, %White
                              SetBkColor CbWparam, %Blue
                              Function = BrushBlue
                           Case %ID_BUTTON
                              SetBkColor CbWparam, &H80C0FF
                              SetTextColor CbWparam, %Blue
                              Function = BrushLtBr
                           End Select
                  End Select
               End Function
               Function PbMain
                  Local hDlg As Long
                  Dialog New %HWND_DESKTOP,"Test", , , 300, 250, %WS_CAPTION Or %WS_SYSMENU To hDlg
                  Control Add Label, hDlg, %ID_Label1, "Transparent", 10, 5, 280, 10, %SS_RIGHT
                  Control Add Frame, hDlg, %ID_FRAME, " Frame ", 5, 20, 290, 225
                  Control Add TextBox, hDlg, %ID_Text1, "", 15, 35, 270, 80, %ES_WANTRETURN Or %ES_MULTILINE Or %WS_TABSTOP, %WS_EX_CLIENTEDGE
                  Control Add TextBox, hDlg, %ID_Text2, "Multiline" + $CRLF + "Readonly" + $CRLF + "Try to change", 15, 150, 270, 80, %ES_WANTRETURN Or %ES_MULTILINE Or %ES_READONLY, %WS_EX_CLIENTEDGE
                  Control Add Option, hDlg, %ID_Button, "Testbutton", 40, 120, 80, 15
                  Dialog Show Modal hDlg, Call hDlg_CB
               End Function
            E-MAIL: [email protected]


            • #7
              Create a normal textbox and then just send:
              CONTROL DISABLE hDlg, %MESGBOX
              (it will be grayed)

              mailto[email protected][email protected]</A>


              • #8
                Thank you to everyone for your help on this problem. Thanks especially to Semen
                for the code which helped the proverbial light bulb come on as pertains to API
                calls (a first for me). Maybe one day I'll be able to return the favor by helping
                someone else out. Thanks again for the help guys.