Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
On-screen drawing
#1
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
.qml   On-screen draw.qml (Size: 4.68 KB / Downloads: 946)
#2
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 ?

Code:
Select All      Help
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.

Code:
Select All      Help
,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
pi
#3
If ToolbarWindow32 is transparent, you can draw on hDlg, on WM_ERASEBKGND message. It is easier than to use toolbar custom draw feature.

Code:
Select All      Help
\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
#4
this is AWESOME!!!
cant wait to start using it.
A new blog on QM coding and automation.

The Macro Hook
#5
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...

Code:
Select All      Help
,if(d.cx and d.cy) siz d.cx d.cy hDlg
#6
Quote:Minimum QM version 2.2.0.
#7
I have QM Version 2.2.0.11
#8
Then maybe you somehow use old version of System folder. Can you post function DefDialogProc? It is in System\Dialogs\Dialog Functions\Private.
#9
Here is

DefDialogProc:
Code:
Select All      Help
;/
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)
#10
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.
#11
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.
pi


Forum Jump:


Users browsing this thread: 1 Guest(s)