1. ShellExecute problem

Hi there,

I'm extremely new to Euphoria (first day and working on a first program), and I have a question. I hope this is the right place to put it.

In my first program I use a ShellExecute command from Win32Lib by David Cuny and friends to launch Internet Explorer, but I get an error message (Windows messagebox, not in the error-log) : "ShellExecute requires a WinMain". Fine, but how can I create a WinMain ?

Could somebody help me on this, or point me in the direction of a specialist ?

Regards,

Dirk.

new topic     » topic index » view message » categorize

2. Re: ShellExecute problem

Rael said...

I'm extremely new to Euphoria (first day and working on a first program)

I hope the example below is not too much culture shock then. This program, shexec.exw, along with many others can be found in the demo folder distributed with the win32lib library.


include win32lib.ew 
without warning 
constant mWin  = create(Window,  "Shell Execute Sample",0,  0, 0, 460,300, 0), 
         btn   = create(PushButton, "&Run", mWin,  5,   5, 50, 25, 0), 
         verbl = create(LText,   "Verb:",   mWin,  5,  95, 60, 25, 0), 
         verb  = create(EditText, "open",   mWin, 70,  95, 350, 25, 0), 
         filel = create(PushButton,   "File:",   mWin,  5, 125, 60, 25, 0), 
         file  = create(EditText, "C:\\",   mWin, 70, 125, 350, 25, 0), 
         parml = create(LText,   "Params:", mWin,  5, 155, 60, 25, 0), 
         parm  = create(EditText, "",       mWin, 70, 155, 350, 25, 0), 
         ddirl = create(LText,   "Dir:",    mWin,  5, 185, 60, 25, 0), 
         ddir  = create(EditText, "",       mWin, 70, 185, 350, 25, 0), 
         SB    = create(StatusBar, "",      mWin, 0, 0, 0, 0, 0) 
 
procedure Doit(integer self, integer event, sequence parms) 
    integer x 
    x = shellExecuteEx(getText(verb), 
                     getText(file), 
                     getText(parm), 
                     getText(ddir), 
                     SW_SHOWNORMAL, 
                     0) 
    showMessage(sprintf("Result = %d", {x})) 
end procedure 
setHandler(btn, w32HClick, routine_id("Doit")) 
 
procedure FindFile(integer self, integer event, sequence parms) 
sequence theFile 
 
    theFile = getOpenFileName(mWin, getText(file), 
                          { "dialog flags", 
                {OFN_EXPLORER,       -- looks like windows explorer 
                 OFN_HIDEREADONLY,   -- hide the read-only checkbox 
                 OFN_LONGNAMES      -- use long filenames 
                    }, 
                          "All Files (*.*)", "*.*"}) 
    setText(file, theFile) 
end procedure 
setHandler(filel, w32HClick, routine_id("FindFile")) 
 
WinMain(mWin, Normal) 

The WinMain() function is the starting point for win32lib programs. Its first parameter is the primary window for the application and this is the "mainwin" that the error message talks about.

new topic     » goto parent     » topic index » view message » categorize

3. Re: ShellExecute problem

Rael said...

Hi there,

I'm extremely new to Euphoria (first day and working on a first program), and I have a question. I hope this is the right place to put it.

In my first program I use a ShellExecute command from Win32Lib by David Cuny and friends to launch Internet Explorer, but I get an error message (Windows messagebox, not in the error-log) : "ShellExecute requires a WinMain". Fine, but how can I create a WinMain ?

Could somebody help me on this, or point me in the direction of a specialist ?

Regards,

Dirk.

Hi, Dirk.

You might want to grab a copy of the "Enhanced IDE" otherwise known as the Win32Lib IDE, also by David, but now extended and maintained by Judith Evans. It will allow you build a simple program that has the WinMain built in.

Mike

new topic     » goto parent     » topic index » view message » categorize

4. Re: ShellExecute problem

Thanks DerekParnell and Mike777,

I'll give it a try in the morning.

Although I don't really understand why a window has to be created (can it be invisible ? I might find this out when reading the IDE documentation) for a ShellExecute that is mainly instructing Internet Explorer to pop up. Doesn't IE create it's own window ? Yet another question that pops into my mind: how do I instruct the invoked IE (or any other windows app that might be invoked in the ShellExecute) to use that WinMain ?

Anyway, I will keep you informed about the progress I make.

Thanks for the help.

Regards,

Dirk.

new topic     » goto parent     » topic index » view message » categorize

5. Re: ShellExecute problem

This should make for some interesting discussion, and you are in for a heavy learning experience, because, put simply, Windows doesn't work the way you think it does. Not at all. That's why there are thick books written about it. :) good luck!

new topic     » goto parent     » topic index » view message » categorize

6. Re: ShellExecute problem

Hi there,

Good news ! I took a look at the win32lib routines for ShellExecute and ShellExecuteEx, and found the errormessage. Aparantly the ShellExecuteEx absolutely wants to pass a window identifier to the underlying Windows ShellExecute function. But in the microsoft documentation it is stated that ShellExecute can do without that identifier (NULL value allowed), and as my ShellExecute is not needing a window (it spawns IE: ShellExecute("open","\Somepath\index.html", SW_SHOWNORMAL) ), I've copied and modified David Cuny's ShellExecuteEx into my app, and you know what : IT WORKS !

Thanks all for helping !

Regards,

Dirk.

new topic     » goto parent     » topic index » view message » categorize

7. Re: ShellExecute problem

Rael said...

Hi there,

Good news ! I took a look at the win32lib routines for ShellExecute and ShellExecuteEx, and found the errormessage. Aparantly the ShellExecuteEx absolutely wants to pass a window identifier to the underlying Windows ShellExecute function. But in the microsoft documentation it is stated that ShellExecute can do without that identifier (NULL value allowed), and as my ShellExecute is not needing a window (it spawns IE: ShellExecute("open","\Somepath\index.html", SW_SHOWNORMAL) ), I've copied and modified David Cuny's ShellExecuteEx into my app, and you know what : IT WORKS !

Thanks all for helping !

Regards,

Dirk.

You may wish to read the documentation for WinMain(). It allows for not using a main window at all, although this is not used very often that I know. I'll have to include a demo about this I guess.

CChris

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu