has anyone ever used drawcaption win23api
Announcement
Collapse
No announcement yet.
DrawCaption
Collapse
X
-
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
-
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
-
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
-
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.
Comment
Comment