Page 2 of 2

Re: Several icons in an EXE

Posted: Fri Jan 22, 2010 8:35 pm
by Edwin Knoppert
MS RC.exe handles one or more include folders to be set.
You could ask to use the main file's folder one of these folders.

If that case you could also use subfolders like:
ICON1 ICON "images\\icon1.ico"

Re: Several icons in an EXE

Posted: Fri Jan 22, 2010 8:57 pm
by ts-soft
Edwin Knoppert wrote:MS RC.exe handles one or more include folders to be set.
You could ask to use the main file's folder one of these folders.

If that case you could also use subfolders like:
ICON1 ICON "images\\icon1.ico"
PORC.exe (comes with PB) supports the same, but the PB-IDE doesn't set a path.
Pelles C - Help wrote: /I option (PORC)


Syntax:
/I path



Description:
The /I option adds a new path where the resource compiler should look for #include files, or files specified in ANICURSOR, ANIICON, BITMAP, CURSOR, HTML, ICON, MANIFEST, MESSAGETABLE, PLUGPLAY or VXD statements.

Re: Several icons in an EXE

Posted: Fri Jan 22, 2010 9:13 pm
by Michael Vogel
ts-soft wrote:create a "myresource.res" with porc from your script and import this!
Hey, the best one, thanks!

And porc accepts all types of paths, relative and absolute :D
So I'm wondering if porc is not used by PB or the IDE makes something wrong - why else you need absolute pathes here :twisted:

Michael

PS another (tiny) issue concerning resource files within the IDE: if add a new rc file via file selector and choose the file by a double click, the compiler options get closed :?:

PSS wrote a small tool which "automatically" generates the RES file:
[-] you still need to write the RC file and add the Import "File.Res" into the source
[+] you don't have to use the command line, search for the porc.exe etc.

Code: Select all

; • "Tool PorcMeUp.exe" is located in directory "...\Purbasic\Catalogs\
;
; • Configuration of the Tool
;	%COMPILEFILE\..\Catalogs\Tool PorcMeUp.exe
;	"%TEMPFILE" "%PATH"
;	%COMPILEFILE\..
;
;	Auto &Indent
;	Menu Or Shortcut
;
; - Wait until tool quits
; - Reload Source after tool has quit
; - into the current source

; • written by Michael Vogel...

Procedure Init()

	; Dateinamen holen...
	If CountProgramParameters()<>2
		MessageBox_(0,"'Porc Me Up' needs two parameters!"+#CR$+"Add %TEMPFILE and %PATH to configuration","Error",#MB_ICONERROR|#MB_OK)
		End
	EndIf

	Global SourceFile.s=ProgramParameter()
	Global SourcePath.s=ProgramParameter()
	Global FileRC.s=""
	Global FileRES.s=""

EndProcedure
Procedure Doit()

	Protected z.s
	Protected l.s
	Protected n
	Protected m

	Init()

	ReadFile(1,SourceFile)

	While Not(Eof(1))
		z=ReadString(1)
		l=LCase(z)

		n=FindString(l,"import ",1)
		If n
			z=Trim(z)
			z=Trim(z,#TAB$)
			l=LCase(z)

			If FindString(l,"import ",1)=1
				n=FindString(l,".res",1)
				If n
					m=FindString(l,#DQUOTE$,1)
					FileRES=Mid(z,m+1,n-m+3)
					Break
				EndIf
			EndIf
		EndIf

	Wend

	CloseFile(1)
	
	If Len(FileRes)=0
		MessageBox_(0,"'Porc Me Up' has nothing to do..."+#CR$+"Import ''Resource.Res'' missing!","Error",#MB_ICONERROR|#MB_OK)
	Else
		FileRC=Left(FileRES,Len(FileRES)-2)+"c"
		n=RunProgram(#PB_Compiler_Home+"Compilers\porc.exe",#DQUOTE$+FileRC+#DQUOTE$,SourcePath,#PB_Program_Hide)
		MessageBox_(0,"'Porc Me Up' has generated '"+FileRES+"'..."+#CR$+"Porc's Return Value = "+Str(n),"Information",#MB_ICONINFORMATION|#MB_OK)
	EndIf

EndProcedure

Doit()

Re: Several icons in an EXE

Posted: Wed Jan 11, 2012 7:43 pm
by Michael Vogel
Actually, including multiple icons (resources) into a compiled purebasic program is not perfect -- using a 'rc' file don't work with relative path names.

Feature Request: please think about allowing an alternative method (adding multiple file names into the icon field, parsing the 'rc' file to correct the path names, modifying the linker etc.) to support relative path names...

Re: Several icons in an EXE

Posted: Wed Mar 14, 2012 5:56 pm
by Randy Walker
First create your windows in the normal fashion. Then use WM_SETICON to apply any icon to any window:

Code: Select all

Enumeration      ; Whatever you want to call your windows :)
  #Main_Window
  #Sub_Window_1
  #Sub_Window_2
  #Sub_Window_3
EndEnumeration

; << Create your windows here, and afterward, apply icons as indicated below:

If FileSize("C:\aaaa\bbbb\image1.ico") > 0
  image1hndl = LoadImage(#Sub_Window_1, "C:\aaaa\bbbb\image1.ico")
  SendMessage_(WindowID(#Sub_Window_1), #WM_SETICON, 1, image1hndl)
EndIf
If FileSize("C:\aaaa\bbbb\image2.ico") > 0
  image2hndl = LoadImage(#Sub_Window_2, "C:\aaaa\bbbb\image2.ico")
  SendMessage_(WindowID(#Sub_Window_2), #WM_SETICON, 1, image2hndl)
EndIf
If FileSize("C:\aaaa\bbbb\image3.ico") > 0
  image3hndl = LoadImage(#Sub_Window_3, "C:\aaaa\bbbb\image3.ico")
  SendMessage_(WindowID(#Sub_Window_3), #WM_SETICON, 1, image3hndl)
EndIf
; etc,etc,etc...
Err, uhhhh... maybe I didn't understand the intent of this tip. What was the question? :lol:

Re: Several icons in an EXE

Posted: Wed Mar 14, 2012 6:09 pm
by skywalk
I do what Randy does, but use IncludeBinary...

Code: Select all

DataSection
  ImageList:  Data.i ?Image_1, ?Image_2, ?Image_3
  Image_1:    IncludeBinary "C:\icon\my1.ico"
  Image_2:    IncludeBinary "C:\icon\my2.ico"
  Image_3:    IncludeBinary "C:\icon\my3.ico"
EndDataSection