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

Started by HJH, June 12, 2005, 12:02:55 PM

Previous topic - Next topic

HJH

Hello



I successfully used on a command promptnewlisp link.lisp (see http://www.newlisp.org/downloads/newlisp_manual.html#linking">//http://www.newlisp.org/downloads/newlisp_manual.html#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

HPW

#1
I think newlisp.exe has no icon-resource.

You may try the run wrapper from Peter:



http://www.turtle.dds.nl/run/index.html">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.
Hans-Peter

HPW

#2
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/">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!
Hans-Peter

HJH

#3
Quote from: "HPW"...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!




Quote from: "HPW"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 (import "kernel32.DLL" "GetStdHandle")

See entry http://www.alh.net/newlisp/phpbb/viewtopic.php?t=688">//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

HPW

#4
How about:



(import "user32.dll" "MessageBoxA")

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

Hans-Peter

HJH

#5
It works fine in the 1.4MB  newlisp-tk.exe but not in the 210kB newlisp.exe



--HJH

HJH

#6
Why does
(import "user32.dll" "MessageBoxA")

(MessageBoxA 0 "Content" "Caption" 0)

not work in newlisp.exe (210kB exe)?



--HJH

Sammo

#7
Hmmm...



With my 186.5KB newlisp.exe ("newLISP v.8.6.0 on Win32 MinGW") running on win2K sp4, the code example works perfectly.
(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.

HPW

#8
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



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.
Hans-Peter

Lutz

#9
>> 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

HJH

#10
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

HPW

#11
Adding this to init.lsp

(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")
Hans-Peter