Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sets width and height of dialog
#1
Hi,

I want to set the width and height of the dialog via hotkey(Alt+A)
dialog width and height, The definitions before and after the adjustment are as follows

 size before:
 0 "" 0x90C80AC8 0x0 0 0 112 30 "Dialog" "4"

 size after:
 0 "" 0x90C80AC8 0x0 0 0 216 144 "Dialog" "4"

What is the relationship between width and height and pixel size in the definition

Using the width and height in the definition directly, the final effect cannot be achieved

[Image: 1672287630]
Macro Macro3
Code:
Copy      Help
;size before:
;0 "" 0x90C80AC8 0x0 0 0 112 30 "Dialog" "4"

;size after:
;0 "" 0x90C80AC8 0x0 0 0 216 144 "Dialog" "4"

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 112 30 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 8 96 12 ""
;4 ListBox 0x54230101 0x200 112 8 96 130 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

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


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "401 Aa") ;;Alt+A
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case 401
;,;int x y w h
;,;GetWinXY hDlg x y w h
,siz 216 144 hDlg
,case IDCANCEL
ret 1
#2
Success, there may be an easier way
 
Code:
Copy      Help
,case 401
,int x y w h
,GetWinXY hDlg x y w h
,w=w*216/112-4
,h=h*(144-30)/30-30+2
,siz w h hDlg
#3
Using the width and height of the client area directly is wrong. Why Huh


Code:
Copy      Help
,case 401
,int x y w h
,RECT r
,DpiGetWindowRect hDlg r 4
,h=r.bottom
,w=r.right
,w=w*216/112
,h=h*144/30
,siz w h hDlg
#4
you're not accounting for the non-client area of the window.
there is a built in windows function to convert dialog units to pixels

use this
Code:
Copy      Help
,case 401
,RECT r r1 r2;
,r.left = 0; r.top = 0; r.right = 216; r.bottom = 144;
,MapDialogRect(hDlg &r)
,DpiGetWindowRect hDlg r1 4; DpiGetWindowRect hDlg r2 
,int ncah=(r2.bottom-r2.top) - (r1.bottom-r1.top)
,int ncaw=(r2.right-r2.left) - (r1.right-r1.left)
,siz r.right+ncaw r.bottom+ncah hDlg
#5
Thank you for your help

1.How to make the dialog expand up so that the list box appears above the edit box (the picture below)
I've seen this effect before

2.How to switch two window sizes after pressing alt+a multiple times

[Image: 1672439673]


Forum Jump:


Users browsing this thread: 1 Guest(s)