In-Memory Dialogs

Windows specific questions.
Macq
Posts: 24
Joined: Feb 18, 2021 4:01
Location: Queensland, Australia

Re: In-Memory Dialogs

Post by Macq »

Hi Dave.

This is from the main window proceedure of a program where I ask for parameters to be entered.

Code: Select all

Case 201: ' Options - Match Fit
    dim as LPDLGTEMPLATE lpdt
    ' 1st param is "cdit" & must match number of controls defined. top left, bottom right, "Title", template
     Dialog( 12, 0, 0, 180, 116, "Set Options", lpdt, WS_OVERLAPPED or WS_SYSMENU or DS_CENTER )
     Rtext(1,36,8,45,8,"Match Fit:")
     EditText(201,83,8,16,10,"",WS_BORDER or WS_TABSTOP)
     Rtext(1,36,22,45,22,"Aspect Fit:")
     EditText(202,83,22,16,10,"",WS_BORDER or WS_TABSTOP)
     Rtext(1,36,36,45,36,"Threads:")
     EditText(203,83,36,16,10,"",WS_BORDER or WS_TABSTOP)
     Rtext(1,36,50,45,50,"Matches:")
     EditText(204,83,50,16,10,"",WS_BORDER or WS_TABSTOP)
     Rtext(1,36,64,45,64,"Dup Fit:")
     EditText(205,83,64,16,10,"",WS_BORDER or WS_TABSTOP)
     DefPushButton( IDOK, 33, 79, 50, 14, "Ok", WS_TABSTOP )
     PushButton( IDCANCEL, 95, 79, 50, 14, "Cancel", WS_TABSTOP )
     CreateModalDialog( 0, @DialogProc, 0, lpdt ) ' Don't use hWnd here because it prevents the tabstops working correctly!
and here is the dialog proceedure

Code: Select all

function DialogProc( byval hDlg as  HWND, _
                     byval uMsg as UINT, _
                     byval wParam as WPARAM, _
                     byval lParam as LPARAM ) as integer

    select case uMsg
        case WM_INITDIALOG
        SetDlgItemText(hDlg,201,str(OptionMatchFit))
        SetDlgItemText(hDlg,202,str(OptionAspectFit))
        SetDlgItemText(hDlg,203,str(OptionMaxThread))
        SetDlgItemText(hDlg,204,str(OptionNumCells))
        SetDlgItemText(hDlg,205,str(OptionDupFit))

        case WM_COMMAND
            dim as Zstring * 10 Zbuf
            if hiword(wParam) = BN_CLICKED then
                if loword(wParam) = IDOK then

                    GetDlgItemText(hDlg,201,@Zbuf,9) 
                    OptionMatchFit = valUint(Zbuf)
                    if(OptionMatchFit > 999) then OptionMatchFit = 999
                    if(OptionMatchFit < 2) then OptionMatchFit = 2

                    GetDlgItemText(hDlg,202,@Zbuf,9)
                    OptionAspectFit = val(Zbuf)
                    if(OptionAspectFit > 0.9) then OptionAspectFit = 0.9
                    if(OptionAspectFit < 0.1) then OptionAspectFit = 0.1

                    GetDlgItemText(hDlg,203,@Zbuf,9)
                    OptionMaxThread = valuint(Zbuf)
                    if(OptionMaxThread > MAXTHREAD+1) then OptionMaxThread = MAXTHREAD+1
                    if(OptionMaxThread < 1) then OptionMaxThread = 1

                    GetDlgItemText(hDlg,204,@Zbuf,9)
                    OptionNumCells = valuint(Zbuf)
                    if(OptionNumCells > NUMCELLS) then OptionNumCells = NUMCELLS
                    if(OptionNumCells < 4) then OptionNumCells = 4

                    GetDlgItemText(hDlg,205,@Zbuf,9)
                    OptionDupFit = Valuint(Zbuf)
                    if(OptionDupFit < 2)  then OptionDupFit = 2
                    if(OptionDupFit > 10) then OptionDupFit = 10

                    EndDialog( hDlg, null )

                elseif loword(wParam) = IDCANCEL then
                    EndDialog( hDlg, null )
                end if
            end if

        case WM_CLOSE
            EndDialog( hDlg, null )
    end select
    return 0
end function
softfoot
Posts: 43
Joined: Aug 31, 2020 3:45

Re: In-Memory Dialogs

Post by softfoot »

Thanks that's very helpfull
Dave
softfoot
Posts: 43
Joined: Aug 31, 2020 3:45

Re: In-Memory Dialogs

Post by softfoot »

Can someone please post the current download link - the last one seems dead
Regards,
TIA Dave
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: In-Memory Dialogs

Post by srvaldez »

Post Reply