Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dlg Resizing through EN_SETFOCUS
#1
Hi Gintaras,
Strange result with the following dlg. Not sure if this is a bug or may some opt setting not being used by me.
I want the user to be able to expand the dlg/edit fields by clicking on them and another click to toggle back to regular size. This works a few times and then eventually locks up - can no longer resize through clicking or even write text to edit controls anymore. I think the problem is that I have to remove the focus away from the control to be able to toggle a second time. I remove focus now with the act after the resizing but this is probably bad way of doing it. Any thoughts on why this locks up or better way to do it?
Thanks so much, S

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

GdiObject- red=CreateSolidBrush(ColorFromRGB(0 0 255))
str controls = "69 67"
str e69 rea67
if(!ShowDialog("DashBoard" &DashBoard &controls)) ret

;BEGIN DIALOG
;0 "" 0x90000840 0x0 0 0 389 25 "DashBoard"
;69 Edit 0x50200844 0x20000 132 27 294 75 ""
;44 Button 0x52010100 0x20000 8 0 124 10 ""
;39 Button 0x52010100 0x20000 8 8 124 9 ""
;61 Button 0x52010100 0x20000 8 16 124 9 ""
;58 Static 0x54000000 0x0 437 6 10 0 ""
;67 Edit 0x50200844 0x20000  132 0 258 28 ""
;6 Button 0x54032000 0x0 0 0 8 8 "x"
;END DIALOG
;DIALOG EDITOR: "" 0x2030400 "" "" "" ""

ret
;messages

sel message
,case WM_INITDIALOG
,,Zorder hDlg HWND_TOPMOST SWP_NOACTIVATE
,,__GdiHandle-- hb=CreateSolidBrush(0xff00)
,,Transparent hDlg 255 0xff00        
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_CTLCOLORDLG
,,ret hb
ret
;messages2
sel wParam
,case EN_SETFOCUS<<16|67            
,,int x1 y cx cy; GetWinXY hDlg x1 y cx cy
,,if cy < 100
,,,siz 0 500 hDlg 1
,,,siz 0 250 id(67 hDlg) 1    
,,,MoveWindow id(69 hDlg) 200 225 400 150 1        
,,,act    
,,else
,,,siz 0 46 hDlg 1
,,,siz 0 40 id(67 hDlg) 1    
,,,act
,case EN_SETFOCUS<<16|69
,,GetWinXY hDlg x1 y cx cy
,,if cy < 100
,,,siz 0 500 hDlg 1
,,,siz 0 250 id(67 hDlg) 1    
,,,MoveWindow id(69 hDlg) 200 225 400 150 1        
,,,act    
,,else
,,,siz 0 46 hDlg 1
,,,siz 0 40 id(67 hDlg) 1    
,,,act
,case 6
,,clo hDlg
,case IDOK
,case IDCANCEL
ret 1
#2
To remove focus from a control, use SetFocus hDlg.

Can also use WM_SETCURSOR instead of EN_SETFOCUS.
Function DashBoard
Code:
Copy      Help
,case WM_COMMAND goto messages2
,case WM_CTLCOLORDLG
,,ret hb
,case WM_SETCURSOR
,if lParam>>16=WM_LBUTTONDOWN and GetWinId(wParam)=67
,,if GetFocus!wParam
,,,out "expand"
,,else
,,,out "shrink"
#3
Sweet!!!
Thanks again!
S


Forum Jump:


Users browsing this thread: 1 Guest(s)