//QM v2.10. Do not edit with text editor!!! //
11    2
I7b̩a:H#`ȏZ
  examples  65536 3EC7AA76 0

  draw_on_control  8 3EC7D851 1
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("draw_on_control" &draw_on_control)) ret

 BEGIN DIALOG
 0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
 3 Static 0x54000000 0x0 10 10 66 46 "Text"
 1 Button 0x54030001 0x4 120 116 48 14 "OK"
 2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
 END DIALOG
 DIALOG EDITOR: "" 0x2030503 "*" "" "" ""

ret
 messages
sel message
	case WM_INITDIALOG
	DT_DrawOnControl id(3 hDlg) &draw_on_control_proc
	 DT_DrawOnControl hDlg &draw_on_control_proc
	case WM_DESTROY
	case WM_COMMAND goto messages2
ret
 messages2
sel wParam
	case IDOK
	case IDCANCEL
ret 1

  draw_on_control_proc  8 3EC85258 1
 /draw_on_control
function hWnd hdc RECT&ru cbParam

__GdiHandle hPen=CreatePen(0 1 0xff0000)
__GdiHandle hBrush=CreateSolidBrush(0xc0E0)
int oldPen=SelectObject(hdc hPen)
int oldBrush=SelectObject(hdc hBrush)
Ellipse hdc 4 4 50 50
SelectObject(hdc oldBrush)
SelectObject(hdc oldPen)

__Font-- f.Create("Comic Sans MS" 12 1)
int oldFont=SelectObject(hdc f)
SetBkMode hdc TRANSPARENT
SetTextColor hdc 0xff
TextOutW hdc 10 14 @"test" 4
SelectObject(hdc oldFont)

  draw_on_splitter  8 3EC9B3B0 1
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

 InitSplitter

str controls = "3 4"
str e3 e4
if(!ShowDialog("draw_on_splitter" &draw_on_splitter &controls)) ret

 BEGIN DIALOG
 0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
 3 Edit 0x54231044 0x200 0 0 112 112 ""
 4 Edit 0x54231044 0x200 118 0 106 112 ""
 5 QM_Splitter 0x54030000 0x0 112 0 6 112 ""
 6 QM_Splitter 0x54030000 0x0 0 112 110 6 ""
 1 Button 0x54030001 0x4 120 116 48 14 "OK"
 2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
 END DIALOG
 DIALOG EDITOR: "" 0x2030503 "*" "" "" ""

ret
 messages
sel message
	case WM_INITDIALOG
	DT_DrawOnControl id(5 hDlg) &draw_on_splitter_proc 0 ;;vertical splitter
	DT_DrawOnControl id(6 hDlg) &draw_on_splitter_proc 1 ;;horizontal splitter
	case WM_DESTROY
	case WM_COMMAND goto messages2
ret
 messages2
sel wParam
	case IDOK
	case IDCANCEL
ret 1

  draw_on_splitter_proc  8 3EC9B37D 1
 /draw_on_splitter
function hWnd hdc RECT&ru cbParam

RECT r; GetClientRect hWnd &r
int w(r.right) h(r.bottom) ww(w/2) hh(h/2)

__Font-- fontSym.Create("Marlett" w) ;;symbol font
__Hicon-- iconCut=GetFileIcon("$qm$\cut.ico")

int oldFont=SelectObject(hdc fontSym)
SetBkMode hdc TRANSPARENT

sel cbParam
	case 0 ;;vertical splitter
	TextOutW hdc 0 hh-w L"3" 1 ;;<
	TextOutW hdc -w/6 hh L"4" 1 ;;>
	DrawIconEx hdc -3 h-18 iconCut 16 16 0 0 DI_NORMAL
	
	case 1 ;;horizontal splitter
	TextOutW hdc ww-h 0 L"5" 1 ;;^
	TextOutW hdc ww -h/6 L"6" 1 ;;v
	DrawIconEx hdc w-18 -3 iconCut 16 16 0 0 DI_NORMAL

SelectObject(hdc oldFont)

  DT_DrawOnControl  8 3EC85567 0
 /
function! hwnd cbFunc [cbParam]

 Sets an user-defined function to be called to draw on a control in a dialog or other window.
 Returns: 1 success, 0 failed.

 hwnd - control handle.
 cbFunc - address of callback function, like &MyDrawControlFunc.
   function hWnd hdc RECT&r cbParam
   Tip: menu File -> New -> Templates -> Callback -> Callback_DrawOnControl.
 cbParam - some value to pass to the callback function.

 REMARKS
 The callback function is called whenever the control receives WM_PAINT message, after calling control's window procedure, therefore can draw on top. It can use Windows GDI or GDI+ functions.
 This function subclasses the control to intercept WM_PAINT messages sent to the control.
 This function also can draw directly on dialog, but instead you can use the standard way (case WM_PAINT/BeginPaint/EndPaint) or DT_SetBackgroundColor/DT_SetBackgroundImage.


#ifndef SetWindowSubclass ;;< QM 2.3.5
dll comctl32
	[410]#SetWindowSubclass hWnd pfnSubclass uIdSubclass dwRefData   ;;pfnSubclass: function# hWnd uMsg wParam lParam uIdSubclass dwRefData
	[411]#GetWindowSubclass hWnd pfnSubclass uIdSubclass *pdwRefData
	[412]#RemoveWindowSubclass hWnd pfnSubclass uIdSubclass
	[413]#DefSubclassProc hWnd uMsg wParam lParam
#endif

if(IsBadCodePtr(cbFunc)) end ERR_BADARG

type __DT_DOC cbFunc cbParam
__DT_DOC* d._new; memcpy d &cbFunc 8

int R=SetWindowSubclass(hwnd &DT_DOC_WndProc 1 d)
if(!R) d._delete
ret R!0

  private  65600 3EC7A5DA 0

  DT_DOC_WndProc  8 3EC7DAEA 7
 /
function# hWnd message wParam lParam uIdSubclass __DT_DOC*d

RECT r
sel message
	case WM_PAINT
	GetUpdateRect hWnd &r 0

int R=DefSubclassProc(hWnd message wParam lParam)

sel message
	case WM_NCDESTROY
	RemoveWindowSubclass(hWnd &DT_DOC_WndProc 1)
	
	case WM_PAINT
	__Hdc dc.Init(hWnd)
	_i=SaveDC(dc)
	call d.cbFunc hWnd dc.dc &r d.cbParam
	RestoreDC(dc _i)

ret R

  Callback_DrawOnControl  2056 3EC852D3 7
 /
function hWnd hdc RECT&ru cbParam

 hWnd - control handle.
 hdc - device context.
 ru - the initial update rectangle.
 cbParam - cbParam passed to DT_DrawOnControl.

 EXAMPLE
 Ellipse hdc 4 4 20 20

  file  268500992 0

  