Draw on a control

Functions, classes, components, etc. Only high quality content.

Draw on a control

Postby Gintaras on Sat May 18, 2013 3:54 am

Sets an user-defined function to be called to draw on a control in a dialog or other window.
Attachments
Draw on control.qml
(5.08 KiB) Downloaded 690 times
Gintaras
Site Admin
 
Posts: 10282
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Draw on a control

Postby stupomer on Sat May 18, 2013 7:50 pm

Thanks, works great for the icons!!! I couldn't however, understand how to use the example to change the vertical splitter into a horizontal splitter with updown arrows. The marlett character "v" for up/down arrows is great but I couldn't get it to size right. with the TextOutW definition of "dll gdi32 #TextOutW hdc x y @*lpString c". For some reason, it was getting extremely large or small when I put variable or absolute integer values in for x and y depending on the size and height/width of the splitter bar.
Thanks though for an amazing UI element.
Stuart
User avatar
stupomer
Active Member
 
Posts: 922
Joined: Fri Mar 23, 2007 2:22 am
Location: Boston, USA

Re: Draw on a control - problem with resource id

Postby stupomer on Sun May 19, 2013 1:19 am

Hi Gintaras,
I am trying to use this function in an executable therefore the icon I refer to will need resource id. Unfortunately, if I include a resource id in the filepath for the icon, it fails to appear when I run the dialog:


__Hicon-- ico=LoadImageW(0 @IconPath IMAGE_ICON 0 0 LR_LOADFROMFILE)


Is there a way to get this into an executable?

S
User avatar
stupomer
Active Member
 
Posts: 922
Joined: Fri Mar 23, 2007 2:22 am
Location: Boston, USA

Re: Draw on a control

Postby Gintaras on Sun May 19, 2013 4:41 am

Now added code for horizontal splitter too.

Can be
GetFileIcon(":5 $qm$\cut.ico")
Gintaras
Site Admin
 
Posts: 10282
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Draw on a control

Postby stupomer on Thu May 23, 2013 12:17 am

many many thanks Gintaras!
S
User avatar
stupomer
Active Member
 
Posts: 922
Joined: Fri Mar 23, 2007 2:22 am
Location: Boston, USA

Color on Splitter - Re: Draw on a control

Postby stupomer on Mon Oct 28, 2013 1:07 pm

Hi Gintaras,
This is probably figure-out-able from what you have in the section and examples but I am still having trouble. I would like to give a color to both the background dialog and the splitter. Perhaps same perhaps different.
To give dialog background color, I use this:

DT_SetBackgroundColor(hDlg 0 0xB48246) ;;blue 70 130 180


If there was a way to similarly assign color to this element, that would be great. I guess if it was transparent, it would take the background color but still be grab-able?

I see that this may be relevant but not yet sure how to implement:

SetBkMode hdc TRANSPARENT


Not sure what this would do with any draw-on-controls.

Thanks for any help!
S
User avatar
stupomer
Active Member
 
Posts: 922
Joined: Fri Mar 23, 2007 2:22 am
Location: Boston, USA

Re: Draw on a control

Postby Gintaras on Mon Oct 28, 2013 2:03 pm

Example with 3 splitters. Vertical transparent, horizontal yellow, vertical with arrows and icon.
Function Dialog137     ?
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4 7"
str lb3 e4 e7
if(!ShowDialog("Dialog137" &Dialog137 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;3 ListBox 0x54230101 0x200 4 4 96 62 ""
;4 Edit 0x54231044 0x200 106 4 114 62 ""
;7 Edit 0x54231044 0x200 4 74 96 48 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;5 QM_Splitter 0x54000000 0x0 100 4 6 62 ""
;6 QM_Splitter 0x54030000 0x0 4 66 216 8 ""
;8 QM_Splitter 0x54030000 0x0 100 74 8 48 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "*" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,DT_SetBackgroundColor(hDlg 0 0xB48246) ;;blue 70 130 180
,__GdiHandle-- hBrush=CreateSolidBrush(0xffff)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CTLCOLORSTATIC ;;probably from a splitter
,sel GetDlgCtrlID(lParam)
,,;case 5 ;;do nothing, it's transparent by default
,,case 6 ret hBrush ;;horz splitter
,,case 8 ;;draw something, if you have function draw_on_splitter_proc from "Draw on control" examples
#ifdef draw_on_splitter_proc
,,RECT ru; GetClientRect lParam &ru
,,draw_on_splitter_proc lParam wParam ru 0
#endif
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Gintaras
Site Admin
 
Posts: 10282
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Draw on a control

Postby stupomer on Mon Oct 28, 2013 4:01 pm

weird, example not working in installed or portable versions of QM editor. - splitters remain standard default color.
Will try later to put it into my specific code.
S
User avatar
stupomer
Active Member
 
Posts: 922
Joined: Fri Mar 23, 2007 2:22 am
Location: Boston, USA

Re: Draw on a control

Postby Gintaras on Mon Oct 28, 2013 4:23 pm

Maybe you have older splitters version...
Gintaras
Site Admin
 
Posts: 10282
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Draw on a control

Postby Gintaras on Mon Oct 28, 2013 4:28 pm

Yes, updated now.
viewtopic.php?f=2&t=4528
Gintaras
Site Admin
 
Posts: 10282
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Draw on a control

Postby stupomer on Mon Oct 28, 2013 4:36 pm

yes that was the problem. I just redownloaded from forum archive and works fine. Thanks!!!!, S
User avatar
stupomer
Active Member
 
Posts: 922
Joined: Fri Mar 23, 2007 2:22 am
Location: Boston, USA


Return to QM Extensions

Who is online

Users browsing this forum: No registered users and 4 guests

cron