Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Couple button questions. Enlarge control on mouse over.
#1
Is there a way to make a button, icon or bitmap enlarge on mouse rollover?

And, is there a way to deactivate (gray out?) a button until a certain screen is reached or action is performed in a dialog?

Finally, thank you Gin for making such a spectacular program and thank you for being such a big help for newbies like me!

Thanks
#2
Code removed.

Quote:And, is there a way to deactivate (gray out?) a button until a certain screen is reached or action is performed in a dialog?
Use function EnableWindow.
#3
Helpful as always! Thank you!!
#4
I'm using the button enlarge code you gave me but I'm having some kind of ...glitch? If I mouse over from one button to the next to fast, that button will remain enlarged even when I mouse off from it. Also all other buttons stop enlarging when this happens.. As long as I move the mouse cursor slow over each button all works well. What do you think would be causing this to happen?

*Edit*

I should rephrase that. If you move the cursor from one button to another and back too fast, that's when it freezes.
#5
Use this instead.

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

if(!ShowDialog("dlg_change_button_size2" &dlg_change_button_size2)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032000 0x0 16 30 16 14 "A"
;4 Button 0x54032000 0x0 32 30 16 14 "B"
;5 Button 0x54032000 0x0 48 30 16 14 "C"
;6 Static 0x54000000 0x0 16 14 98 12 "move mouse on a button"
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,DT_ChangeMouseControlSize id(3 hDlg) 5
,DT_ChangeMouseControlSize id(4 hDlg) 5
,DT_ChangeMouseControlSize id(5 hDlg) 15
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

You'll need these 2 functions. You can use them with any dialog.
Function DT_ChangeMouseControlSize
Code:
Copy      Help
;/
function hwndControl sizePlus

;Sets a control to make bigger on mouse over.
;Call this function in dialog procedure, under WM_INITDIALOG.

;hwndControl - control handle.
;sizePlus - how much bigger.


type CMCS_DATA wndProc sizePlus !big RECT'r
CMCS_DATA* p._new
p.wndProc=SubclassWindow(hwndControl &CMCS_WndProc)
p.sizePlus=sizePlus
SetProp hwndControl "CMCS_DATA" p

Function CMCS_WndProc
Code:
Copy      Help
;/
function# hWnd message wParam lParam

CMCS_DATA* p=+GetProp(hWnd "CMCS_DATA")
if(!p) ret
int wndProc=p.wndProc

sel message
,case WM_NCDESTROY
,p._delete
,RemoveProp(hWnd "CMCS_DATA")
,
,case WM_MOUSEMOVE
,if !p.big
,,p.big=1
,,GetWindowRect hWnd &p.r; MapWindowPoints 0 GetParent(hWnd) +&p.r 2 ;;save old rect
,,RECT r=p.r; InflateRect &r p.sizePlus p.sizePlus; MoveWindow hWnd r.left r.top r.right-r.left r.bottom-r.top 1 ;;make bigger
,,TRACKMOUSEEVENT t.cbSize=16; t.dwFlags=TME_LEAVE; t.hwndTrack=hWnd; TrackMouseEvent &t ;;set to notify when mouse leaves
,
,case WM_MOUSELEAVE
,if p.big
,,p.big=0
,,MoveWindow hWnd p.r.left p.r.top p.r.right-p.r.left p.r.bottom-p.r.top 1

ret CallWindowProc(wndProc hWnd message wParam lParam)
#6
INCREDIBLE!! Man you are GOOD!

Thank you
#7
This is a GREAT way to get a very simple hover over button effect that Windows XP style gives to buttons but not seen in Windows Classic Style (only need to set sizePlus to 1 for a nice subtle effect). More importantly if you cover a button with a bmp/jpeg using:


Code:
Copy      Help
,SendMessage(id(47 hDlg) BM_SETIMAGE IMAGE_BITMAP LoadPictureFile(SampleImageFilePath 0))

you would normally lose the Windows XP hover effect but this gives it back!!!! Beautiful.

Anyway to make it work for a tab control? kind of like def TCS_HOTTRACK 0x0040 but a little more prominent?


Thanks!!!
Stuart
#8
Quote:Anyway to make it work for a tab control? kind of like def TCS_HOTTRACK 0x0040 but a little more prominent?

Cannot make tab buttons bigger. Can add icons. Also can add TCS_OWNERDRAWFIXED style and draw anything in buttons, but then probably we will lose the default theme, and the control will look like on Windows 2000.
#9
What is the syntax for drawing jpg or bmp on tab button? Can you give an example (one line .... Not something big and complex :-).
Thank you for all you do!
Stuart
#10
it would be something not very small Smile
#11
Tab control with icons
Colors, Icons, Jpg/BMP's on Tabs in SysTabControl32

Owner-draw tabs
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
#12
Function dlg_tab_owner_draw
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("" &dlg_tab_owner_draw)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 SysTabControl32 0x54030040 0x0 0 0 224 110 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030300 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,str-- t_tabLabels="A[]Bbbbbbbbbbbbbb[]C"
,__GdiHandle-- t_tabBrush=CreateSolidBrush(0x80f0c0) ;;color
,;__GdiHandle bm=LoadPictureFile("$qm$\bitmap1.bmp"); __GdiHandle-- t_tabBrush=CreatePatternBrush(bm) ;;image
,
,int htb=id(3 hDlg)
,SetWinStyle htb TCS_OWNERDRAWFIXED 1
,TCITEMW ti.mask=TCIF_TEXT
,foreach _s t_tabLabels
,,ti.pszText=@_s; SendMessage htb TCM_INSERTITEMW _i &ti
,,_i+1
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,
,case WM_DRAWITEM
,DRAWITEMSTRUCT& d=+lParam
,;out "%i %i %i" d.itemID d.itemAction d.itemState
,
,if(d.itemState&ODS_SELECTED) FillRect d.hDC &d.rcItem t_tabBrush
,
,_s.getl(t_tabLabels d.itemID)
,RECT r=d.rcItem; InflateRect &r -2 -2
,SetBkMode d.hDC TRANSPARENT
,DrawTextW d.hDC @_s -1 &r DT_NOPREFIX
,
,ret DT_Ret(hDlg 1)
,
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Forum Jump:


Users browsing this thread: 1 Guest(s)