Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog: detect upper menubar not visible
#1
I have below a menubar in a dialog, I want to detect if the the menubar is not visible, ideally if the resizing cuts of the smallest part of the upper menu bar.
In the below code I output the the dialog size (height) after resizing but it doesn't work as it should.

EDIT:
The ?? in the line: ?? :410 are 2 downfacing arrows

Function resize_hide
Code:
Copy      Help
str md=
F
;BEGIN MENU
;?? :410
;item 1 :411
;item 2 :412
;item 3 :413
;END MENU

str dd=
;BEGIN DIALOG
;0 "" 0x90CC0AC8 0x0 0 0 246 42 "Dialog" "4"
;3 Edit 0x54030080 0x200 65 15 96 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls 0 0 0 0 0 0 0 0 md)) ret



#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,int dw dh he
,case WM_DESTROY
,case WM_SIZE
,,;; --- Does not always capture height correctly
,,GetWinXY hDlg 0 0 dw dh
,,outt F"WM_SIZE dh : {dh}"
,,;; --- check if inputfield is visible (does not work)
,,;he=id(3 hDlg)
,,;if(!IsWindowVisible(he))....
,case WM_SIZING
,,;; ---  Does not always capture height correctly
,,;GetWinXY hDlg 0 0 dw dh
,,;outt F"WM_SIZING dh : {dh}"        
,,;; --- check if inputfield is visible (does not work)
,,;he=id(3 hDlg)
,,;if(!IsWindowVisible(he))....
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

The arrows are meant as part of rollup/rolldown.
I found the rollup function within the archive ("WindowRollUp") and it uses
    TITLEBARINFO ti.cbSize=sizeof(TITLEBARINFO)
    GetTitleBarInfo hwnd &ti
    siz 0 ti.rcTitleBar.bottom-ti.rcTitleBar.top hwnd 1
But even with this code I can not detect if the the menubar is visible OR cut off partially.
#2
I solved the issue with a timer, but I am still very much open for a more effective/faster method.
#3
Ron,
if i am reading this correctly i think this is what your after

Function rollupToMenu
Code:
Copy      Help
str md=
;BEGIN MENU
;↑↑ :410
;item 1 :411
;item 2 :412
;item 3 :413
;END MENU

str dd=
;BEGIN DIALOG
;0 "" 0x90CC0AC8 0x0 0 0 246 42 "Dialog" "4"
;3 Edit 0x54030080 0x200 65 15 96 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls 0 0 0 0 0 0 0 0 md)) ret



#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,int-- rollUpDown
,case WM_DESTROY
,if(GetProp(hDlg "qm_roll_cy"))
,,RemoveProp hDlg "qm_roll_cy"
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 410 ;;↑↑|↓↓
,RECT rmb
,int hmenu=GetMenu(hDlg)
,GetMenuItemRect(hDlg hmenu 0 rmb)
,int mbh=(rmb.bottom-rmb.top)*2-2
,rollUpDown=!rollUpDown
,sub.WindowRollUp(hDlg rollUpDown mbh)
,
ret 1
#sub WindowRollUp
function hwnd !up [mh];;up: 1 roll up, 0 restore

;Resizes window so that only the title bar and the menu bar is visible.
;hwnd - window handle.

int hmenu2
if up
,if(GetProp(hwnd "qm_roll_cy")) ret
,int cy
,GetWinXY hwnd 0 0 0 cy hwnd
,SetProp hwnd "qm_roll_cy" cy
,TITLEBARINFO ti.cbSize=sizeof(TITLEBARINFO)
,GetTitleBarInfo hwnd &ti
,int mbh= (ti.rcTitleBar.bottom-ti.rcTitleBar.top) +mh
,str md2=
,;BEGIN MENU
,;↓↓ :410
,;END MENU

