Announcement

Collapse
No announcement yet.

Multiline Frame error

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

  • Multiline Frame error

    When I use a multiline style on a frame, I get this mangled result.



    The multiline works, but the text background extends to the right beyond the border of the frame.

    Here's the line of code that generated it.

    Code:
        Control Add Frame, hdlg, 504, "Title" & $CrLf & "Rocks", 340,20,70,90, %bs_left Or %bs_multiline
    Changing text justification just changes where the excess background is found.

    Has anyone seen this?
    Last edited by Gary Beene; 20 Jan 2009, 05:51 PM.

  • #2
    Frame with Multi Line Text

    This will draw frame with multiline text. the CONTROL SET COLOR is used to match the text background to the dialog.


    Code:
        CONTROL ADD FRAME, hDlg, %FrameD, "Check" & CHR$(13) & "Stand", 840, 600, 100, 100, %BS_MULTILINE
        CONTROL SET COLOR  hDlg, %FrameD,  %BLACK, %CYAN
        CONTROL ADD FRAME, hDlg, %FrameD, "", 840, 600, 100, 100 '880, 607, 32, 1, ,

    Comment


    • #3
      Thanks for the response, Walter.

      But try your example with longer text, such as

      Code:
      "Checkstand" & $crlf & "StandAlone"
      It will still exhibit the problem I mention.

      Even if I match text background color to the dialog color, the problem is that I cannot bring
      a control adjacent to the frame (well, at least not without having to worry about the order
      of placement).

      I'd think that the control would not try to place colors outside the bounds of the control.
      Last edited by Gary Beene; 20 Jan 2009, 11:25 PM.

      Comment


      • #4
        Add the WS_CLIPSIBLINGS style to the control.
        When a control has the WS_CLIPSIBLINGS style, it does not paint areas of its
        client area that are overlapped by other controls. It also does not paint
        outside its boundaries when the device context it uses is that of its parent window.
        That is, when its class is created with the CS_PARENTDC style.
        Dominic Mitchell
        Phoenix Visual Designer
        http://www.phnxthunder.com

        Comment


        • #5
          Hi Dominic,

          That didn't seem to work. Here's the code:

          Code:
              Control Add Frame, hdlg, 504, "Title" & $CrLf & "Rocks", 340,20,70,90, %bs_multiline Or %ws_clipsiblings
          I get this:



          I'll look at MSDN for any other nuances of using ws_clipsiblings.

          Comment


          • #6
            This works correctly. However, the width of the frame must be greater the length of the longest word in the caption.

            Code:
                CONTROL ADD FRAME, hDlg, %FrameD, "Checkstand" & $CRLF & "Teststand", 840, 600, 100, 100, %BS_MULTILINE
                CONTROL SET COLOR  hDlg, %FrameD,  %BLACK, %CYAN
                CONTROL ADD FRAME, hDlg, %FrameD, "", 840, 600, 100, 100
            Attached Files

            Comment


            • #7
              Hi Walter,

              Thanks for the comment, but I'm not sure you're right. In my example, the frame was wider than the longest word, but still got bleed over onto the dialog.

              Did I misunderstand your comment?
              Last edited by Gary Beene; 21 Jan 2009, 05:28 PM.

              Comment


              • #8
                Trust me, the information I posted works. What you are seeing is DDT not honouring the
                styles you set for the frame.
                CONTROL ADD FRAME does not set the WS_CLIPSIBLINGS style for the control. You will have
                to ask PowerBASIC why this statement ignores such an important style.

                Give CONTROL ADD the boot and use the following instead:
                Code:
                 
                CONTROL ADD "BUTTON", hdlg, 504, "Title" & $CRLF & "Rocks At PowerBASIC", 340,20,70,90, _
                            %BS_GROUPBOX OR %BS_MULTILINE OR %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS
                Dominic Mitchell
                Phoenix Visual Designer
                http://www.phnxthunder.com

                Comment


                • #9
                  Hi Gary;

                  I'm sorry to hear that my suggestion didn't work for you.

                  Comment


                  • #10
                    Gary, you don't show enough code so it's hard to tell but my guess is you make the frame smaller than the textbox (unless I'm not undersatanding the problem). See frame code below.

                    '
                    Code:
                    'PBWIN 9.00 - WinApi 05/2008 - XP Pro SP3
                    #Dim All 
                    #Compile Exe  
                    #Include "WIN32API.INC"
                    '
                    Global hdlg As Dword                
                    %Id_Exit_Btn = 1000
                    %Id_Sample_Textbox = 1001
                    %Id_Show_Result_Btn = 1002
                    ' 
                    Macro Common_Locals 'Macro easier than retyping and maintains coding consistency
                      Global Dlg_hght, Dlg_Wd As Long 'Global in case want to use in Controls
                      Local Row, col, hght, tb_hght, wd, Longest,ctr, ln, ln1, i As Long
                      Local  l, s As String
                    End Macro  
                    '
                    CallBack Function Dialog_Processor              
                      Common_Locals
                      Select Case CbMsg     'This is TO determine the message TYPE 
                         '       
                         Case %WM_INITDIALOG'<- Initialiaton when the program loads 
                         '
                         Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes              
                         '
                         Case %WM_COMMAND  'This processes command messages
                           Select Case CbCtl
                             Case %Id_Show_Result_Btn 
                                Control Get Text CbHndl, %Id_Sample_Textbox To l$
                                  ? l$, , FuncName$
                             Case %Id_Exit_Btn
                               Select Case CbCtlMsg        
                                  Case 0
                                    Dialog End CbHndl 'Applikation beenden
                               End Select
                           End Select
                      End Select
                    End Function
                    '
                    Function PBMain
                      Common_Locals
                      Dlg_hght = 400
                      Dlg_Wd = 400
                      Dialog New Pixels, hdlg, "Demo", , , Dlg_Wd, Dlg_Hght, %WS_SYSMENU To hdlg 'centered
                    '
                      col = 10
                      Wd = 40
                      Hght = 12
                      Row = hght * 5
                    '  
                      s$ = "Brown, Kevin" & $CrLf & _
                           "123 PBWin Avenue" & $CrLf & _
                           "PowerBasic, FL 12345"
                    '         
                      Tb_Hght = Hght * 10 'Plenty room for 10 lines of text
                      Wd = Dlg_Wd - 20 'minus the label and leave a little
                      Control Add TextBox, hdlg, %Id_Sample_Textbox, s$, Col, Row, Wd, TB_Hght, %ES_WantReturn Or %ES_MultiLine
                    '
                      '>>>>>>>>>>> Frame Code
                      s$ = Trim$("Title") & $CrLf & Trim$("Rocks")
                      Row = Row - 25 ' room for title above tb      
                      Col = Col - 4 'start left of tb
                      Wd = Wd + 8 'extend past TB
                      TB_hght = TB_hght + 40 'extend below TB
                      Control Add Frame, hdlg, 504, s$, Col, Row, Wd, TB_hght, %bs_left Or %bs_multiline
                      '>>>>>>>>>>>> Ebd frame code
                    '
                       hght = 25   
                       Wd = Dlg_Wd - 20
                       Col = 10 'center
                    '
                       Row = Dlg_hght - (Hght * 2) - 4 'Just off bottom
                         Control Add Button, hdlg, %Id_Show_Result_Btn, "Show Textbox Results", col, row, Wd, Hght
                    '
                       Row = Dlg_hght - Hght - 2 'Just off bottom
                         Control Add Button, hdlg, %Id_Exit_Btn, "Abandon Ship", col, row, Wd, Hght
                    '  
                         Dialog Show Modal hDlg   Call Dialog_Processor
                    End Function  'Applikation beenden
                    '
                    ========================
                    Remember that lost time
                    does not return.
                    Thomas a Kempis
                    ========================
                    It's a pretty day. I hope you enjoy it.

                    Gösta

                    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                    Comment


                    • #11
                      Using Dominic's suggestion, it looks to me like the frame control is designed only for one line titles.

                      Code:
                      #COMPILE EXE
                      #DIM ALL
                      #INCLUDE "win32api.inc"
                      
                      FUNCTION PBMAIN()
                         LOCAL hDlg, nStyle AS LONG, s AS STRING
                         nStyle = %WS_SYSMENU OR %WS_MINIMIZEBOX
                         DIALOG NEW PIXELS, 0, "Frame Title", , , 700, 300, nStyle TO hDlg
                         
                         s = "Title" & $CRLF & "Rocks At PowerBASIC"
                         's = "Rocks At PowerBASIC"
                         CONTROL ADD "BUTTON", hdlg, 504, s, 200, 100, 200, 100, _
                                  %BS_MULTILINE OR %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %BS_GROUPBOX
                      
                         
                         DIALOG SHOW MODAL hDlg
                      END FUNCTION
                      Of course you could work around it by placing a label control next to a frame with no title.

                      Comment


                      • #12
                        it looks to me like the frame control is designed only for one line titles
                        No, the CONTROL ADD FRAME statement is broken. It cannot be used to create frames on a
                        resizeable dialog unless a workaround is applied. Controls on a resizeable dialog must have the
                        WS_CLIPSIBLINGS style, otherwise the dialog will look awful when it is resized.

                        A frame belongs to the button class and has the BS_GROUPBOX style, therefore,
                        this code
                        Code:
                        CONTROL ADD FRAME, hDlg, 504, "Title" & $CRLF & "Rocks At Grenada", 340,20,70,90, %BS_MULTILINE
                        is the same as this code
                        Code:
                        CONTROL ADD "BUTTON", hdlg, 504, "Title" & $CRLF & "Rocks At Grenada", 340,20,70,90, _
                                              %BS_GROUPBOX OR %BS_MULTILINE OR %WS_CHILD OR %WS_VISIBLE
                        If you don't want to use the CONTROL ADD statement, you can add the WS_CLIPSIBLINGS style after the
                        control is created like this
                        Code:
                         
                        LOCAL hCtrl AS DWORD
                        ...
                        CONTROL ADD FRAME, hDlg, 504, "Title" & $CRLF & "Rocks At Grenada", 340,20,70,90, %BS_MULTILINE
                        CONTROL HANDLE hDlg, 504 TO hCtrl
                        SetWindowLong hCtrl, %GWL_STYLE, GetWindowLong(hCtrl, %GWL_STYLE) OR %WS_CLIPSIBLINGS
                        Last edited by Dominic Mitchell; 22 Jan 2009, 04:14 AM.
                        Dominic Mitchell
                        Phoenix Visual Designer
                        http://www.phnxthunder.com

                        Comment


                        • #13
                          I'm missing something here. You guys are creating a custom control called "button" not a frame control. At least as I see it. Here's a FRAME (using Charles's code):
                          '
                          Code:
                          #Compile Exe
                          #Dim All
                          #Include "win32api.inc"
                          Function PBMain()
                             Local hDlg, nStyle As Long, s As String
                             Local boundry As Long
                             nStyle = %WS_SYSMENU Or %WS_MINIMIZEBOX
                             Dialog New Pixels, 0, "Frame Title", , , 700, 300, nStyle To hDlg
                             
                             s =   "Title" & $CrLf & "Rocks At PowerBASIC"
                             's = "Rocks At PowerBASIC"
                             Control Add "BUTTON", hdlg, 504, s, 200, 100, 200, 100, _
                                      %BS_MULTILINE Or %WS_CHILD Or %WS_VISIBLE Or %WS_CLIPSIBLINGS Or %BS_GROUPBOX
                          '
                          '<<<<<<<<<<<<<<<<<<<<<<<<< Frame 
                             boundry = 25
                             Control Add Frame, hdlg, 505, " Frame around Button", _
                                                200 - Boundry, _  'start left
                                                100 - boundry, _  'start higher
                                                200 + boundry + boundry, _ 'make wider
                                                100 + boundry + boundry, _    'make deeper
                                                %BS_Center
                             Control Set Color hdlg, 505, %Yellow, %Red                   
                          '>>>>>>>>>>>>>>>>>>>>>>>>>>>>   
                             Dialog Show Modal hDlg
                          End Function
                          '
                          It's a pretty day. I hope you enjoy it.

                          Gösta

                          JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                          LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                          Comment


                          • #14
                            I'm with Charles on this one - Multiline applied to a frame, is kind of flakey.

                            Using Control Add Frame or the equivalent Control Add "Button" with %BS_GROUPBOX style, the same problems are visible. Seperating the application of the styles with SetWindowLong doesn't change the way that CLIPCHILDREN chops the top half of the first of two 'Multilines'.
                            This DDT sample shows a partial work-around that puts up a (sacrificial) blank first line which CLIPCHILDREN removes, leaving the two lines both visible. CLIPCHILDREN does stop the frame label 'beeding' past the side of the frame but the top line of the frame box is not shown as you would expect.
                            Code:
                            #COMPILE EXE
                            #DIM ALL
                             
                            #INCLUDE "WIN32API.INC"
                             
                            FUNCTION PBMAIN()
                             LOCAL hDlg, hCtrl AS DWORD
                             DIALOG FONT DEFAULT "Arial" ,10 , 0 , 1
                             
                              DIALOG NEW PIXELS, 0, "Frame Test", 178, 185, 201, 140, %WS_CAPTION OR %WS_SYSMENU, TO hDlg
                              DIALOG SET COLOR hDlg, -1, %WHITE
                             
                              CONTROL ADD FRAME, hDlg, 504, "", 40, 20, 70, 90, %BS_MULTILINE
                              CONTROL HANDLE hDlg, 504 TO hCtrl
                              SetWindowLong hCtrl, %GWL_STYLE, GetWindowLong(hCtrl, %GWL_STYLE) OR %WS_CLIPSIBLINGS
                             
                              CONTROL SET TEXT hDlg, 504, " " & $CR & "Title" & $CR & "Rocks"    ' 1st line 'clipped'
                             
                              DIALOG SHOW MODAL hDlg
                             
                            END Function
                            I don't think it's a DDT issue either - see this pretty clumsy SDK sample that shows the same issues.
                            Code:
                            #COMPILE EXE
                            #INCLUDE "WIN32API.INC"
                            '
                            FUNCTION WINMAIN (BYVAL hInstance AS LONG, BYVAL hPrevInstance AS LONG, _
                                              BYVAL lpCmdLine AS ASCIIZ PTR, BYVAL iCmdShow AS LONG) AS LONG
                              LOCAL hWnd&, My_wclass AS WndclassEx, szAppName AS ASCIIZ * 80, Msg AS tagMsg
                              szAppName               = "MY_PBFAQ_SDK"
                              My_wclass.cbSize        = SIZEOF(My_wclass)
                              ' ---------------------------------------
                              My_wclass.STYLE         = %CS_DBLCLKS                                 ' class styles effect how some things work (different than window styles)
                              ' ---------------------------------------
                              My_wclass.lpfnWndProc   = CODEPTR(My_WndProc)
                              ' ---------------------------------------
                              My_wclass.cbClsExtra    = 0                                           ' define extra data storage for class
                              My_wclass.cbWndExtra    = 4                                           ' define extra data storage per each window instance (4 bytes can store 1 Long)
                              My_wclass.hInstance     = GetModulehandle(BYVAL %NULL)                ' define handle to process (EXE)
                              My_wclass.hIcon         = LoadIcon(0, BYVAL MAKLNG(%IDI_QUESTION,0))   ' default Icon displayed on ALT+TAB Dialogbox
                              My_wclass.hCursor       = LoadCursor(0, BYVAL MAKLNG(%IDC_HELP,0))    ' default Cursor for window
                              My_wclass.hbrBackground = GetStockObject(%GRAY_BRUSH)                 ' define window background brush
                              My_wclass.lpszMenuName  = 0                                           ' define default menu (0= no default menu)
                              ' ---------------------------------------
                              My_wclass.lpszClassName = VARPTR(szAppName)
                              ' ---------------------------------------
                              My_wclass.hIconSm       = LoadIcon(0, BYVAL MAKLNG(%IDI_QUESTION,0))      ' default Icon displayed in window caption bar
                              ' ---------------------------------------
                              '
                              RegisterClassEx My_wclass
                              hWnd = CreateWindowEx(0, szAppName, "Naff SDK Dialog", _
                                                  %WS_overlappedwindow, 50, 50, 400, 300, _
                                                  %HWND_DESKTOP, %null, hInstance&, BYVAL %NULL)
                              ShowWindow hWnd&, iCmdShow
                              UpdateWindow hWnd&
                              WHILE GetMessage(Msg, %NULL, 0, 0)
                                TranslateMessage Msg
                                DispatchMessage Msg
                              WEND
                            END Function 
                            '------------------/WinMain
                            '
                            FUNCTION My_WndProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                                              BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
                                SELECT CASE wMsg  '----------- start message handling ----------
                                    Case %WM_CREATE
                                      hFram1& =CreateWindow("BUTTON", "Initial" & $CR & "Label" & $CR & "+ Multiline?", _
                                        %WS_CHILD OR %WS_VISIBLE OR %BS_GROUPBOX OR %BS_MULTILINE, _
                                        50, _
                                        50, _
                                        100, _
                                        100, _
                                        hWnd, BYVAL %NULL, GetModuleHandle(BYVAL %NULL), BYVAL %NULL)
                                      hFram2& =CreateWindow("BUTTON", "1" & $CR & "Title" & $CR & "CLIPSIBLINGS" & $CR & "Clip Top?", _
                                        %WS_CHILD OR %WS_VISIBLE OR %BS_GROUPBOX OR %BS_MULTILINE OR %WS_CLIPSIBLINGS, _
                                        250, _
                                        50, _
                                        100, _
                                        100, _
                                        hWnd, BYVAL %NULL, GetModuleHandle(BYVAL %NULL), BYVAL %NULL)
                                    Case %WM_SYSCOMMAND
                                      If (WParam AND &HFFF0) = %SC_CLOSE Then 
                                        'WinBeep 900, 500
                                        '%WM_CLOSE comes next unless..
                                        'Function = 1
                                      End If
                                    Case %WM_CLOSE
                                      'WinBeep 300, 500
                                      'Exit Function      ' DOES work here in SDK
                                    CASE %WM_DESTROY
                                      'WinBeep 100, 500
                                      PostQuitMessage 0
                                    EXIT FUNCTION
                                END SELECT        '-----------  end message handling  ----------
                              FUNCTION = DefWindowProc(hWnd&, wMsg&, wParam&, lParam&)
                            END Function 
                            '------------------/My_WndProc
                            It's as if the frame control is displaying two superimposed labels.
                            The first label is just a background but is what you would get if the frame was not Multiline - it grows as more text is added and obscures the top line of the frame box, evetually extending beyond it if not truncated with CLIPCHILDREN.
                            The multiline text is displayed as you would expect but is chopped above the top of the frame if CLIPCHILDREN is applied.
                            Rgds, Dave

                            Comment

                            Working...
                            X