Announcement

Collapse
No announcement yet.

DDT Display Questions

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

    DDT Display Questions

    Hi everyone:

    I've been doing quite a lot of dialog creation/modification lately, and have a couple of questions.

    First, I have a button: START GAME! I want to make the word GAME! wrap to the second line in the button, instead of having both words on the same line, but can't seem to convey this to PowerBASIC. I've tried placing a CHR$(10) or CHR$(13) between the two words, but it just places a strange ASCII symbol in the middle of the line.

    Next, I've got a combobox with 150 items that the user can select from to change the font of the dialog print. The user can easilly scroll down the list with the mouse using the down arrow, but there is no up arrow. How can I get the combobox to display with one?

    Now, I have a textbox displaying some instructions that the user of my game will need to read. It's about 5 screens of information, yet the Read-Only TextBox has no up or down arrow. I've tried everything I can think of here, but just can't seem to get it. Same question really, I guess, is there any way for a mouse user to move through the information in the textbox without having to press the pagedown key?

    Lastly, I've got a dialog using IMGBUTTONS. I have created a nice button with an icon displaying perfectly, but I want to be able to caption the button with some text. If I create a label above the button, the user will not be able to click on the caption, and there's plenty of room at the top of the button for a nice caption to be displayed. Ideally, I'd like the text to be written in the center over top of the image and use the ImgButtonX control, but I imagine this would be a bit trickier than simply captioning the image. I had thought of writing the text in a fancy script on top of the image in the actual icon, but I want the user to be able to change the font, size, weight, etc. of the caption.

    Sorry to post so many questions at once, but I am really puzzled as to how to go about solving them.

    Thanks so much for your help.
    Danny.

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

    #2
    Danny, for your first question add style %BS_MULTILINE to your
    CONTROL ADD BUTTON definition, and use:

    "&START" + $CRLF + "GAME"



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

    Comment


      #3
      Charles:
      That worked! Thanks a million!
      Have a great day.
      Cheers
      Danny.

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

      Comment


        #4
        Danny, for your second question, try this...

        Code:
        #COMPILE EXE
        #DIM ALL
        #INCLUDE "win32api.INC"
        DECLARE CALLBACK FUNCTION dlgProc()
        FUNCTION PBMAIN
           LOCAL hDlg AS LONG, txt AS STRING, style AS LONG, i AS LONG
           DIALOG NEW 0, "Test", , , 100, 200, %WS_SYSMENU + %WS_CAPTION TO hDlg
           CONTROL ADD BUTTON, hDlg, %IDOK, "&Start" + $CRLF + "Game", 5, 10, 70, 30, %BS_MULTILINE
           CONTROL ADD BUTTON, hDlg, %IDCANCEL, "&Cancel", 5, 50, 70, 30
           txt = "This is a test of the scrolling, read only textbox" + $CRLF
           FOR i = 0 TO 20
              txt = txt + $CRLF + STRING$(8, 65 + i)
           NEXT i
           style = %ES_MULTILINE + %ES_READONLY + %WS_VSCROLL
           CONTROL ADD TEXTBOX, hDlg, 100, txt, 10, 100, 80, 50, style, %WS_EX_CLIENTEDGE
           DIALOG SHOW MODAL hDlg CALL dlgProc
        END FUNCTION
        
        CALLBACK FUNCTION dlgProc()
           SELECT CASE CBMSG
           CASE %WM_COMMAND
              SELECT CASE CBCTL
                 CASE %IDOK
                    MSGBOX "Starting game now"
                 CASE %IDCANCEL
                    DIALOG END CBHNDL
                 END SELECT
           CASE %WM_DESTROY
           END SELECT
        END FUNCTION
        ------------------

        Comment


          #5
          ComboBox:
          Try the following style: %WS_VSCROLL OR %CBS_DISABLENOSCROLL
          Also, check the height, since it determines the height of the
          dropped list. I usually set it to 80, or more.

          TextBox:
          Try the following style: %ES_MULTILINE OR %WS_VSCROLL OR _
          %ES_AUTOVSCROLL

          IMGBUTTONS:
          Yes, sounds tricky. You probably need to create an ownerdrawn
          button and handle all drawing and repositioning of text and
          image there. Easiest solution must be do include it in the image.

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

          Comment


            #6
            All right! That worked, Also!
            The %WS_VSCROLL style did it for the textbox and combobox. What a streightforward, yet ingenious solution! Thank you so much for suggesting it, I saw the style in WIN32API.INC but didn't know what it did. Now I do! I should mention for anyone that's interested, I successfully captioned my image by creating a label near the bottom of the IMGBUTTONX control. It looks great.

            I have one more really strange question for you clever PB programmers, and then I'll leave you all alone for a long, long time. I am writing a simple editor to take notes and so forth, but I want to build in a very streightforward spell-checker type idea. I don't want to create a function to spell-check the entire document at once; if my users are like me they'd never even consider using it. My idea is to skip that step at the end, and have the program check the spelling of the current line as they go, displaying missspelled words at the bottom of the screen in a status line. My problem is, as you may have guessed, I don't know how to get the current line from a textbox as the user scrolls through it. I don't suppose any of you would happen to know how?

            Thank you so much for your time. I sure do appreciate all the helpful hints!
            Danny.

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

            Comment


              #7
              Danny, hope the following code helps you in determining the current line number.


              Code:
              #COMPILE EXE
              #DIM ALL
              #INCLUDE "win32api.INC"
              DECLARE CALLBACK FUNCTION dlgProc()
              
              FUNCTION PBMAIN
                 LOCAL hDlg AS LONG
                 DIALOG NEW 0, "Textbox Line Number", , , 150, 140, %WS_SYSMENU + %WS_CAPTION TO hDlg
                 CONTROL ADD BUTTON, hDlg, 100, "&LineNo", 5, 10, 50, 14
                 CONTROL ADD TEXTBOX, hDlg, 101, "", 5, 30, 120, 80, %ES_WANTRETURN + %ES_MULTILINE
                 DIALOG SHOW MODAL hDlg CALL dlgProc
              END FUNCTION
              
              CALLBACK FUNCTION dlgProc()
                 LOCAL s AS STRING, i AS INTEGER
                 STATIC lineNo AS LONG
                 SELECT CASE CBMSG
                 CASE %WM_INITDIALOG
                    FOR i = 1 TO 7
                       s = s + "This is line" + STR$(i) + $CRLF
                    NEXT i
                    CONTROL SET TEXT CBHNDL, 101, s
                 CASE %WM_COMMAND
                    SELECT CASE CBCTL
                       CASE 100
                          MSGBOX "Line number =" + STR$(lineNo + 1)
                       CASE 101
                          CONTROL SEND CBHNDL, 101, %EM_LINEFROMCHAR, -1, %NULL TO lineNo
                       END SELECT
                 CASE %WM_DESTROY
                 END SELECT
              END FUNCTION

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

              Comment


                #8
                And if you want the text of a certain line, you can use:
                Code:
                FUNCTION GetLineText(BYVAL hEdit AS LONG, BYVAL ln AS LONG) AS STRING
                  LOCAL Buf AS STRING, lnStart AS LONG, lnLen AS LONG
                 
                  lnStart = SendMessage(hEdit, %EM_LINEINDEX, ln, 0)       'line start
                  lnLen   = SendMessage(hEdit, %EM_LINELENGTH, lnStart, 0) 'line length
                 
                  IF lnLen THEN
                     Buf = SPACE$(lnLen)
                     lnLen = SendMessage(hEdit, %EM_GETLINE, ln, STRPTR(Buf)) 'Get line
                     IF lnLen THEN FUNCTION = Buf
                  END IF
                 
                END FUNCTION
                Together with Charles' example, it can be tested with:
                Code:
                         CASE 100
                            MSGBOX GetLineText(GetDlgItem(CBHNDL, 101), lineNo)

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

                Comment


                  #9
                  Charles, Borje:
                  That did it! I've combined the two functions so I can get the default line from the textbox with a quick function call! The editor works great, and It's really quick!

                  Thank you so much for your help.

                  Danny.

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

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