Page 1 of 1

How do I set an icon when using 'newlisp link.lsp'

Posted: Sun Jun 12, 2005 7:02 pm
by HJH
Hello

I successfully used on a command prompt

Code: Select all

newlisp link.lisp
(see http://www.newlisp.org/downloads/newlis ... ml#linking to create a 211kB-non-GUI-MSWindows executable with a newLisp script I wrote.

It is fantastic how easy it is, to create small handy stand-alone Windows apps doing a particular task. (And the installation then is just copy/paste an exe).

My question: Is it possible to add an icon file myIcon.ICO during the linking process?

If I construct several of these programs that would be useful to be able to distinguish them by the icon.

--HJH

Posted: Sun Jun 12, 2005 8:12 pm
by HPW
I think newlisp.exe has no icon-resource.
You may try the run wrapper from Peter:

http://www.turtle.dds.nl/run/index.html

You can compile this wrapper with your own icon or use a tool like resource-hacker to change it.

Posted: Mon Jun 13, 2005 6:00 am
by HPW
The question starts me thinking for a solution:

I tried to add a resource to newLISP.exe with

http://www.users.on.net/johnson/resourcehacker/

and get a new exe with icon. It still works as before with link.lsp
and show the icon in the command-window and the task-bar.

So exactly what you want. So we can make nice small tool with their own icon. Of cource still a command-line interface!

Posted: Mon Jun 13, 2005 8:49 am
by HJH
HPW wrote:...It still works as before with link.lsp
and show the icon in the command-window and the task-bar.

So exactly what you want.
Yes, indeed. I use this approach now. I just do a backup copy of the original 'newlisp.exe' to have it handy for the next time. Thank you for this recommendation!

HPW wrote:So we can make nice small tool with their own icon. Of cource still a command-line interface!
Yes, but often command line tools are just good enough; I collect a couple of file, do some minor processing and write out a result file and a log file. Just the things script languages are meant for.

Of course it would be nice to give the user a visual feedback as well by showing a standard Windows message box ("Success" or "Failure, see log file").

Alex has a nice example using a Win32 function call from

Code: Select all

(import "kernel32.DLL" "GetStdHandle") 
See entry http://www.alh.net/newlisp/phpbb/viewtopic.php?t=688

So it seems it would not be too difficult to call other Win32 functions.

Has somebody the calling sequence just ready? (copy / paste)?

--HJH

Posted: Mon Jun 13, 2005 10:14 am
by HPW
How about:

Code: Select all

 (import "user32.dll" "MessageBoxA")

(MessageBoxA 0 "Content" "Caption" 0)
(MessageBoxA 0 "Content" "Caption" 1)
(MessageBoxA 0 "Content" "Caption" 2)
etc.


Posted: Mon Jun 13, 2005 3:28 pm
by HJH
It works fine in the 1.4MB newlisp-tk.exe but not in the 210kB newlisp.exe

--HJH

Posted: Tue Jun 14, 2005 9:17 pm
by HJH
Why does

Code: Select all

(import "user32.dll" "MessageBoxA") 

(MessageBoxA 0 "Content" "Caption" 0) 
not work in newlisp.exe (210kB exe)?

--HJH

Posted: Tue Jun 14, 2005 11:14 pm
by Sammo
Hmmm...

With my 186.5KB newlisp.exe ("newLISP v.8.6.0 on Win32 MinGW") running on win2K sp4, the code example works perfectly.

Code: Select all

(import "user32.dll" "MessageBoxA") 
(MessageBoxA 0 "Content" "Caption" 0) 
pops up a modal box in the middle of the screen with caption "Caption", content "Content", and an OK button.

Posted: Wed Jun 15, 2005 6:00 am
by HPW
Same observation as Sammo here.
Works for me with all 3 version of current newlisp: TK, EXE and DLL

I also tested with the icon resource version.

File-sizes:
Standard-EXE 8.6.0 MINGW: 190976 Bytes
ICON-EXE 8.6.0 MINGW: 192000 Bytes

Code: Select all

newLISP v.8.6.0 on Win32 MinGW, execute 'newlisp -h' for more info.
> (import "user32.dll" "MessageBoxA")
MessageBoxA <77D504EA>
> (MessageBoxA 0 "Content" "Caption" 0)
1
One observation: Called the first time the messagebox gets behind the console window and is only visible on the task bar.

Posted: Wed Jun 15, 2005 1:09 pm
by Lutz
>> It works fine in the 1.4MB newlisp-tk.exe but not in the 210kB newlisp.exe

the 1.4MB newlisp-tk.exe is just the Tcl/Tk frontend to the smaller newlisp.exe. So when you run newlisp-tk.exe, it launches newlisp.exe and communicated with it via TCP/IP. If it works using newlisp-tk.exe is also must work with newlisp.exe by definition.

Lutz

Posted: Wed Jun 15, 2005 1:23 pm
by HJH
Yes, thank you all for your answers.

In fact the dialog is produced, but it does not show up. The only thing that something happens is a new entry in the taskbar where people do not normally check regularily for new things. So from a usability point of view it is useless.

But let's not use more time with this issue. I just write a text log file as feedback and (exit) newlisp. If I want to do a GUI app I'll stick to the 1.2MB newlisp-tk-combination.

--HJH

Posted: Wed Jun 15, 2005 7:21 pm
by HPW
Adding this to init.lsp

Code: Select all

(define (mymsgbox cont capt)
	(if (not MessageBoxA)
		(import "user32.dll" "MessageBoxA"))
	(MessageBoxA 0 cont capt 0))
seems to solve the display problem on the first call of:
(mymsgbox "Content" "Caption")