Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
transparent dialog
#1
is there a way i can make my dialog transparent so you can only see the buttons i tried WS_INVISIBLE but it kinda messed up
#2
Function dlg_transparent
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dlg_transparent" &dlg_transparent)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030008 "*" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,__GdiHandle-- hb=CreateSolidBrush(0xff00)
,Transparent hDlg 255 0xff00
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CTLCOLORDLG
,ret hb
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#3
perfect thx
#4
This makes the dialog completely disappear...except for the buttons!
0 "" 0x80000840 0x0 0 0 227 154 "Dialog"

This is very neat! Thanks Gintaras!
#5
yah this works so its invisible

but what about getting rid of the dialog box on the toolbar of ur computer

so that way u just see the buttons and no dialog box on the bottom taking up space?
#6
what dialog box?
#7
like at the bottom of computer where it shows what programs are open

it shows Dialog and Quick Macros Forum

is there a way dialog does not show but the buttons still do?
#8
I think no.
#9
i think this is what you mean
Function dlg_transparent
Code:
Copy      Help
;0 "" 0x80000840 0x90 0 0 227 154 "Dialog"
where there is no shell tray button
#10
Happy New Year to Gintaras and whole forum!
I wonder if it is possible to have a control (pushbutton autocheckbox) that toggles the transparency of the dlg without becoming transparent itself - so visible enough to turn transparency off.
I could I geuss do this with a separate child dialog but then would have to reposition it if the dialog moves so better if more integrated.
Maybe there is a simpler way with applying brush to one control or something.
Hoping there is something simple/elegant to accomplish this that I can't think of.
Thanks so much,
S

