Announcement

Collapse
No announcement yet.

Super-classed controls and cbWndExtra..

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

  • Super-classed controls and cbWndExtra..

    Did some tests on standard and super-classed standard controls right
    after creation with:
    Code:
      MSGBOX STR$( GetClassLong(hCtrl, %GCL_CBWNDEXTRA) )
    ..with interesting results. BUTTON controls already has 8 bytes allocated,
    COMBOBOX 2 bytes, etc. When Super classing them, one often want to add a
    few bytes to cbWndExtra for own purposes, but since MS obviously already
    use some of it and also say we should not set cbWndExtra to more than 40
    extra bytes - then how safe is it to add anything extra at all?

    I mean, what if MS starts using up those 40 bytes itself in later versions
    of Windows? Maybe adding to cbWndExtra should be avoided with super-classed
    controls? Or maybe I simply have been sitting here too long and my mind has
    started seeing ghosts in every corner of Windows..


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

  • #2
    Borje;

    That is a good point !

    While I doubt the standard controls will be modified significantly
    in the future, the common controls obviously have gone through
    significant changes because of many different versions.

    Using properties may be a safer way to go.

    I superclass the edit control which uses 10 bytes I think and I was
    worried about that.

    It does seem the standard controls don't use anywhere near the
    maximum of 40 bytes though, so adding a few extra bytes shouldn't be
    a problem. Also Windows 95 is 16 bit under the hood, so it is
    limited by 40 extra window bytes, but Windows NT, ME, 2000 should be
    32 bit under the hood and they may not be limited by the 40 byte
    limitation. Have you tried Windows ME, 2000 to see if it will handle
    more than 40 bytes ?

    If it does, then all you would have to do is verify that Win95/98
    leave you some room to work with and not worry about later OS.


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

    Comment


    • #3
      "Shouldn't" and Microsoft logic doesn't rhyme very well in my ears.
      I think you are right Chris, probably nothing to worry about. If MS
      starts using up lots of those bytes, it will be in new systems, new
      controls, where limit is set higher. Just as long as one makes sure
      to *add* own extra bytes to existing, it should be safe.

      Still, the phrase "no one will ever need more than 640 KB" keeps
      ringing in my ears.. :/

      I have a fancy box with expensive Win ME here, no longer installed,
      because I ran into so many hardware problems. MS seems to think
      hardware older than a year doesn't exist and that all people are
      rich enough to buy new each year. I'm a rare creature in their eyes,
      some of the stuff I use daily is more than ten years old (like an
      18-pin invoice printer from around 1848, etc.. So, can't test in ME..


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

      Comment


      • #4
        Borje,

        You are right, there are ghosts in every corner of windows and
        Microsoft put them there. I am a "s"u"c"k" it and see man(empirical
        testing) so if you need the extra bytes for each control instance,
        write the code and get a few friends to test it on later versions
        for you to see what it does.

        You are probably safe to allocate the full 40 bytes and use the
        higher addresses. I would not be surprised what Microsoft does
        after seeing the changes from win3.## to win95 so I don't think
        there is a particularly safe way to do anything as documented
        functions get changed by Microsoft as it suits them, not you
        or I.

        Regards,

        [email protected]

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


        [This message has been edited by Steve Hutchesson (edited May 12, 2001).]
        hutch at movsd dot com
        The MASM Forum

        www.masm32.com

        Comment


        • #5
          At the end, the controls are prob. not meant to superclass in the first place.
          Superclassing is just made possible.
          I never touch the extrabytes during superclassing.
          You can not predict the results.
          Maybe now but what in the future for that class?

          SetPROP() is what i use.
          Superclassed controls are easy to maintain because of the messages you get like WM_DESTROY.



          ------------------
          hellobasic

          Comment


          • #6
            Why to worry ?
            limitation of 40 bytes is for Windows 95 only (which almost died).
            If OS doesn't accept large parameters it's honestly returns 0 in RegisterClass (so, possible to control).

            If you need more than 40 bytes, you can:
            1) either to mark an app by Windows 98+, NT 3.51+ (doubt that you lose more than 1% of customers)
            2) either to use a way, recommended by Microsoft - 4 additional bytes only (pointer to allocated memory).

            Actually second way is even better:
            a) one GetWindowLong only.
            b) clear that all standart controls use less than 40 bytes.

            ------------------
            E-MAIL: [email protected]

            Comment


            • #7
              Borje;

              I would assume that most controls will leave enough room in the
              extra bytes to allocate at least one extra long.

              To play it safe, you can use just one long to store a handle to a
              UDT stored in Global memory (use Peek and Poke to move the memory
              back and forth between a real PB UDT variable - of course you must
              use the Global handle and unlock it first to use Peek and Poke).

              This will allow you to allocate as large a block of memory you
              may need.



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

              Comment


              • #8
                Why worry? Because soon new version of Windows again. Who knows what
                MS starts doing there - maybe new limit will be 2 GB, but MS will use
                it all for new .NET things in standard controls. Remember Bill's
                prediction about 640 KB.. :/

                No, I don't think so either. Just wanted to point out that not all bytes
                are available when one super-class existing standard controls. I usually
                allocate memory for a UDT and only need to store a 4-byte pointer. Should
                be safe enough. However, did a stupid thing, superclassed a ComboBox and
                tried to use Get/SetWindowLong at byte zero for my 4 byte pointer, with
                GPF as result. Forgot that MS already use some of those extra bytes in
                their controls.

                BTW, did you know that dialogs, like DDT or resource, uses up 16 of those
                extra bytes themselves? SDK style windows use what we tell them to, plus
                gives programmer full control. Start to like SDK'style better and better..

                BTW2: Win95 is far from dead. Millions of people have not upgraded, because
                paying so much money just to get new start-up picture is not on their
                priority list. As a matter of fact, lots of schools and even big companies
                still even use Win 3.1(1) because A: it works for them, B: they have hundreds
                of working old 486's and simply can't afford to upgrade them all. I know, I
                still sell a lot of my 16-bit app' to both schools and companies and almost
                not a day without a system manager that tells me how lucky he was to find
                something that works in all his computers..

                Recent statistics I saw in a newspaper showed about 80% use Win98/ME. Almost 10%
                of all Windows systems were still Win95 (a lot of computers, that's for sure),
                a few percent are still Win3.x and only a few percent actually is Win2K. Mostly
                large companies use Win2K or NT4, but most ordinary users don't. So, depending
                on type of program and market, it may be a waiste of time trying to figure out
                things that don't work in a few % NT systems, but works in 90% of all PC computers..


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

                Comment


                • #9
                  Chris, almost exactly what I do. In this case, something like:
                  Code:
                  'in declares
                  TYPE CBCOLORDATA
                    oldProc   AS LONG
                    autoColor AS LONG
                    userColor AS LONG
                  END TYPE
                   
                  'in WINMAIN or PBMAIN..
                    LOCAL cbc AS CBCOLORDATA PTR
                    cbc = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@cbc))
                    IF cbc THEN
                       @cbc.oldProc   = SetWindowLong(hCombo, %GWL_WNDPROC, BYVAL CODEPTR(CBProc))
                       SetClassLong hCombo, %GCL_CBWNDEXTRA, 40 'what is 40 bytes in ocean of memory..?
                       SetWindowLong hCombo, 36, cbc            'Store the pointer for later use at pos 36
                    ELSE
                       EXIT FUNCTION                            'no point to continue..
                    END IF
                   
                   
                  'in cbProc
                    LOCAL cbc AS CBCOLORDATA PTR
                    cbc = GetWindowLong(hWnd, 36)   'Get stored data
                   
                    SELECT CASE wMsg
                       CASE %WM_DESTROY 'Un-subclass Combobox and free up allocated memory
                          IF @cbc.oldProc THEN SetWindowLong hWnd, %GWL_WNDPROC, @cbc.oldProc
                          IF cbc THEN CALL HeapFree(GetProcessHeap(), 0, BYVAL cbc)
                          FUNCTION = 0 : EXIT FUNCTION

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

                  Comment


                  • #10
                    Borje --

                    > So, depending on type of program and market,

                    That's exactly right. For example, one of my programs is used by businesses that use 100.00% Windows NT. So it's a waste of time for me to do anything with 9x when it comes to that program. It all depends on your target audience.

                    > it may be a waiste of time trying to figure out
                    > things that don't work in a few % NT systems, but
                    > works in 90% of all PC computers.

                    Unfortunately that may turn out to be short-sighted. Microsoft has officially terminated the Windows 95/98/ME line. It is still available -- you can still buy 98 and ME -- but the replacement for those versions will be Windows XP, which is based on Windows NT.

                    It may be true that today a large percentage of the world's PCs use Windows 9x, but that number is virutally guaranteed to decline over the next few years.

                    -- Eric




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

                    Comment


                    • #11
                      Things will be very different with XP, because most people will have
                      to upgrade or buy new computers in order to run it. Plus, more than 90%
                      of all Internet connections are still via slow modems, and will be for
                      many years to come, so most people in real world won't be able to use
                      XP and many of those .NET features at all.

                      Must remember that for majority of people, a computer is not the most
                      important thing to spend money on. I have a feeling MS marketers have
                      fallen into latest IT hype and think all has broadband and GHz machines,
                      or at least will get/have within reasonable time. Have a feeling that
                      putting so much trust and money on XP may be what finally pulls Microsoft
                      down from the throne.

                      Also have feeling they are not complete fools, so must be some weird
                      strategy behind all this. Maybe they want "ordinary" people to start
                      using Mac instead? After all, Bill has always had his greedy eyes on
                      Mac and owns a large portion of it by now, so who knows..


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

                      Comment


                      • #12
                        Borje --

                        Remember, just 15 years ago the standard system was a 640k XT (an "8086") running DOS, with a mono screen, a 20 meg hard drive, a 5-inch floppy drive, no modem and no mouse.

                        Ten years ago most people were using using 286 or 386 systems, with DOS or maybe Windows 3.0.

                        Five years ago Windows 95 was just a few months old, and a 200 Mhz Pentium Pro was something you invited your friends over to see.

                        Today we have 1 GHz machines with multi-gig hard drives, Windows ME and 2000, and the growth of high-speed internet connections is following the same curve that everything else has followed.

                        Five years from now? I don't know if .NET or XP or anything else will still be around, but I am certain that things will be different than they are today. So unless you are writing software that you intend to have a lifespan of only a few years, IMO it is a mistake to base your plans on the current state of the world.

                        So when I read...

                        > more than 90% of all Internet connections are
                        > still via slow modems, and will be for many years
                        > to come,
                        so most people in real world won't be
                        > able to use XP and many of those .NET features at all.

                        ...it sounds very much like somebody saying "640k should be enough for anybody". (Sorry, couldn't resist. )

                        -- Eric


                        ------------------
                        Perfect Sync Development Tools
                        Perfect Sync Web Site
                        Contact Us: mailto:[email protected][email protected]</A>



                        [This message has been edited by Eric Pearson (edited May 13, 2001).]
                        "Not my circus, not my monkeys."

                        Comment


                        • #13
                          I am incline to agree with Borje about the average hardware
                          around the world, outside of some European countries and the US
                          bandwidth is expensive and unreliable and slow. try running streaming
                          video on a 28k connection and you will understand what the problem
                          is.

                          High end hardware belongs to the corporate sector and many developers
                          but assuming that smaller businesses and the consumer market have
                          the same is a mistake, many machines are not connected to the internet
                          at all as the users have no use for it.

                          Price fatigue is another factor, small business and the consumer
                          market generally object to repeatedly paying very high prices for
                          software that often does not work as well as their older stuff.

                          I deal with programmers around the world and in many places, a 133
                          meg pentium is classed as a good modern machine and generally they run
                          either win95 or perhaps win98 se if it does not bog the machine down
                          too much with its extra overhead.

                          I suggest that win9x will be around in large quantities for some years
                          to come as the later versions do not offer any great advantage in
                          functionality terms. NT4, win2k and later will be used by the corporate
                          sector as they become available but it is a mistake to assume that
                          the rest of the world can afford to follow.

                          Regards,

                          [email protected]

                          ------------------
                          hutch at movsd dot com
                          The MASM Forum

                          www.masm32.com

                          Comment


                          • #14
                            One should always try to keep up with latest technology, yes, but also
                            try to reason with intelligense. MS is not doing the later, if they
                            abandon majority and only target corporate users. But they probably
                            have a long term plan for it..

                            One interesting aspect is that a year ago, the IT hype was at its peek,
                            with companies building fortunes on promises. Today time has come to
                            fulfill their high promises and one by one goes down because dreams and
                            real life situations are not the same. Sweden is good example - "broadband
                            for all" was the promise and even the government poored enormous amounts
                            of taxpayer's money into the IT sector.

                            Today, most of those companies has gone bankrupt and not many broadband
                            projects are still alive. Several of my friends have lost their jobs in
                            that sector this spring and not many of the people I talk to has got what
                            they were promised to get long time ago, a working broadband connection.

                            This is why I have a gut feeling world economy is in for a rough ride
                            later on this year, when people discover MS' new system is not for
                            majority of current users. Maybe history is about to repeat itself.
                            Remember what happened to IBM some 15 years ago. Same thing may very
                            well happen to MS - when things start go wrong, it goes fast. Maybe
                            time finally is here for Linux.. so please - where is PB for LINUX?


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

                            Comment


                            • #15
                              Hutch --

                              I thought exactly the same thing a few years ago.

                              Meet you back here in five years and we'll see who's right.

                              -- Eric


                              ------------------
                              Perfect Sync Development Tools
                              Perfect Sync Web Site
                              Contact Us: mailto:[email protected][email protected]</A>



                              [This message has been edited by Eric Pearson (edited May 13, 2001).]
                              "Not my circus, not my monkeys."

                              Comment


                              • #16
                                One more point...

                                > I deal with programmers around the world
                                > and in many places, a 133 meg pentium is
                                > classed as a good modern machine and
                                > generally they run either win95 or perhaps
                                > win98 se if it does not bog the machine down
                                > too much with its extra overhead.

                                I agree, that's what most of the world is using. But that reinforces my point, rather than refuting it.

                                Just five years ago, those things were the state of the art! And today, it's an average system around the world.

                                Where will we be in five years?

                                -- Eric



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

                                Comment


                                • #17
                                  > Where will we be in five years?

                                  Gone fishing..


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

                                  Comment


                                  • #18
                                    I seem to agree with Borje in many things, going fishing appeals
                                    to me. In 5 years things will have changed a lot but its by no
                                    means predictable which way the change will go.

                                    In one direction the technology will be different and some of the
                                    newer ideas may be in production, memory technology has the promise
                                    of being many powers larger than current. We may see the end of
                                    Von Neuman logic in processing and the advent of "SMART" hardware,
                                    not just fast number crunchers.

                                    The other direction is not so rosy, cost and economic seperation
                                    has the potential to make the hardware too expensive for most people
                                    as the "Bill Gates" idea of a computer in every household slowly
                                    dies a natural death. As operating systems go in the direction of
                                    "web tv", the idea of a general purpose computer in the household
                                    that can be used for a wide range of things may eventually disappear.

                                    I personally came back to writing software to write flat memory model
                                    software as I had known of it since about 1990 in assembler. It has
                                    been a viable exercise and has earnt me a living but the corporate takeover
                                    of the software industry and the effective end of open system architecture
                                    is not something that has appealed to me.

                                    If the new stuff is genuinely smart and has the potential to do new and
                                    clever things, I may make another comeback but going fishing keeps
                                    sounding like a better option than the learning curve to absorb
                                    another set of badly documented APIs in an environment that is
                                    controlled to corporate advantage.

                                    Regards,

                                    [email protected]

                                    ------------------
                                    hutch at movsd dot com
                                    The MASM Forum

                                    www.masm32.com

                                    Comment

                                    Working...
                                    X