Re: How Do I RUN or OPEN found file .. Win32Lib programme ..

new topic     » goto parent     » topic index » view thread      » older message » newer message

Dan Moyer wrote:
> 
> Les Rogers wrote:
> > 
> > 
> > Hello,
> > 
> > The programme from Win32Lib is openfile.exw.

> Now that I actually *run* it, that demo *does* work, though it doesn't
> give any info as to how to *use* it.

Yes it runs, but it is still a horrible 'example' program. Here is a somewhat
better example ...

include win32lib.ew
integer theWindow
integer btnGetFile
integer txtFile

procedure click_GetFile(integer self, integer event, sequence parms)
    sequence lFileName
    integer lTxtWidth
    integer lTxtHeight
    sequence lRect

    -- Open the dialog and get the user's response.
    lFileName = getOpenFileName(theWindow, "", {"All Files", "*.*"})
    if length(lFileName) = 0 then
        return  -- User cancelled the dialog.
    end if

    -- Adjust the area on screen to show the selected filename.
    lTxtHeight = getTextHeight(txtFile, lFileName) + 2
    lTxtWidth = getTextWidth(txtFile, lFileName) + 2
    lRect = getClientRect(txtFile)
    setClientRect(txtFile, lTxtWidth, lTxtHeight)

    -- Now make sure that the window can show the whole text area.
    lRect = getClientRect(theWindow)
    if lRect[3] < lTxtWidth + 10  then
        setClientRect(theWindow, lTxtWidth + 10, lRect[4])
    end if

    -- Show the selected file name
    setText( txtFile, lFileName)
    setVisible(txtFile, 1)

end procedure

procedure main(sequence Args)


    theWindow = create(Window, "User Selected File", 0, 0, 0, 
                                    400, 100,0)
    btnGetFile = create(Button, "Get a File Name", theWindow, 5, 5, 
                                    300, 40, 0)
    txtFile   = create(Label, "", theWindow, 5, 55, 300, 13, WS_BORDER)
    setVisible(txtFile, 0)  -- Initially hide the showing area.

    setHandler(btnGetFile, w32HClick, routine_id("click_GetFile"))

    WinMain( theWindow, Normal)
end procedure

main( command_line() )


-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu