Announcement

Collapse
No announcement yet.

DDT button vs SDK

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

  • DDT button vs SDK

    Using DDT, I create a rather good looking button with this:-

    CONTROL ADD BUTTON, hDlg, ButtonID," " + CHR$(ButtonID), bPos(ButtonID).x, bPos(ButtonID).y, w, h, _
    %SS_NOTIFY OR %SS_CENTER OR %SS_SUNKEN, %BDR_RAISED

    I am actually creating an array of buttons from "A" to "Z".

    As I say, the buttons look good and I seem not to be able to create
    the same style in SDK code. The %SS_ and %BDR_ styles are normally
    for STATIC windows.

    Does DDT use some combination when creating buttons?

    Regards,

    David

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

  • #2
    David, you are mixing equates from two separate things, in an effort to create a button.

    First, the Static styles are definitely wrong - you should be using Button styles. Essentially, when you specify a style with equates, the equates are replaced with their numeric values to form a bit-mask. Windows uses this bit-mask to work out how the control should br drawn and behave. When you specify the styles for a different kind of control you are forming a style bit-mask that is very likely to make the control behave completely differently than expected.

    Further, the style %BDR_RAISED is actually not a control style equate at all, but a flag used for the DrawEdge() API. Since you are using this for the Extended Style, you are effectively telling DDT to use the extended styles EXSTYLE& = %WS_EX_DLGMODALFRAME OR WS_EX_NOPARENTNOTIFY (since this is that the value of BDR_RAISED is equal to).

    Is this clear?

    Try using the following code:
    Code:
    CONTROL ADD BUTTON, x&, %Button1, "&text", 10, 10, 50, 14,,%WS_EX_DLGMODALFRAME
    It should give you the exact same (strange looking!) button.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Nope. It's just that you are using "wrong" values that happen to become
      valid. %BDR_RAISED (&H0005) as EX style can be translated into
      %WS_EX_NOPARENTNOTIFY OR %WS_EX_DLGMODALFRAME (&H00000004& OR &H00000001&).
      Both combinations = 5, so you really use the later combination, even if
      %BDR_RAISED looks valid. You can also set ex style to 5 directly and see
      what happens..

      Same with the others, %SS_NOTIFY OR %SS_CENTER OR %SS_SUNKEN is same as
      %BS_LEFT OR %BS_PUSHLIKE OR %BS_DEFPUSHBUTTON. In other words, correct
      styles, %BS_LEFT OR %BS_PUSHLIKE OR %BS_DEFPUSHBUTTON, %WS_EX_DLGMODALFRAME,
      will give you same appearence.

      Using correct styles, you know what you have created. Using wrong ones
      from other controls, you are in for big surprises, because the values
      still translates into something..


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

      Comment


      • #4
        Control styles
        --------------
        SS_NOTIFY = BS_LEFT = &H100&
        SS_CENTER = BS_DEFPUSHBUTTON = &H1&
        SS_SUNKEN = BS_PUSHLIKE = &H1000&

        Extended styles?
        ----------------
        BDR_RAISED = WS_EX_DLGMODALFRAME OR WS_EX_NOPARENTNOTIFY = &H0005

        Yep, these will definitely give pause to CreateWindowEx. You aren't
        gonna get what you think you gonna get. What is wrong with using the
        BS_xxx styles for the buttons? How about
        window styles = BS_NOTIFY OR BS_CENTER OR BS_PUSHLIKE
        extended styles = WS_EX_DLGMODALFRAME OR WS_EX_NOPARENTNOTIFY
        or maybe
        window styles = BS_NOTIFY OR BS_CENTER OR BS_PUSHBUTTON.
        extended styles = WS_EX_DLGMODALFRAME OR WS_EX_NOPARENTNOTIFY

        Also, why are you using a DrawEdge flag(BDR_RAISED)?
        Anyway, adding the WS_XXX and WS_EX_XXX styles to the standard controls
        is an easy way to produce some striking effects.


        ------------------
        Dominic Mitchell
        Dominic Mitchell
        Phoenix Visual Designer
        http://www.phnxthunder.com

        Comment


        • #5
          Thanks chaps.

          I had taken some example code from an earlier posting for Game15.bas
          which created statics with this code. I simple changed the static to
          button and saw the interesting effect.

          I'll experiment further with the SDK styles.

          Regards,

          David

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

          Comment


          • #6
            David, you stumbled across an interesting aspect of Windows !

            While, of course you were using all the wrong Style constants
            as was mentioned, you did use one extended style that was acceptable which
            was :

            %WS_EX_DLGMODALFRAME

            (you use %BDR_RAISED which the wrong constant, but the right value)


            This style gives you a dialog type border around your control.

            The same thing can be accomplished with the style %WS_DLGFRAME.

            If you examine the Style for controls carefully, there are two
            different types of styles. If you break up the DWord that holds a
            style into a Low Word and High Word, you will noticed that the high
            word will be used to store a generic Window style (they start with
            %WS_). The low word is used to store a value which is unique to the
            control (ie. %BS_LEFT).

            Most of the time, you can mix the generic window styles with the
            controls unique style to produce some interesting effects.

            The style %WS_DLGFRAME will produce a nice dialog type border (a
            raised border) around your control. You can mix this with the
            extended style %WS_EX_STATICEDGE to produce a 3D border (both
            a raised edge and a sunken edge combined).

            When you create a control using the styles associated with it,
            the control may convert some of those styles into generic Window
            styles in its WM_CREATE or WM_NCCREATE messages. Most controls do not
            paint the border around themselves. They simply use a generic
            window style or extended style and then pass the non-client area
            messages (WM_NCPAINT) to the DefWindowProc function which draw it
            for them.

            Basically, this means that is most instances, the use of generic
            Window Styles and extended styles are acceptable for controls (at least
            the ones that affect the border).

            Simply put, you can use these styles to produce interesting borders
            around your controls with no problems.



            ------------------
            Chris Boss
            Computer Workshop
            Developer of "EZGUI"
            http://cwsof.com
            http://twitter.com/EZGUIProGuy

            Comment


            • #7
              To reiterate and clarify:
              Code:
              %BDR_RAISED <> %WS_EX_DLGMODALFRAME
              %BDR_RAISED =  %WS_EX_DLGMODALFRAME + %WS_EX_NOPARENTNOTIFY
              These are compared in their numeric value only... %BDR_ equates should not be used to specify control styles.


              ------------------
              Lance
              PowerBASIC Support
              mailto:[email protected][email protected]</A>
              Lance
              mailto:[email protected]

              Comment


              • #8
                The easiest way to experiment with things like this is to use a dialog editor like Microsoft Visual Studio. In VS, if you double-click on a control like a button, a dialog will appear with checkboxes for each of the valid properties for that control. Rather than compile, run, look... compile, run, look... you can see the effects of the various properties instantly. Then, when you find the look you want, you simply examine the resulting .rc file and use those equates with your DDT dialog.

                I also find a resource editor to be useful for designing dialogs. Drag things around until you like the way they look, then hard-code the values into your DDT commands.

                I also like the fact that I use a Microsoft product as a "third party add on" for PowerBASIC.

                -- Eric

                P.S. You may find that you like using the resource editor so much that you will eventually move from DDT to SDK style coding for your GUIs.



                ------------------
                Perfect Sync Development Tools
                Perfect Sync Web Site
                Contact Us: mailto:[email protected][email protected]</A>
                "Not my circus, not my monkeys."

                Comment


                • #9
                  A good tip Eric.

                  I often design the UI with Visual Studio, and then use RCtoDDT to generate DDT code. It can shave a bit of time from the task of creating a GUI.


                  ------------------
                  Lance
                  PowerBASIC Support
                  mailto:[email protected][email protected]</A>
                  Lance
                  mailto:[email protected]

                  Comment


                  • #10
                    Thanks gentlemen,

                    I am now using the following which suits the need:_

                    i& = CreateWindow("BUTTON", BYCOPY bc, %WS_VISIBLE OR %WS_DLGFRAME OR %WS_CHILD, _
                    xPos, yPos, w, h, hDlg, ButtonID, hInstance, _
                    0)
                    Regards

                    David

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

                    Comment


                    • #11
                      Is there any particular reason you started using DDT (CONTROL ADD) and are now using the CreateWindow() API call instead?

                      ------------------
                      Lance
                      PowerBASIC Support
                      mailto:[email protected][email protected]</A>
                      Lance
                      mailto:[email protected]

                      Comment


                      • #12
                        Hi Lance,

                        I am simply experimenting. I am testing one lookup screen in DDT
                        and one in SDK using Steve Hutch's dBuilder freeware program.

                        Both have a list box and 26 buttons 'A' to 'Z'. Click the button and load
                        the listbox from a file or database, with names begining with the
                        letter of the button caption.

                        Regards,

                        David

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

                        Comment

                        Working...
                        X