Announcement

Collapse
No announcement yet.

display in bold the last 4 letters of a string?

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

  • display in bold the last 4 letters of a string?

    hi,
    i am displaying this string: ABCD1234
    how can i display it to user like that:

    ABCD1234

    last characters are bold.
    Note: i a, using PB7
    thanks

  • #2
    Need more details, such as what type of control you are trying to do this with...
    Adam Drake
    PowerBASIC

    Comment


    • #3
      Originally posted by Adam J. Drake View Post
      Need more details, such as what type of control you are trying to do this with...
      hi,
      it is inside a TEXTBOX within a DIALOG control

      Comment


      • #4
        Try using a RichEdit control instead of a TextBox.
        Some discussion / code here..

        User to user discussions about the PB/Win (formerly PB/DLL) product line. Discussion topics include PowerBASIC Forms, PowerGEN and PowerTree for Windows.
        Rgds, Dave

        Comment


        • #5
          Originally posted by Dave Biggs View Post
          Try using a RichEdit control instead of a TextBox.
          Some discussion / code here..

          http://www.powerbasic.com/support/pb...ad.php?t=36567
          Hi,
          I cant find in PB7 RichText control or
          Code:
          CONTROL SET FONT [I][I]hDlg[/I][/I],   [I][I]id&[/I][/I], [I][I]fonthndl&[/I][/I]
          .
          there is only
          Code:
          DIALOG FONT fontname$, pointsize&
          which changes the font for teh whole dialog
          thanx
          Last edited by Raed Abu-Sanad; 8 Oct 2008, 10:41 AM.

          Comment


          • #6
            There are two ways to do this.

            First of all, don't use a TEXTBOX (edit) control. Do you really want your users EDITING a field which appears in multiple fonts? I didn't think so.

            A LABEL (static) control would be a better choice for a display-only control.

            Ok, the two ways:
            1. Instead of using a single control, use two controls, one for the "normal" font and one for the "bold" font, located right next to the "normal" font . Use the appropriate font setting command for the "bold" control. I don't think there is a DDT "CONTROL SET FONT" command, so you will have to "CONTROL SEND CBHNDL, %ID_CONTROL, %WM_SETFONT, hFont, %NULL"

            This method stinks, because to get the text to look like "one piece of text" you will have to adjust the location of the BOLD control every time the text changes in the NORMAL control. While "doable" it will not be fun, at all.

            2. Create the LABEL control with style SS_OWNERDRAW; on the WM_DRAWITEM notification you will draw the text yourself.

            This WILL involve making some GDI calls to the WinAPI. There are no DDT commands to handle this.

            There may or may not be a demo of this here, somewhere. Try searching for "WM_DRAWITEM " *and* ( "TextOut" OR "DrawText" )

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Can't remeber what font statements were available back in PBwin7.

              If you want mixed characters in a single control here's an example of using a RichEdit control as a label..

              User to user discussions of general programming topics such as algorithms, APIs, etc.


              And another version..
              User to user discussions about the PB/Win (formerly PB/DLL) product line. Discussion topics include PowerBASIC Forms, PowerGEN and PowerTree for Windows.


              In later versions of the compiler you have the advantage of Graphic text options too..
              Rgds, Dave

              Comment


              • #8
                >In later versions of the compiler you have the advantage of Graphic text options too..

                Darned, I forgot about that! A GRAPHIC CONTROL would make this relatively simple to do I think, since there are text-measuring 'DDT' commands built in.

                (The compiler version thing will have to be a separate issue.)
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  hi,
                  i cant find even SS_OWNERDRAW, could u post an example to make things simpler to me, i am a newbie to PBa dn BASIC generally.
                  thanks

                  Comment


                  • #10
                    To create a static control using the CreateWindow or CreateWindowEx function, specify the STATIC class, appropriate window style constants, and a combination of the following static control styles.

                    Comment


                    • #11
                      I agree with Dave about RichEdit
                      Try using a RichEdit control instead of a TextBox.
                      although it takes some coding, but you can format the text (even if its a bit extreme and do it character by character)

                      Somewhere here I know I or others have examples of Richedit. (probably in the source code forums archives)
                      Engineer's Motto: If it aint broke take it apart and fix it

                      "If at 1st you don't succeed... call it version 1.0"

                      "Half of Programming is coding"....."The other 90% is DEBUGGING"

                      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                      Comment


                      • #12
                        Originally posted by Raed Abu-Sanad View Post
                        hi,
                        i cant find even SS_OWNERDRAW, could u post an example to make things simpler to me, i am a newbie to PBa dn BASIC generally.
                        thanks
                        Raed, As a "newby to PB AND to BASIC generally" (your Oct 2008 forum join date noted), what you are asking to do (mixing fonts on the same line) is a pretty advanced project. I would suggest taking things a little slower until you have a little more experience with Basic (and PB).

                        A couple ways to do it were suggested but both are *relatively* advanced and would probably, even likely, to be confusing to a newby.

                        Not trying to discourage you at all. Only wouldn't like to see you be unnecessarily daunted in the dawn of could be a bright, promising, delightful, exciting, satisfying PB experience for you (and maybe us) by *relatively* sophisticated techniques.

                        (Note that posted, someone will probably post a simple 5 line routine to do what Raed asks. {sigh})

                        =======================================
                        "Logic is in the eye of the logician."
                        Gloria Steinem
                        =======================================
                        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

                        Working...
                        X