Originally posted by Rodney Hicks
View Post
Announcement
Collapse
No announcement yet.
GRAPHIC transparent background
Collapse
X
-
Originally posted by Chris Holbrook View PostI'm hoping to draw a rectangle into a GRAPHIC control with a transparent background so that it appears to frame the text contents of the control beneath it.
** edited - the bitmap is a red herring, just draw on the GRAPHIC but set the LABEL to have a transparent background. Code changed. Paul, this may do what you want but I don't know about printing it.**
Code:#PBFORMS CREATED V1.51 '------------------------------------------------------------------------------ ' The first line in this file is a PB/Forms metastatement. ' It should ALWAYS be the first line of the file. Other ' PB/Forms metastatements are placed at the beginning and ' end of "Named Blocks" of code that should be edited ' with PBForms only. Do not manually edit or delete these ' metastatements or PB/Forms will not be able to reread ' the file correctly. See the PB/Forms documentation for ' more information. ' Named blocks begin like this: #PBFORMS BEGIN ... ' Named blocks end like this: #PBFORMS END ... ' Other PB/Forms metastatements such as: ' #PBFORMS DECLARATIONS ' are used by PB/Forms to insert additional code. ' Feel free to make changes anywhere else in the file. '------------------------------------------------------------------------------ #COMPILE EXE #DIM ALL '------------------------------------------------------------------------------ ' ** Includes ** '------------------------------------------------------------------------------ #PBFORMS BEGIN INCLUDES #IF NOT %DEF(%WINAPI) #INCLUDE "WIN32API.INC" #ENDIF #IF NOT %DEF(%COMMCTRL_INC) #INCLUDE "COMMCTRL.INC" #ENDIF #INCLUDE "PBForms.INC" #PBFORMS END INCLUDES '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Constants ** '------------------------------------------------------------------------------ #PBFORMS BEGIN CONSTANTS %IDD_DIALOG1 = 101 %IDC_GRAPHIC1 = 1001 %IDC_LABEL1 = 1003 #PBFORMS END CONSTANTS '------------------------------------------------------------------------------ GLOBAL hBmp AS LONG '------------------------------------------------------------------------------ ' ** Declarations ** '------------------------------------------------------------------------------ DECLARE CALLBACK FUNCTION ShowDIALOG1Proc() DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG #PBFORMS DECLARATIONS '------------------------------------------------------------------------------ DECLARE SUB Circle (BYVAL hWnd AS LONG, BYVAL hDlg AS LONG) '------------------------------------------------------------------------------ ' ** Main Application Entry Point ** '------------------------------------------------------------------------------ FUNCTION PBMAIN() PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _ %ICC_INTERNET_CLASSES) ShowDIALOG1 %HWND_DESKTOP END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** CallBacks ** '------------------------------------------------------------------------------ CALLBACK FUNCTION ShowDIALOG1Proc() LOCAL ncW!, ncH! SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG ' Initialization handler GRAPHIC ATTACH CBHNDL, %IDC_GRAPHIC1 GRAPHIC WIDTH 2 GRAPHIC ELLIPSE (0, 0) - (90, 90),%RED ,-2, 0 CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL CASE %IDC_GRAPHIC1 END SELECT CASE %WM_CLOSE GRAPHIC ATTACH hBmp, 0 GRAPHIC BITMAP END END SELECT END FUNCTION '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Dialogs ** '------------------------------------------------------------------------------ FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG #PBFORMS BEGIN DIALOG %IDD_DIALOG1->-> LOCAL hDlg AS DWORD LOCAL hFont1 AS DWORD DIALOG NEW hParent, "Transparent", 165, 103, 201, 121, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR _ %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_CENTER OR %DS_3DLOOK OR _ %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO _ hDlg CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC1, "", 45, 10, 90, 80 CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "LABEL", 45, 10, 90, 85, %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER, %WS_EX_LEFT OR _ %WS_EX_LTRREADING CONTROL SET COLOR hDlg, %IDC_LABEL1, -1, -2 hFont1 = PBFormsMakeFont("MS Sans Serif", 24, 400, %FALSE, %FALSE, %FALSE, %ANSI_CHARSET) CONTROL SEND hDlg, %IDC_LABEL1, %WM_SETFONT, hFont1, 0 #PBFORMS END DIALOG DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt #PBFORMS BEGIN CLEANUP %IDD_DIALOG1 DeleteObject hFont1 #PBFORMS END CLEANUP FUNCTION = lRslt END FUNCTION '------------------------------------------------------------------------------------------------
Last edited by Chris Holbrook; 9 Dec 2007, 08:13 AM.
Leave a comment:
-
I would like to type over a graphic document and print out both the typed information and graphic document.
something along the lines of a free style form fill.
Is that what is being discussed here.
paul
Leave a comment:
-
Have you tried CONTROL ADD LINE, hDlg, id&, "",x,y,xx,yy, %style
You can create a rectangle with it using a value two dialog units > the height and width of your control that your surrounding
x and y should be offset -1 from the original controls.
It won't create a very thick frame, but it will be obvious to the user.
Rod
Leave a comment:
-
Originally posted by Chris Boss View PostIt can't be transparent normally.
Leave a comment:
-
The PB Graphic control is simply an OwnerDraw Static control.
It can't be transparent normally. The WS_EX_TRANSPARENT extended window style only works with control classes you create, where you draw in WM_PAINT, but not WM_ERASEBKGND. This control extended style tends to flicker when drawing, because Windows draws all other controls first and then the ones with the WS_EX_TRANSPARENT extended style last.
To accomplish what you want, could be done, using a custom control class with the WS_EX_TRANSPARENT extended style.
A better way, IMO, would be to use the graphic control on top of the other control, but use a region to make the control non-rectangular (meaning a hollow center).
You can use the SetWindowRgn API function to pass a Region handle to the Graphic control to change its shape.
The CreateRectRgn function can be used to create rectangular regions. To produce the hollow effect (a rectangle with the center transparent), requires combining multiple regions to produce the effect you want. Use the CombineRgn function to do this.
Regions can be used to produce round controls, controls with sections within it being transparent.
The beauty of regions is that the transparent parts are more than just transparent. They simply don't exist. This means when a mouse button is clicked on the transparent part, it is clicked on whatever is underneath.
Leave a comment:
-
GRAPHIC transparent background
I'm hoping to draw a rectangle into a GRAPHIC control with a transparent background so that it appears to frame the text contents of the control beneath it. Both the GRAPHIC and the LABEL beneath it are siblings and the parent dialog is of the same dimensions as the two controls The resulting GRAPHIC doesn't seem to be transparent:
Code:CASE %WM_EXITSIZEMOVE DIALOG GET SIZE CBHNDL TO W, H DIALOG GET LOC CBHNDL TO X, Y CONTROL SET SIZE CBHNDL, %IDC_LABEL, w, h CONTROL KILL CBHNDL, %IDC_GRAPHIC' in case dialog was resized CONTROL ADD GRAPHIC, CBHNDL, %IDC_GRAPHIC, "", 0, 0, W, H GRAPHIC ATTACH CBHNDL, %IDC_GRAPHIC GRAPHIC COLOR %RED, -2 GRAPHIC BOX (5,5) - (W-5, H-5),0,%RED,-2
Tags: None
Leave a comment: