Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SysTabControl32 and Background image
#1
Testing dlg_multipage_with_tab_control example from arhieve.
Resized it so have some stuff outside of SysTabControl32 now (on default nonumber page).
If i try to add background image (bitmap) over whole field it hides tab panel independently if i add bitmap or SysTabControl32 first.
Ofc i can make it with 4 bitmap rectangles around tabcontrol, but it requires manual tiling of images and 4 images also and cant change background on the fly.
Any way to go?
#2
You probably use a static bitmap control to display the background image. Instead use function DT_SetBackgroundImage.

Function dlg_multipage_with_tab_control2
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 163 "Form"
;1001 Button 0x54032000 0x0 28 28 48 14 "Button"
;1002 Edit 0x54030080 0x200 28 48 96 12 ""
;1003 Button 0x50012003 0x0 28 68 48 10 "Check"
;1004 Static 0x54000000 0x0 28 84 48 13 "Text"
;1101 Static 0x44020000 0x4 104 62 48 13 "Page1"
;1201 Static 0x44020000 0x4 110 70 48 13 "Page2"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;3 SysTabControl32 0x54000040 0x0 16 8 232 120 ""
;5 Static 0x54000010 0x20004 4 138 257 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "" "0" "" ""

if(!ShowDialog(dd &sub.DlgProc)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,
,DT_SetBackgroundColor hDlg 1 0x80e0a0 0x80e0e0
,;DT_SetBackgroundImage hDlg "$my qm$\Copy.jpg"
,
,int htb=id(3 hDlg)
,TCITEM ti.mask=WINAPI.TCIF_TEXT
,ti.pszText="A"
,SendMessage htb WINAPI.TCM_INSERTITEMA 0 &ti
,ti.pszText="B"
,SendMessage htb WINAPI.TCM_INSERTITEMA 1 &ti
,ti.pszText="C"
,SendMessage htb WINAPI.TCM_INSERTITEMA 2 &ti
,
,DT_Page hDlg 0
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case WINAPI.TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom WINAPI.TCM_GETCURSEL 0 0)
,DT_Page hDlg _i

However some controls have incorrect background color when tab background color is different than dialog color. Need a child dialog and function EnableThemeDialogTexture.

Function dlg_multipage_with_tab_control3
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 163 "Form"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;3 SysTabControl32 0x54030040 0x0 16 8 232 120 ""
;5 Static 0x54000010 0x20004 4 138 257 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "" "0" "" ""

if(!ShowDialog(dd &sub.DlgProc)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,
,DT_SetBackgroundColor hDlg 1 0x80e0a0 0x80e0e0
,;DT_SetBackgroundImage hDlg "$my qm$\Copy.jpg"
,
,int htb=id(3 hDlg)
,TCITEM ti.mask=WINAPI.TCIF_TEXT
,ti.pszText="A"
,SendMessage htb WINAPI.TCM_INSERTITEMA 0 &ti
,ti.pszText="B"
,SendMessage htb WINAPI.TCM_INSERTITEMA 1 &ti
,ti.pszText="C"
,SendMessage htb WINAPI.TCM_INSERTITEMA 2 &ti
,
,int hDlg0=sub.Dialog2(hDlg)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case WINAPI.TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom WINAPI.TCM_GETCURSEL 0 0)
,DT_Page id(99 hDlg) _i


#sub Dialog2
function# [hwndOwner]

str dd=
;BEGIN DIALOG
;0 "" 0x50000448 0x0 20 26 130 94 "Dialog"
;1003 Edit 0x54030080 0x200 16 24 96 12 ""
;1004 Button 0x54032000 0x0 16 40 48 14 "Button"
;1005 Button 0x54012003 0x0 16 60 48 10 "Check"
;1006 Static 0x54000000 0x0 16 8 48 12 "Page0"
;1106 Static 0x54000000 0x0 16 8 48 12 "Page1"
;1206 Static 0x54000000 0x0 16 8 48 12 "Page2"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "0" "" ""

str controls = "1003 1005"
str e1003 c1005Che
ret ShowDialog(dd &sub.DlgProc2 &controls hwndOwner 0x101)


#sub DlgProc2
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SetWindowLong hDlg GWL_ID 99
,EnableThemeDialogTexture hDlg ETDT_ENABLETAB
,DT_Page hDlg 0
,SetFocus id(1003 hDlg)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

To set child dialog position here I use this:
BEGIN DIALOG
0 "" 0x50000448 0x0 20 26 130 94 "Dialog"
...
ret ShowDialog(dd &sub.DlgProc2 &controls hwndOwner 0x101)
#3
Nice, thx a lot.
#4
With DT_SetBackgroundColor seems like it rewrites whole area once you move dialog window to a new position on screen (when u run dialog in usual mode and not in editor). This is a bit annoying blinking of all controls :? And yeah i used static bitmap control previously for background, no such effect with it except it goes over SysTabControl32
#5
I tested static bitmap control, it does not hide SysTabControl32 if it is below in Z order.

hides:
6 Static 0x5400000E 0x0 4 40 252 112 ""
3 SysTabControl32 0x54000040 0x0 16 8 232 120 ""

does not:
3 SysTabControl32 0x54000040 0x0 16 8 232 120 ""
6 Static 0x5400000E 0x0 4 40 252 112 ""
#6
Oh really, did not think it is important Smile Thx! Igot the advantage about DT_SetBackgroundImage as i can rewrite background of static text controls for example, tho blinking...Smile
#7
How can i access to c1005Che chexbox state from main dialog in dlg_multipage_with_tab_control3 example above?

for example if i add button in main dialog and use
Code:
Copy      Help
,case <button id>
,,if IsDlgButtonChecked(hDlg0 1005)
,,,out "1"
,,else
,,,out "0"
it doesnt seem to work
#8
hDlg0=id(99 hDlg)
#9
How to get control variables of this 2nd dialog after dialog procedure?
#10
With 2 dialogs it is difficult. I found a way to display controls correctly with 1 dialog. Use EnableThemeDialogTexture for dialog, and draw dialog background on WM_PAINT.

Function dlg_multipage_with_tab_control5
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 163 "Form"
;1001 Button 0x54032000 0x0 28 28 50 16 "Button"
;1002 Edit 0x54030080 0x200 28 48 96 12 ""
;1003 Button 0x54012003 0x0 28 68 48 10 "Check"
;1004 Static 0x54000000 0x0 28 84 48 13 "Text"
;1101 Static 0x44020000 0x4 104 62 48 13 "Page1"
;1201 Static 0x44020000 0x4 110 70 48 13 "Page2"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;3 SysTabControl32 0x54000040 0x0 16 8 232 120 ""
;5 Static 0x54000010 0x20004 4 138 257 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "" "0" "" ""

if(!ShowDialog(dd &sub.DlgProc 0 _hwndqm)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,
,EnableThemeDialogTexture hDlg ETDT_ENABLETAB
,
,int htb=id(3 hDlg)
,TCITEM ti.mask=TCIF_TEXT
,ti.pszText="A"
,SendMessage htb TCM_INSERTITEMA 0 &ti
,ti.pszText="B"
,SendMessage htb TCM_INSERTITEMA 1 &ti
,ti.pszText="C"
,SendMessage htb TCM_INSERTITEMA 2 &ti
,
,DT_Page hDlg _i
,
,case WM_PAINT
,;draw dialog background here
,
,;first time create brush
,__GdiHandle- brush hbm
,int useBmp=1 ;;if 0, use color
,if !brush
,,if useBmp
,,,hbm=LoadPictureFile("$my qm$\Copy.jpg")
,,,brush=CreatePatternBrush(hbm)
,,else
,,,brush=CreateSolidBrush(0xc0ffff)
,
,;then fill background with the brush
,PAINTSTRUCT ps; BeginPaint hDlg &ps
,RECT r; GetClientRect hDlg &r
,FillRect ps.hDC &r brush
,EndPaint hDlg &ps
,
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom TCM_GETCURSEL 0 0)
,DT_Page hDlg _i
#11
There is no background in tabs then :?
#12
Make tab control small.
Function dlg_multipage_with_tab_control6
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 163 "Form"
;1001 Button 0x54032000 0x0 28 28 50 16 "Button"
;1002 Edit 0x54030080 0x200 28 48 96 12 ""
;1003 Button 0x54012003 0x0 28 68 48 10 "Check"
;1004 Static 0x54000000 0x0 28 84 48 13 "Text"
;1101 Static 0x44020000 0x4 104 62 48 13 "Page1"
;1201 Static 0x44020000 0x4 110 70 48 13 "Page2"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;3 SysTabControl32 0x54000040 0x0 16 8 232 14 ""
;5 Static 0x54000010 0x20004 4 138 257 1 ""
;6 Button 0x54020007 0x0 16 8 232 112 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "" "0" "" ""

if(!ShowDialog(dd &sub.DlgProc)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,
,DT_SetBackgroundColor hDlg 1 0x80e0a0 0x80e0e0
,;DT_SetBackgroundImage hDlg "$my qm$\Copy.jpg"
,
,int htb=id(3 hDlg)
,TCITEM ti.mask=WINAPI.TCIF_TEXT
,ti.pszText="A"
,SendMessage htb WINAPI.TCM_INSERTITEMA 0 &ti
,ti.pszText="B"
,SendMessage htb WINAPI.TCM_INSERTITEMA 1 &ti
,ti.pszText="C"
,SendMessage htb WINAPI.TCM_INSERTITEMA 2 &ti
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case WINAPI.TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom WINAPI.TCM_GETCURSEL 0 0)
,DT_Page hDlg _i