,hmenu2=DT_CreateMenu(md2)
,DT_SetMenu hwnd hmenu2
,siz 0 mbh hwnd 1
else
,cy=GetProp(hwnd "qm_roll_cy")
,if(!cy) ret
,RemoveProp hwnd "qm_roll_cy"
,str md1=
,;BEGIN MENU
,;↑↑ :410
,;item 1 :411
,;item 2 :412
,;item 3 :413
,;END MENU
,
,hmenu2=DT_CreateMenu(md1)
,DT_SetMenu hwnd hmenu2    
,siz 0 cy hwnd 1
#4
That's almost what I meant.
The user could resize manually the height so it cut's off the upper menubar or completely makes it not visible:

Example

[Image: 1.jpg]

I resolved it with a timer.
But I thought maybe there is a way to do this more effectively through WM_SIZE / WM_SIZING
Thank you for your example though!
#5
WM_SIZE will not work properly in this case

Need to use a combination of WM_SIZING and WM_EXITSIZEMOVE messages to detect when the user resizes the window and the menu is covered or partially covered by the window.

WM_EXITSIZEMOVE is fired when the user releases the mouse after a resize or move

example below resizes window to show menu if menu becomes covered or partially covered.

Function RollupToMenu
Code:
Copy      Help
str md=
;BEGIN MENU
;↑↑ :410
;item 1 :411
;item 2 :412
;item 3 :413
;END MENU

str dd=
;BEGIN DIALOG
;0 "" 0x90CC0AC8 0x0 0 0 246 42 "Dialog" "4"
;3 Edit 0x54030080 0x200 65 15 96 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls 0 0 0 0 0 0 0 0 md)) ret

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,int-- RollUpDown WindowWasResized
,int dw dh
,case WM_DESTROY
,if(GetProp(hDlg "qm_roll_cy"))
,,RemoveProp hDlg "qm_roll_cy";;remove prop is user closes the window rolled up
,case WM_EXITSIZEMOVE
,if WindowWasResized = 1
,,GetWinXY hDlg 0 0 dw dh
,,if dh<59 and dh>=39
,,,siz 0 59 hDlg 1
,,WindowWasResized = 0
,case WM_SIZING
,if WindowWasResized = 0
,,WindowWasResized = 1;;indicates the the user is resizing and not moving the window
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 410 ;;↑↑|↓↓
,RECT rmb
,int hmenu=GetMenu(hDlg)
,GetMenuItemRect(hDlg hmenu 0 rmb)
,int mbh=(rmb.bottom-rmb.top)*2-2
,RollUpDown=!RollUpDown
,sub.WindowRollUp(hDlg RollUpDown mbh)

ret 1
#sub WindowRollUp
function hwnd !up [mh];;up: 1 roll up, 0 restore

;Resizes window so that only the title bar and the menu bar is visible.
;hwnd - window handle.

int hmenu2
if up
,if(GetProp(hwnd "qm_roll_cy")) ret
,int cy
,GetWinXY hwnd 0 0 0 cy hwnd
,SetProp hwnd "qm_roll_cy" cy
,TITLEBARINFO ti.cbSize=sizeof(TITLEBARINFO)
,GetTitleBarInfo hwnd &ti
,int mbh= (ti.rcTitleBar.bottom-ti.rcTitleBar.top) +mh
,str md2=
,;BEGIN MENU
,;↓↓ :410
,;END MENU

,hmenu2=DT_CreateMenu(md2)
,DT_SetMenu hwnd hmenu2
,siz 0 mbh hwnd 1
else
,cy=GetProp(hwnd "qm_roll_cy")
,if(!cy) ret
,RemoveProp hwnd "qm_roll_cy"
,str md1=
,;BEGIN MENU
,;↑↑ :410
,;item 1 :411
,;item 2 :412
,;item 3 :413
,;END MENU
,
,hmenu2=DT_CreateMenu(md1)
,DT_SetMenu hwnd hmenu2    
,siz 0 cy hwnd 1
#6
Perfect, this works!
Thank you!


Forum Jump:


Users browsing this thread: 1 Guest(s)