Announcement

Collapse
No announcement yet.

Acceptable Style Bits For Custom Controls

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

  • Acceptable Style Bits For Custom Controls

    I was just printing out some of the bits set in the various window styles we use such as %WS_OVERLAPPEDWINDOW, %WS_VISIBLE, etc. These all appear to be in the upper WORD of the 32 bit DWORD. It was my understanding that the low 16 bit word was fair game for custom control writers. However, in outputting some of the extended window styles, I saw that MS had ventured into the high order byte of the low order word (now, that is confusing!), ie., bits 8 through 15. For example, here is my little program to check out the bits in %WS_EX_OVERLAPPEDWINDOW...

    Code:
    #Compile Exe
    #Dim All
    #Include "Win32Api.inc"
    
    Function PBMain() As Long
      Local dwVar As Dword
      Register i As Dword
      
      dwVar=%WS_EX_OVERLAPPEDWINDOW
      'dwVar=%WS_EX_CLIENTEDGE
      Print "dwVar="dwVar
      Print
      For i=0 To 31
        Print "Bit #"Trim$(Str$(i)), Abs(IsTrue(dwVar And 2^i))
      Next i
      
      Waitkey$
      
      PBMain=0
    End Function
    Code:
    'Output
    '===============
    'dwVar= 768
    '
    'Bit #0         0
    'Bit #1         0
    'Bit #2         0
    'Bit #3         0
    'Bit #4         0
    'Bit #5         0
    'Bit #6         0
    'Bit #7         0
    'Bit #8         1                set
    'Bit #9         1                set
    'Bit #10        0
    'Bit #11        0
    'Bit #12        0
    'Bit #13        0
    'Bit #14        0
    'Bit #15        0
    'Bit #16        0
    'Bit #17        0
    'Bit #18        0
    'Bit #19        0
    'Bit #20        0
    'Bit #21        0
    'Bit #22        0
    'Bit #23        0
    'Bit #24        0
    'Bit #25        0
    'Bit #26        0
    'Bit #27        0
    'Bit #28        0
    'Bit #29        0
    'Bit #30        0
    'Bit #31        0
    So, would it be safe to assume we could use bits 0 through 7 for our own use in styles we may create for our own custom controls. At this point I really only need one bit for the control (a grid) I'm working on.
    Fred
    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

  • #2
    Check out the standard control "EDIT" class.
    It has such extra flags.

    Personally i woul'd not recommend this approach.
    Not very extendable.
    usually a change on demand requires recreate of the control(?)
    hellobasic

    Comment


    • #3
      The WS_EX_ constants represent extended styles, thus are separate from the basic WS_ styles. The easiest method is to base your styles on a set of pre-designed styles such as the ES_ and BS_ style sets - copy, paste & rename.
      kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

      Comment


      • #4
        Just checked out %ES_AUTOHSCROLL for the edit control Edwin. It has bit #7 set. I don't see how Microsoft's use of bits 0 through 7 for its various controls, ie., edit, combo box, list box, etc., would bother me in any way for my intended use of these lower eight bits, because I'd be using them in a CreateWindowEx() call for a custom control, so it would only be my interpretation of the bits within the WM_CREATE of the control that would matter, ie.,

        Code:
        CreateWindowEx(0,"MyGrid","",%EDIT_ONLY_GRID Or %WS_CHILD Or %WS_VISIBLE.......

        No Go????
        Fred
        "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

        Comment


        • #5
          What if you have a need for more bits?
          (And your users already are using your grid for years)

          How about on demand change of 'style' / behaviour of this control?
          hellobasic

          Comment


          • #6
            Maybe some folks might have a need to change the style of a control at run time, but I've never done that. Never even thought of doing that. At present I write my own grids for the rather special purpose of entering data. For those grids I never even bothered with styles. At this time though I'm thinking of adding one more modality to my grids, and that would be to enable a behavior more typical of how grids are usually used, that is to scroll through and view data with an occasional edit. So, rather than writting a new grid, (and having to load two dlls), I'd like to just modify the one I have to accept a somewhat altered functionality. So in other words, define two styles, ie.,

            Code:
            %DATA_ENTRY_GRID   = 0
            %DATA_EDIT_GRID    = 1
            This does not appear to me to be an unacceptable use of style bits. If, in the fullness of time I, I might come up with some other modality, limiting myself to the lower eight bits leaves a lot of room for expansion. Of course, since bits pertaining to buttons, edit controls, etc., would have no meaning or interpretation within the WM_CREATE of my grid, I could I suppose redefine those equates as I wish, but that seems awkward, if not ridiculous, to me.
            Fred
            "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

            Comment


            • #7
              The High sixteen bits of window styles is for Windows use (predefined).
              The low sixteen bits of window styles are for your use any way you like (for custom classes).

              Don't mess with the extended window styles, since they are for windows only and aren't used for custom control classes. Future versions of Windows may use some bits not currently used.
              Chris Boss
              Computer Workshop
              Developer of "EZGUI"
              http://cwsof.com
              http://twitter.com/EZGUIProGuy

              Comment


              • #8
                Thanks for the confirmation Chris. Guess I'm on track then. I think I can make this work!
                Fred
                "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                Comment


                • #9
                  Some people prefer to use SendMessage() to customize the control using their own flags.
                  i.e.
                  CreateWindow...
                  SendMessage hControl, %WM_CstMessage, %CC_SETALL, %CC_FLAGS
                  ShowWindow...

                  Comment

                  Working...
                  X