Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move the ok button based on if dialog is maximized or not
#1
Is there a way to change the size and shape of the OK button based on if the dialog is maximized or not?

Example:
If Dialog is maximized the OK button will look and be in its normal position in a normal dialog. If Dialog is not maximized then the OK button will start at left of bottom of the dialog and continua to the right bottom of the dialog.

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

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

;BEGIN DIALOG
;0 "" 0x90CF0A44 0x100 0 0 222 134 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_SIZE
,if(IsZoomed(win("Dialog" "#32770")))
,,MoveWindow id(1 win("Dialog" "#32770")) 182 189 70 24 1
,if(!IsZoomed(win("Dialog" "#32770")))
,,;Get window size and adjust edit box to match //
,,int x y width height
,,GetWinXY(hDlg &x &y &width &height)
,,siz width-9 height-65 id(1 hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

It is that left bottom and right bottom part that I am having problems with. How do you find the left and right part of the dialog then change the size of the ok button based on it?
#2
Function Move_ok_botton
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

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

;BEGIN DIALOG
;0 "" 0x90CF0A44 0x100 0 0 222 134 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_SIZE
,
,;;GetWinXY(hwnd [&x] [&y] [&width] [&height] [hwndparent])
,
,;;GetWinXY gets coordinates of main window
,int x y cx cy
,GetWinXY(win("Dialog" "#32770") x y cx cy)

,
,;;MoveWindow hWnd x y nWidth nHeight bRepaint

,;;MoveWindow not only moves the control, but also resizes
,;;nWidth=72 and nHeight=23 are size of the button
,;;cx and cy the size of the main window...those are the coordinates of the bottom right corner
,;;therfore x=cx-160 and y=cy-63 (subtracting values pads the distance from bottom corner)
,MoveWindow id(1 win("Dialog" "#32770")) cx-160 cy-63 72 23 1
,
,;;moves the Cancel Button per same as OK button
,MoveWindow id(2 win("Dialog" "#32770")) cx-85 cy-63 72 23 1
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

nice tight and neat...(so you can run this as a separate function if you wish...well without the case WM_SIZE. I usually try to run different function just to make life simple in the main dialog.)
Code:
Copy      Help
,case WM_SIZE
,int x y cx cy;GetWinXY(win("Dialog" "#32770") x y cx cy)
,MoveWindow id(1 win("Dialog" "#32770")) cx-160 cy-63 72 23 1
,MoveWindow id(2 win("Dialog" "#32770")) cx-85 cy-63 72 23 1
#3
I took a look at this and it is more than I asked for and thought could be done and so quick. I will study it and I want the ok button to follow the left edge of the dialog but I am sure that it can do that.

As far as the separate function I do not know how to make one of those yet.

Thank you
#4
Here is an example of putting it in a different function and running it...
.qml   Move Resize OK.qml (Size: 908 bytes / Downloads: 369)
#5
I do not understand. I thought functions where created something like this

Example

Function fileext
Code:
Copy      Help
;/
function lpstr'f str&e

int i=findcr(f '.')
if(i>=0) e.get(f i)
else e=""
ret i
#6
Yep..that too...but if there are no variables you can just kind of use them to consolidate code...

Tweeked the code above...had made a mistake.
#7
Here is an example passing variables:

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

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

;BEGIN DIALOG
;0 "" 0x90CF0A44 0x100 0 0 222 134 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_SIZE
,int x y cx cy;GetWinXY(win("Dialog" "#32770") x y cx cy)
,OK_MoveResize1 x y cx cy
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Function OK_MoveResize1
Code:
Copy      Help
function int&x int'y int'cx int'cy

MoveWindow id(1 win("Dialog" "#32770")) cx-160 cy-63 72 23 1
MoveWindow id(2 win("Dialog" "#32770")) cx-85 cy-63 72 23 1
,
#8
You keep giving my brain new things to think about and I do mean think about.

Why are there so many ways to do functions? Is it just because that was an example of passing or is one way better than the other?


Forum Jump:


Users browsing this thread: 1 Guest(s)