Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(Solved)...Mouse over highlight
#1

I'm using a Static text to get mouse clicks see blow. What I want is when the user does a mouse over on that id it will highlight it, can this be done?.


Thank you.


Function ( testDlg )
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54030100 0x4 56 38 48 12 "&ClickHere"
;END DIALOG
;DIALOG EDITOR: "" 0x202000B "" ""

if(!ShowDialog("testDlg" &testDlg)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case STN_CLICKED<<16|3
,out 1
,case IDOK
,case IDCANCEL
ret 1
#2
Function DT_HiliteControlOnMouseOver
Code:
Copy      Help
;/
function# hDlg message wParam lParam hctrl backcolor textcolor

;Changes control colors when mouse pointer is over.
;The control must be Static or read-only Edit.
;Call this function from dialog function, between ' message' and 'sel message' lines.
;If this function returns a nonzero value, let the dialog function return that value.
;Call this function for each control you want to change colors.


;hDlg message wParam lParam - hDlg message wParam lParam.
;hctrl - control handle.
;backcolor - control color. Use -1 for default color.
;textcolor - control text color. Use -1 for default color.


;See also: <ColorFromRGB>

;EXAMPLE
;;...
;;messages
;int z=DT_HiliteControlOnMouseOver(hDlg message wParam lParam id(3 hDlg) 0xff0000 0x00ffff)
;if(z) ret z
;sel message
;,;...


int brush=GetProp(hDlg "qm_hcoobrush")
sel message
,case WM_SETCURSOR
,if(!brush and child(mouse)=hctrl)
,,;out "1 %i" hctrl
,,if(backcolor=-1) backcolor=GetSysColor(COLOR_BTNFACE)
,,SetProp(hDlg "qm_hcoobrush" CreateSolidBrush(backcolor))
,,SetProp(hDlg "qm_hcoohwnd" hctrl)
,,RedrawWindow hctrl 0 0 RDW_INVALIDATE
,,SetTimer hDlg 33345 50 0
,case WM_TIMER
,if(wParam=33345 and hctrl=GetProp(hDlg "qm_hcoohwnd") and child(mouse)!=hctrl)
,,;out "2 %i" hctrl
,,KillTimer hDlg wParam
,,RemoveProp(hDlg "qm_hcoobrush")
,,RemoveProp(hDlg "qm_hcoohwnd")
,,DeleteObject brush
,,RedrawWindow hctrl 0 0 RDW_INVALIDATE
,case WM_CTLCOLORSTATIC
,if(brush and lParam=hctrl)
,,SetBkMode wParam TRANSPARENT
,,if(textcolor!=-1) SetTextColor wParam textcolor
,,ret brush

Example dialog
Function testDlg
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54030100 0x4 16 84 48 13 "&ClickHere"
;4 Edit 0x54230844 0x20000 0 94 96 48 "dddd"
;END DIALOG
;DIALOG EDITOR: "" 0x2020100 "" ""

if(!ShowDialog("testDlg" &testDlg)) ret
ret
;messages
int z=DT_HiliteControlOnMouseOver(hDlg message wParam lParam id(3 hDlg) 0xff0000 0x00ffff)
if(z) ret z
z=DT_HiliteControlOnMouseOver(hDlg message wParam lParam id(4 hDlg) 0xff0000 0x00ffff)
if(z) ret z
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case STN_CLICKED<<16|3
,out 1
,case IDOK
,case IDCANCEL
ret 1
#3

Very cool.

THANKS!
#4
Hi,

Is it possible to modify this to work with the new DT_SetBackgroundColor function?
Seems like the function is not getting CTLCOLORSTATIC message.
#5
Need just a small change in \System\Dialogs\private\DT_DialogProc. It will be added in next QM.
You can replace the function now. Need QM 2.3.4.
Make System folder not read-only. Replace DT_DialogProc text. Export System folder; when exporting, replace existing system.qml file.

Function DT_DialogProc
Code:
Copy      Help
;/
function# hDlg message wParam lParam

__DIALOG* d; int R

if message=WM_INITDIALOG
,;ShowDialog passes address of __DIALOG as lParam. It uses normal variable, not _new, because need to auto clear on error.
,;Here we create new __DIALOG, copy from __DIALOG of ShowDialog, and zero __DIALOG of ShowDialog to disable clearing it by its dtor.
,;On WM_DESTROY we'll delete our __DIALOG.
,d._new
,memcpy d +lParam sizeof(__DIALOG); memset +lParam 0 sizeof(__DIALOG)
,SetProp(hDlg "dialogdata" d)
,
,if(d.dlgproc) CallWindowProc(d.dlgproc hDlg WM_CREATE 0 0)
,DT_Init(hDlg d)
,d.flags2|2
,if(d.dlgproc) CallWindowProc(d.dlgproc hDlg message wParam d)
,if(d.flags2&0x100) ret ;;hidden or inactive
,ret !(d.dlgproc and GetFocus)

d=+GetProp(hDlg "dialogdata"); if(!d) ret
if(d.flags2&2=0) goto g1

sel message
,case WM_COMMAND if(!lParam and wParam>>16=1) wParam&0xffff ;;remove accelerator flag to match menu id
,case WM_SETCURSOR if(d.tt) d.tt.OnWmSetcursor(wParam lParam) ;;relays if not hooked, etc
,case else if(d.colors) R=call(d.colors.func d.colors hDlg message wParam lParam); int R2=R ;;call through pointer to make exe smaller when not used

if d.dlgproc
,R=CallWindowProc(d.dlgproc hDlg message wParam lParam)
,sel message
,,case WM_COMMAND
,,sel wParam
,,,case [IDOK,IDCANCEL]
,,,if(d.flags2&16) ret R ;;DT_Init was called explicitly, which indicates old version
,,,if(!R) ret 1 ;;don't close
,,,if(wParam=IDOK) DT_Ok hDlg
,,,else DT_Cancel hDlg
,,,ret 1
,,case else
,,if(R2 and !R) R=R2 ;;if our colors proc on wm_ctlcolorx returned a brush (R2), return it now, but if user's dlgproc returned a brush too, return user's brush instead
else
,sel message
,,case WM_COMMAND
,,sel wParam
,,,case IDOK DT_Ok hDlg
,,,case IDCANCEL DT_Cancel hDlg
,,,case else ;;if button or menu, close dialog and return id
,,,if(wParam&0xffff0000) ret 1
,,,if(lParam) _s.getwinclass(lParam); if(!(_s~"Button" and GetWinStyle(lParam)&15<2)) ret 1
,,,DT_Ok hDlg wParam
,,ret 1

;g1
sel message
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_QM_ENDTHREAD if(d.flags&1 and !R) DestroyWindow hDlg; ret 1

ret R
#6
Replaced everything like you explained and it works!

Only lost the little "s" on system folder icon...

Thank you very much and also thank you for fixing tooltips in latest qm! (xp bug, no tooltip after click)

Best Regards.
#7
If no "s" on System folder, possible problems in the future. System folder will not be updated with new QM version, and QM will stop working normally.
To fix it: Delete the folder. In Options/Files check 'Always add System'. Restart QM.
#8
Fixed. Thank you again.

Regards.


Forum Jump:


Users browsing this thread: 1 Guest(s)