Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Draw on a control
#1
Sets an user-defined function to be called to draw on a control in a dialog or other window.


Attached Files
.qml   Draw on control.qml (Size: 5.08 KB / Downloads: 1,309)
#2
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
#3
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:


Code:
Copy      Help
__Hicon-- ico=LoadImageW(0 @IconPath IMAGE_ICON 0 0 LR_LOADFROMFILE)

Is there a way to get this into an executable?

S
#4
Now added code for horizontal splitter too.

Can be
GetFileIcon(":5 $qm$\cut.ico")
#5
many many thanks Gintaras!
S
#6
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:

Code:
Copy      Help
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:

Code:
Copy      Help
SetBkMode hdc TRANSPARENT

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

Thanks for any help!
S
#7
Example with 3 splitters. Vertical transparent, horizontal yellow, vertical with arrows and icon.
Function Dialog137
Code:
Copy      Help
\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
#8
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
#9
Maybe you have older splitters version...
#10
Yes, updated now.
Resizable dialog, resizable controls, splitters
#11
yes that was the problem. I just redownloaded from forum archive and works fine. Thanks!!!!, S


Forum Jump:


Users browsing this thread: 1 Guest(s)