Or add a big static control.
Function dlg_multipage_with_tab_control7
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 163 "Form"
;1001 Button 0x54032000 0x0 28 28 50 16 "Button"
;1002 Edit 0x54030080 0x200 28 48 96 12 ""
;1003 Button 0x54012003 0x0 28 68 48 10 "Check"
;1004 Static 0x54000000 0x0 28 84 48 13 "Text"
;1101 Static 0x44020000 0x4 104 62 48 13 "Page1"
;1201 Static 0x44020000 0x4 110 70 48 13 "Page2"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;6 Static 0x54000000 0x0 24 24 216 90 ""
;3 SysTabControl32 0x54000040 0x0 16 8 232 112 ""
;5 Static 0x54000010 0x20004 4 138 257 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "" "0" "" ""

if(!ShowDialog(dd &sub.DlgProc)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,
,DT_SetBackgroundColor hDlg 1 0x80e0a0 0x80e0e0
,;DT_SetBackgroundImage hDlg "$my qm$\Copy.jpg"
,
,int htb=id(3 hDlg)
,TCITEM ti.mask=WINAPI.TCIF_TEXT
,ti.pszText="A"
,SendMessage htb WINAPI.TCM_INSERTITEMA 0 &ti
,ti.pszText="B"
,SendMessage htb WINAPI.TCM_INSERTITEMA 1 &ti
,ti.pszText="C"
,SendMessage htb WINAPI.TCM_INSERTITEMA 2 &ti
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case WINAPI.TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom WINAPI.TCM_GETCURSEL 0 0)
,DT_Page hDlg _i
#13
oh this is great idea thx! :mrgreen:
#14
Is there any way to make gradient in dlg_multipage_with_tab_control5 ?
#15
Function dlg_multipage_with_tab_control8
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x10C80A48 0x100 0 0 265 163 "Form"
;1001 Button 0x54032000 0x0 28 28 50 16 "Button"
;1002 Edit 0x54030080 0x200 28 48 96 12 ""
;1003 Button 0x54012003 0x0 28 68 48 10 "Check"
;1004 Static 0x54000000 0x0 28 84 48 13 "Text"
;1101 Static 0x44020000 0x4 104 62 48 13 "Page1"
;1201 Static 0x44020000 0x4 110 70 48 13 "Page2"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;3 SysTabControl32 0x54000040 0x0 16 8 232 120 ""
;5 Static 0x54000010 0x20004 4 138 257 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "" "0" "" ""

if(!ShowDialog(dd &sub.DlgProc 0 _hwndqm)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,
,EnableThemeDialogTexture hDlg ETDT_ENABLETAB
,
,int htb=id(3 hDlg)
,TCITEM ti.mask=TCIF_TEXT
,ti.pszText="A"
,SendMessage htb TCM_INSERTITEMA 0 &ti
,ti.pszText="B"
,SendMessage htb TCM_INSERTITEMA 1 &ti
,ti.pszText="C"
,SendMessage htb TCM_INSERTITEMA 2 &ti
,
,DT_Page hDlg _i
,
,case WM_PAINT
,;draw dialog background here
,
,int bkType=2 ;;0 color, 1 hor gradient, 2 vert gradient, 3 image
,
,PAINTSTRUCT ps; BeginPaint hDlg &ps
,RECT r; GetClientRect hDlg &r
,
,sel bkType
,,case [0,3]
,,;first time create brush
,,__GdiHandle- brush hbm
,,if !brush
,,,if bkType
,,,,hbm=LoadPictureFile("$my qm$\Copy.jpg")
,,,,brush=CreatePatternBrush(hbm)
,,,else
,,,,brush=CreateSolidBrush(0xc0ffff)
,,,
,,;then fill background with the brush
,,FillRect ps.hDC &r brush
,,
,,case [1,2]
,,TRIVERTEX x1 x2; int R G B
,,memcpy &x2 &r.right 8
,,ColorToRGB 0x80e0a0 R G B; x1.Red=R<<8; x1.Green=G<<8; x1.Blue=B<<8
,,ColorToRGB 0x80e0e0 R G B; x2.Red=R<<8; x2.Green=G<<8; x2.Blue=B<<8
,,GRADIENT_RECT r1.LowerRight=1
,,GdiGradientFill ps.hDC &x1 2 &r1 1 bkType&2!0
,,
,EndPaint hDlg &ps
,
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom TCM_GETCURSEL 0 0)
,DT_Page hDlg _i
#16
Thanks Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)