Function dlg_transparent_with_control
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "4 5 6"
str e4 lb5 c6Tra
if(!ShowDialog("dlg_transparent_with_control" &dlg_transparent_with_control &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A48 0x100 0 0 223 135 "Dialog"
;3 Button 0x54032000 0x0 2 28 48 14 "Button"
;4 Edit 0x54030080 0x200 4 48 96 14 ""
;5 ListBox 0x54230101 0x200 108 34 96 48 ""
;6 Button 0x54031003 0x0 0 0 90 16 "Transparent"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,;__GdiHandle-- hb=CreateSolidBrush(0xff00)
,;Transparent hDlg 255 0xff00
,case WM_DESTROY
,case WM_COMMAND goto messages2
,;case WM_CTLCOLORDLG
,;ret hb
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 6
,,if(but(lParam))
,,,Transparent hDlg 50 0xff00
,,else
,,,Transparent hDlg 255 0xff00
ret 1
#11
Function dlg_transparent_with_control
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80A48 0x100 0 0 223 135 "Dialog"
;3 Button 0x54032000 0x0 2 28 48 14 "Button"
;4 Edit 0x54030080 0x200 4 48 96 14 ""
;5 ListBox 0x54230101 0x200 108 34 96 48 ""
;6 Button 0x54031003 0x0 0 0 90 16 "Transparent"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "*" "" "" ""

str controls = "4 5 6"
str e4 lb5 c6Tra
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 6
,,if(but(lParam))
,,,sub.Transparent hDlg 1 lParam
,,else
,,,sub.Transparent hDlg 0
ret 1


#sub Transparent
function hwnd trans [hwndButton]

if(!trans)
,SetWindowRgn hwnd 0 1
,ret

RECT rw rb
GetWindowRect hwndButton &rb
GetWindowRect hwnd &rw
OffsetRect &rb -rw.left -rw.top

int hr=CreateRectRgnIndirect(&rb)
SetWindowRgn hwnd hr 1
#12
Thank you Gintaras! I see that this bypassed the whole method of transparency by essentially making the whole window the RECT of the control. Elegant and effective (and super quick response!). Amazing!
I will assume however that it therefore is much more complicated to do this while allowing for variable transparency of the rest of the dialog elements, rather than complete transparency (invisible, pass through clicks, etc).
I imagine I could do this by having the transparency control be part of a child dialog like below but if WS_CHILD is added it will inherit the transparency level. If I take that out, it works, but then I have to write Positioner WM_TIMER function. Is this the correct approach to this or is there a way that it can behave like a WS_CHILD in terms of positioning but no in inheritance of transparency?
Thanks again for any thoughts or assurances that I am taking the right approach,
S

Function ParentDialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "5 6"
str e5 lb6
if(!ShowDialog("ParentDialog" &ParentDialog &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A48 0x10100 0 0 221 159 "ParentDialog"
;5 Edit 0x54030080 0x200 22 42 96 14 ""
;6 ListBox 0x54230101 0x200 58 70 96 48 ""
;1 Button 0x54030001 0x4 120 140 48 14 "OK"
;2 Button 0x54030000 0x4 170 140 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""

ret
;messages

sel message
,case WM_INITDIALOG
,__GdiHandle-- hb=CreateSolidBrush(0xff00)
,Transparent hDlg 255 0xff00
,ControlChildDlg(0 0 hDlg 0)
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CTLCOLORDLG
,ret hb
ret
;messages2
sel wParam
,case IDOK

,
,case IDCANCEL
ret 1

Function ControlChildDlg
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "5"
str c5Tra
sel message
,case 0 ;;on WM_INITDIALOG of the parent dialog
,ret ShowDialog("" &ControlChildDlg &controls wParam 1 WS_CHILD 0 0 2 lParam)
,case 1 ;;on OK of the parent dialog
,hDlg=lParam
,DT_GetControls hDlg &controls
,out c5Tra

;BEGIN DIALOG
;0 "" 0x10000648 0x0 0 0 51 14 ""
;5 Button 0x54031003 0x0 2 0 48 14 "Transparency"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 5
,,int hParentDlg = win("ParentDialog" "#32770")
,,if(but(lParam))
,,,Transparent hParentDlg 50 0xff00
,,else
,,,Transparent hParentDlg 255 0xff00
ret 1
#13
I think that child windows cannot be less transparent than parent. Windows 10 supports transparency of child windows, but I did not test, probably can only make more transparent than parent. Try to find something in stackoverflow etc.
#14
ok thanks. My dialogs need to work on Win7 so will try to make with positioner function.
Thanks again!,
S

looked on StackOverflow and didn't see a better way than my proposed method. It works - see below!
Thanks again for talking me through this!
S

Function ParentDialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "5 6"
str e5 lb6
if(!ShowDialog("ParentDialog" &ParentDialog &controls)) ret

;BEGIN DIALOG
;0 "" 0x90880A48 0x10300 0 0 222 173 "ParentDialog"
;5 Edit 0x54030080 0x200 22 42 96 14 ""
;6 ListBox 0x54230101 0x200 58 70 96 48 ""
;3 Button 0x54030040 0x0 126 0 96 24 "Grab To Move"
;1 Button 0x54030001 0x4 120 140 48 14 "OK"
;2 Button 0x54030000 0x4 170 140 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""

ret
;messages

sel message
,case WM_INITDIALOG
,ont hDlg
,__GdiHandle-- hb=CreateSolidBrush(0xff00)
,Transparent hDlg 255 0xff00
,int- ChildDlgHwnd = ControlChildDlg(0 0 hDlg 0)
,out _s.getwintext(ChildDlgHwnd)    
,DialogDragSubclassControl id(3 hDlg) ;;subclass button 3
,SetTimer hDlg 1 10 0
,case WM_DESTROY
,case WM_TIMER
,,int x_Child y_Child
,,int x_Parent y_Parent
,,GetWinXY ChildDlgHwnd x_Child y_Child 0 0 hDlg
,,GetWinXY hDlg x_Parent y_Parent
,,if x_Child != x_Parent and y_Child != y_Parent
,,,mov x_Parent y_Parent ChildDlgHwnd        
,case WM_COMMAND goto messages2
,case WM_CTLCOLORDLG
,ret hb
ret
;messages2
sel wParam
,case IDOK    
,case IDCANCEL
ret 1

Function ControlChildDlg
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "5"
str c5Tra
sel message
,case 0 ;;on WM_INITDIALOG of the parent dialog
,ret ShowDialog("" &ControlChildDlg &controls wParam 1 WS_CHILD 0 0 2 lParam)
,case 1 ;;on OK of the parent dialog
,hDlg=lParam
,DT_GetControls hDlg &controls
,out c5Tra

;BEGIN DIALOG
;0 "" 0x90080A48 0x0 0 0 51 14 "ChildDlg"
;5 Button 0x54031003 0x0 2 0 48 14 "Transparency"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,,DialogDragSubclassControl id(5 hDlg) ;;subclass button 3
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 5
,,int hParentDlg = win("ParentDialog" "#32770")
,,if(but(lParam))
,,,Transparent hParentDlg 50 0xff00
,,else
,,,Transparent hParentDlg 255 0xff00
ret 1


Forum Jump:


Users browsing this thread: 1 Guest(s)