Announcement

Collapse
No announcement yet.

Hellowin.exe Sample Bug

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

  • Hellowin.exe Sample Bug

    Hello,

    I have tested this on a 486 with win95, K6II with win98SE and dual monitors, and a K6II with winNT4 SP3. All three have the same result.

    If you open up the Hellowin.exe Sample program with your taskbar on Autohide, maximize the Hellowin program, touch the taskbar and move away from it, then the text in the Hellowin program disappears and will not reappear until the window is send another %WM_PAINT message.

    I am having the exact same problem in my own program which is to be used on an a projector, thus I would like to have the taskbar on Autohide to give me a full screen with out having to do anything too fancy. But it is unacceptable for all the text to simply disappear when the user moves the mouse to the bottom of the screen!

    Can anyone offer a reason for this and a possible solution. As far as everything I have read goes, this sample code should be correct.

    Thanks,

    -------------
    Colin Schmidt & James Duffy, Praxis Enterprises, Canada

  • #2
    History repeats. "Sorry, but only forum leaders are permitted to delete posts."

    [This message has been edited by Semen Matusovski (edited January 18, 2000).]

    Comment


    • #3
      Hello. First of all, thanks for your reply.

      Second, sorry, didn't work. Same thing still on my end anyways. Did you test this and have it work for you?

      This is what I have:

      CASE %WM_PAINT
      GetClientRect hWnd, tRect
      hDC = BeginPaint(hWnd, LpPaint)
      SetBkMode hDC, %TRANSPARENT
      SetTextColor hDC, %WHITE
      DrawText hDC, "Hello, Windows 95!", -1, tRect, %DT_SINGLELINE _
      OR %DT_CENTER OR %DT_VCENTER
      EndPaint hWnd, LpPaint
      FUNCTION = 0
      EXIT FUNCTION

      Thanks,

      -------------
      Colin Schmidt & James Duffy, Praxis Enterprises, Canada


      [This message has been edited by Colin Schmidt (edited January 18, 2000).]

      Comment


      • #4
        Hello, again, thanks, but I'm having no luck.

        I pasted you code in straight, but still had the same problem. I have not edited any other part of the original code.

        Any ideas?

        Thanks,

        -------------
        Colin Schmidt & James Duffy, Praxis Enterprises, Canada

        Comment


        • #5
          Colin --
          I looked closely (Win98SE). Sometimes disappears and I returned to previous
          Code:
             Case %WM_PAINT
                  hDC = BeginPaint(hWnd, LpPaint)
                  GetClientRect hWnd, tRect
                  hDC = GetDC(hWnd) ' <---
                  SetBkMode hDC, %TRANSPARENT
                  SetTextColor hDC, %WHITE
                  DrawText hDC, "Hello, Windows 95!", -1, tRect, %DT_SINGLELINE Or %DT_CENTER Or %DT_VCENTER
                  ReleaseDC hWnd, hDC ' <---
                EndPaint hWnd, LpPaint
                Function = 0
                Exit Function
          I opened source (C) code -- Petzold (5th ed., p.45-46)
          Looks like translated "word to word". So, nothing clear, except that something wrong (perhaps, in C-code)

          [This message has been edited by Semen Matusovski (edited January 18, 2000).]

          Comment


          • #6
            THANKS! It works!

            Do you know why BeginPaint did not return the correct DC handle in this case? I'm assumming that this is a Microsoft API bug as opposed to PowerBASIC.

            Thanks,

            -------------
            Colin Schmidt & James Duffy, Praxis Enterprises, Canada

            Comment


            • #7
              Why it's works (at least, it seems to me also) - no idea. I simply looked at SUB Drawgradient.

              Comment


              • #8
                An interesting "feature"!

                I checked this out on my machine with NT4.
                Occasionally, the text vanishes when the window is moved,
                even with the additional code.

                I had to change the CASE statement to
                CASE %WM_PAINT, %WM_MOVE
                to clear up the situation.

                Regards,
                [email protected]
                :) IRC :)

                Comment


                • #9
                  Forget the WM_PAINT event, you are being mislead by the symptom.

                  The actual problem is a bug in the code... the DrawGradient() routine is overwriting the text when the background is updated (ie, when the taskbar is hidden).

                  What seems complicated is actually very simple - DrawGradient should be using the DC it is given instead of obtaining a new DC, thus:

                  1. Change the %WM_ERASEBKGND handler to:
                  Code:
                      CASE %WM_ERASEBKGND
                        hDC = wParam
                        DrawGradient hDC              ' Pass the DC of the region to repaint
                        FUNCTION = 1
                        EXIT FUNCTION
                  2. Change the DrawGradient() function to:
                  Code:
                  SUB DrawGradient(BYVAL hDC AS LONG)
                    LOCAL rectFill AS RECT
                    LOCAL rectClient AS RECT
                    LOCAL fStep AS SINGLE
                    LOCAL hBrush AS LONG
                    LOCAL iOnBand AS INTEGER
                   
                    GetClientRect WindowFromDC(hDC), rectClient
                    fStep = rectClient.nbottom / 200
                   
                    FOR iOnBand = 0 TO 199
                      SetRect rectFill, 0, iOnBand * fStep, rectClient.nright+1, (iOnBand+1) * fStep
                      hBrush = CreateSolidBrush(RGB(0,0,(255-iOnBand)))
                      Fillrect hDC, rectFill, hBrush
                      DeleteObject hBrush
                    NEXT
                  END SUB
                  Forcing a repaint just because the window moves is an "unusual" solution

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

                  Comment


                  • #10
                    Hello,

                    Just of note, a week ago I mentioned this same problem, I also mentioned that I believed that this was caused by the DrawGradient routine, but that I had no Idea why... No one ever responded to it so I just believed that I was way out in left field. Oh well.

                    Anyways, what I actually wanted to say was thanks to Lance and Semen.

                    -------------
                    Colin Schmidt & James Duffy, Praxis Enterprises, Canada

                    Comment

                    Working...
                    X