Posts: 12,072
Threads: 140
Joined: Dec 2002
Functions and examples of on-screen drawing.
You can draw anything (various shapes, text, icons, etc) using Windows API functions.
Drawing functions are documented in the MSDN Library.
Minimum QM version 2.2.0.
Attached Files
On-screen draw.qml (Size: 4.68 KB / Downloads: 1,464)
Posts: 1,271
Threads: 399
Joined: Mar 2003
i figured out how to get the taskbar background and draw
it to the hdc (testing in OSD_ProcExample).
can you tell me how to set the background of ToolbarWindow32 ?
do i have to use NMTBCUSTOMDRAW like in Dialog Explorer for LV and TV ?
def WP_CAPTION 1
int _hTheme=OpenThemeData (0 L"Taskbar")
RECT r2.left=0;r2.right=100; r2.top=0; r2.bottom=30
DrawThemeBackground (_hTheme hdc WP_CAPTION 0 &r2 0)
CloseThemeData (_hTheme)
i tried this in my taskbar dialog, but i guess its nonsense ...
htb is the handle of ToolbarWindow32.
, case WM_PAINT
,, PAINTSTRUCT pa
,, int hdc=BeginPaint (htb &pa)
,, int _hTheme=OpenThemeData (0 L"Taskbar")
,, RECT rc;GetClientRect htb &rc
,, DrawThemeBackground (_hTheme hdc WP_CAPTION 0 &rc 0)
,, CloseThemeData (_hTheme)
,, EndPaint htb &pa
Posts: 12,072
Threads: 140
Joined: Dec 2002
If ToolbarWindow32 is transparent, you can draw on hDlg, on WM_ERASEBKGND message. It is easier than to use toolbar custom draw feature.
\Dialog_Editor
function # hDlg message wParam lParam
if (hDlg) goto messages
if (!ShowDialog ("Dialog36" &Dialog36 )) ret
;BEGIN DIALOG
;0 "" 0x90CC0A44 0x100 0 0 217 129 "Dialog"
;3 ToolbarWindow32 0x54018800 0x0 0 0 217 17 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020100 "" ""
ret
;messages
sel message
, case WM_INITDIALOG
, int htb=id (3 hDlg)
, int il1=ImageList_LoadImage (0 _s.expandpath("$qm$\de_ctrl.bmp") 16 0 0xFF00FF IMAGE_BITMAP LR_LOADFROMFILE )
, SendMessage htb TB_SETIMAGELIST 0 il1
,
, ARRAY (TBBUTTON ) a.create(3)
, ARRAY (str ) as="One[]Two[]Three"
, int i
, for i 0 a.len
,, TBBUTTON & t=a[i]
,, t.idCommand=1001+i
,, t.iBitmap=i+1
,, t.iString=SendMessage (htb TB_ADDSTRINGA 0 as[i])
,, t.fsState=TBSTATE_ENABLED
,
, SendMessage (htb TB_BUTTONSTRUCTSIZE sizeof (TBBUTTON ) 0)
, SendMessage (htb TB_ADDBUTTONS a.len &a[0])
,
, SendMessage id (3 hDlg) TB_AUTOSIZE 0 0
,
, case WM_DESTROY
, case WM_COMMAND goto messages2
,
, case WM_ERASEBKGND
, RECT rc; GetClientRect hDlg &rc
, int hdc=wParam
, FillRect hdc &rc COLOR_BTNFACE +1
, OSD_ProcExample hDlg hdc rc.right rc.bottom 0
, ret DT_Ret (hDlg 1)
,
ret
;messages2
ret 1
Posts: 1,769
Threads: 410
Joined: Feb 2003
this is AWESOME!!!
cant wait to start using it.
Posts: 576
Threads: 97
Joined: Aug 2007
Hey, when ever i try to use this, i get this error...
Error (RT) in OSD_Dialog: invalid pointer
and it goes to this in the OSD_Dialog Function...
, if (d.cx and d.cy) siz d.cx d.cy hDlg
Posts: 12,072
Threads: 140
Joined: Dec 2002
Quote: Minimum QM version 2.2.0.
Posts: 576
Threads: 97
Joined: Aug 2007
I have QM Version 2.2.0.11
Posts: 12,072
Threads: 140
Joined: Dec 2002
Then maybe you somehow use old version of System folder. Can you post function DefDialogProc? It is in System\Dialogs\Dialog Functions\Private.
Posts: 576
Threads: 97
Joined: Aug 2007
Here is
DefDialogProc:
;/
function # hDlg message wParam lParam
;ShowDialog uses this function as dialog
;procedure when dlgproc is omitted or 0.
sel message
, case WM_INITDIALOG
, DT_Init (hDlg lParam)
, ret 1
, ;----
, case WM_COMMAND
, int msg(wParam >> 16) ctrlid(wParam & 0xFFFF)
, sel msg
,, case BN_CLICKED
,, if (ctrlid=IDCANCEL ) DT_Cancel hDlg
,, else if (GetWinStyle (lParam)&15<2) DT_Ok hDlg ctrlid
, ret 1
, ;----
, case WM_DESTROY DT_DeleteData (hDlg)
Posts: 12,072
Threads: 140
Joined: Dec 2002
It is from QM 2.1.8.
If you for some reason don't want to use System of QM 2.2.0, you can probably make OSD_Dialog work with your System version. Add DT_Init and DT_DeleteData, like it is in all other QM 2.1.8 dialogs.
Posts: 1,271
Threads: 399
Joined: Mar 2003
is it possible to attach a rectangle to a window ?
i mean that it follows the window when moving.
in my program i have a static with a colormap.bmp and notify.
its easy to get color values from mouse position.
now i need a solution to display the picked color as rectangles.
one idea is to use datagrid cells because the rest of the info
is there also visible.
my client needs up to three colors for a product (per row).
all what i found for individual cell background has to do with paint/draw.
another idea is define a virtual grid for painting.