Announcement

Collapse
No announcement yet.

DrawCaption

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

  • DrawCaption

    has anyone ever used drawcaption win23api

  • #2
    Yes
    Walt Decker

    Comment


    • #3
      do you have an example i do not understand how you tie it any thing thanks

      Comment


      • #4
        in your callback function under CASE %WM_PAINT

        Code:
        CASE %WM_PAINT
          winDC = getwindowdc(Hndl)
          I = FN_drawcaption(Hndl, HndlDc)
        END FUNCTION
        
        
        '------------------------------------------------------------------------------
        FUNCTION FN_DrawCaption(BYVAL WinHndl AS DWORD, BYVAL WinDc AS DWORD, _
          OPTIONAL BYVAL More AS DWORD) AS LONG
        
        LOCAL SzxBorder, _
              SzyBorder, _
                SzxIcon, _
                SzyIcon, _
                 SzxBtn, _
                 SzyCap, _
                 SzxChr, _
                 SzxFit, _
                    Pen, _
                 OldPen, _
                  Brush, _
                 Obrush, _
                NumChrs       AS LONG
        
        LOCAL DwStyle         AS DWORD
        
        LOCAL CapTxt          AS STRING
        
        LOCAL ZcapTxt         AS ASCIIZ * 64
        
        LOCAL tPnt            AS Point_Struct
        LOCAL tRect           AS Rect_Struct
        
        DwStyle = %DC_ICON OR %DC_TEXT OR %DC_BUTTONS'OR %DC_GRADIENT  OR %DC_SMallCaP
        
        IF More THEN
          DwStyle = DwStyle OR %DC_ACTIVE OR %DC_GRADIENT
        END IF
        
        SzyCap = getsystemmetrics(%SM_CYCAPTION)
        SzyBorder = getsystemmetrics(%SM_CYFRAME)
        SzxBorder = getsystemmetrics(%SM_CXFRAME)
        SzxIcon = getsystemmetrics(%SM_CXICON)
        SzyIcon = getsystemmetrics(%SM_CYICON)
        SzxBtn  = getsystemmetrics(%SM_CXSIZE)
        
        Getwindowrect(WinHndl, VARPTR(tRect))
        mapwindowpoints(0, winHndl, VARPTR(tRect), 2)
        '
        SzxFit = (tRect.X1 - tRect.X)
        tRect.X = tRect.X + SzyBorder * 2
        tRect.Y = tRect.Y + SzxBorder + SzyIcon
        tRect.X1 = SzxFit - SzxBtn * 3 - 2
        tRect.Y1 = SzyCap + SzxBorder
        
        drawcaption(WinHndl, WinDc, VARPTR(tRect), DwStyle)
        
        END FUNCTION
        Walt Decker

        Comment


        • #5
          thanks will try

          Comment


          • #6
            i need to know more
            Local CapTxt As String

            Local ZcapTxt As Asciiz * 64

            Local tPnt
            i need to add text and color
            thanks

            Comment


            • #7
              Mr. Morgan:

              I should have shown more under WM_PAINT

              Code:
              CASE %WM_PAINT
                beginpaint(Hndl, tPaint)
                  WinDc  = getwindowdc(Hndl)
                  I = FN_drawcaption(Hndl, WinDc)
                  deletedc(Hndl, WinDc)
                endpaing(Hndl, tPaint)
              Walt Decker

              Comment


              • #8
                What do you mean by "need to add text and color?"

                If you want to change the caption heading use setwindowtext() api
                if you need to change the color of the title bar that can be done with fillrect() api, but you will have to set the rectangle smaller than the icon and the minimize button otherwise you will have to do the whole thing under, I think it is WM_NCPAINT and place the icon and system buttons where they should be.

                PS:

                Is the window a DDT child window with a caption? If so you can sendmessage(WinHndl, %WM_ACTIVATE, 1, 0) and the title bar color will automatically change from inactive to active without using drawcaption. Also you can DIALOG SET TEXT Hndl, Text$ to change the title bar text.
                Last edited by Walt Decker; 5 Nov 2020, 11:47 PM.
                Walt Decker

                Comment


                • #9
                  Originally posted by James C Morgan View Post
                  i need to know more
                  Local CapTxt As String
                  Local ZcapTxt As Asciiz * 64
                  Local tPnt
                  None of those variables are used. Neither are
                  SzxChr, _ Pen, _ OldPen, _ Brush, _ Obrush, _ NumChrs

                  Why are they included in the example code?

                  Comment


                  • #10
                    SzxChr, _ Pen, _ OldPen, _ Brush, _ Obrush, _ NumChrs
                    because that is a cutdown version of the more complex function.

                    Mr. Morgan asked for an example of drawcaption() only. He did not state the system he is using (api or ddt) nor any of his needs in post #1
                    Walt Decker

                    Comment


                    • #11
                      I sorry i did not state every thing i needed
                      i am always learning.
                      I am wanting to change the color background and foreground. in the caption

                      i have been looking at this.

                      Is the window a DDT child window with a caption? Yes If so you can sendmessage(WinHndl, %WM_ACTIVATE, 1, 0) and the title bar color will automatically change from inactive to active without using drawcaption. Then what? i am running win 10 64
                      and pbwin 10.03 i have tried syscolors
                      I understand this----Also you can DIALOG SET TEXT Hndl, Text$ to change the title bar text.

                      again Thanks

                      Comment


                      • #12
                        I am wanting to change the color background and foreground. in the caption
                        Mr. Morgan:

                        You should do that with the %WM_NCPAINT message. I do not have an example handy. Search the forum for %WM_NCPAINT or perhaps caption buttons. I will check my archives for an example.
                        Walt Decker

                        Comment


                        • #13
                          Some background may be helpful here:

                          Windows has all sorts of built in UI elements. I don't mean the controls or windows themselves, but API's to draw such elements. Whether it be a button, checkbox, frame, window borders, caption bar, etc.there is an API to draw it. Now the normal GDI API's which do this are for the old style look of Windows, not the more modern Themed look. If you want to draw such UI elements and to have that old style (Windows 95/98) look that is fine, but it won't give you the modern themed look. For that you have to call the API's in the Windows system Theme DLL, not the GDI. Interestingly for most of the old style UI elements, there is a modern Theme version to draw it. A Themed button, Themed Checkbox, Themed caption bar, etc.

                          The OS Theme DLL is:

                          UXTHEME.DLL

                          I built in a Theme drawing engine in EZGUI 5.0 and here are the following Theme API's I use:

                          IsAppThemed
                          IsThemeActive
                          SetWindowTheme
                          OpenThemeData
                          CloseThemeData
                          DrawThemeBackground
                          DrawThemeEdge


                          There are others, but this does most of what I needed.

                          I found that rather than statically link ones app to the Theme OS DLL, I prefer to use the LoadLibrary API to load the DLL and then the GetProcAddress API to get a pointer to the Theme API's. Then I use CALL DWORD to make the calls.

                          The reason for this is that EZGUI is backward compatible with most versions of Windows such as Windows 95/98/ME, XP, Vista, 7 and 8. This way I can use it even on a system that does not support Themes. You can though simply statically declare the API's if you wish, since most software will be used today on a version of Windows which supports Themes.

                          Remember though that you have to test to see if Themes are turned off on the end user system when using Theme drawing API's. If turned off, then you have to use an alternate GDI call to draw the API elements. That is what I do in EZGUI. My drawing commands can draw UI elements, but depending upon whether the app has Themes ON or OFF, I use the appropriate calls.

                          If you want to custom draw UI stuff which looks modern you really need to look into the Theme API's.
                          Chris Boss
                          Computer Workshop
                          Developer of "EZGUI"
                          http://cwsof.com
                          http://twitter.com/EZGUIProGuy

                          Comment

                          Working...
                          X