IonicWind Software

Creative Basic => General Questions => Topic started by: Techno on June 11, 2015, 11:44:36 pm

Title: Linking Resources to my Win32 Application
Post by: Techno on June 11, 2015, 11:44:36 pm
Dear support,

How can I linking my extern resource file with the extention .rc or .res to my application?.
I don't find any comments how I can do this in Creative Basic ?. Can you explean the steps with an example how I can do this

Thanks
Stephane
Title: Re: Linking Resources to my Win32 Application
Post by: LarryMc on June 12, 2015, 12:43:42 am
Never actually tried it because I don't use CB but this is the way it is suppose to work.

name your rc file the same as your exe file
i.e. myprog.exe myprog.rc with both in same folder and then compile it
make sure the resource paths are correct in the rc file.

Now, when you just run your program from inside the IDE there will be no resources.
They will only be there when you run the exe file.
Title: Re: Linking Resources to my Win32 Application
Post by: Techno on June 12, 2015, 01:42:48 am
Quote from: LarryMc on June 12, 2015, 12:43:42 am
Never actually tried it because I don't use CB but this is the way it is suppose to work.

name your rc file the same as your exe file
i.e. myprog.exe myprog.rc with both in same folder and then compile it
make sure the resource paths are correct in the rc file.

Now, when you just run your program from inside the IDE there will be no resources.
They will only be there when you run the exe file.



Thanks

What is the correct path syntax?. I ask this because there is always a runtime error

Posiibly 1
Code Select


100 RTIMAGE "b://test/candle.jpg"
101 RTIMAGE "b://test/holly.jpg"
102 RTIMAGE "b://test/mirror.jpg"
103 RTIMAGE "b://test/flame1.jpg"
104 RTIMAGE "b://test/flame2.jpg"
105 RTIMAGE "b://test/flame3.jpg"
106 RTIMAGE "b://test/flame4.jpg"
107 RTIMAGE "b://test/flame5.jpg"
108 256 "b://test/sn.wav"



Code Select


100 RTIMAGE "b:\test\candle.jpg"
101 RTIMAGE "b:\test\holly.jpg"
102 RTIMAGE "b:\test\mirror.jpg"
103 RTIMAGE "b:\test\flame1.jpg"
104 RTIMAGE "b:\test\flame2.jpg"
105 RTIMAGE "b:\test\flame3.jpg"
106 RTIMAGE "b:\test\flame4.jpg"
107 RTIMAGE "b:\test\flame5.jpg"
108 256 "b:\test\sn.wav"



Code Select

' just a little Creative program for Christmas ..
' GWS 2007

DEF w : WINDOW
DEF wstyle : INT
DEF key : INT
DEF run : INT
DEF candle : INT
DEF holly : INT
DEF mirror : INT
DEF n : INT
DEF c[6] : INT
DEF red : INT
DEF grn : INT
DEF blu : INT
DEF twopi : INT
DEF th : FLOAT
'DEF song : MEMORY

AUTODEFINE "OFF"
DECLARE Rn(low:INT,high:INT)
wstyle = @size|@minbox|@maxbox

'===============================================================
'Main Program
'===============================================================
WINDOW w,-800,0,800,600,wstyle,0,"Happy Christmas 2007",handler
SETWINDOWCOLOR w,rgb(0,0,20)
CONTROL w,"B, Exit, (800-65)/2, 510, 65, 32, @ctlbtnflat, 1"
SETCONTROLCOLOR w,1,rgb(0,150,190),rgb(0,50,100)
CENTERWINDOW w
twopi = 8 * atan(1)

' load song into memory.  (Note: Custom file type has to be >255)
LOADRESOURCE(108, 256, song)
PLAYWAVE song, @sndasync|@sndloop

candle = LOADIMAGE(100, @imgscalable)
holly  = LOADIMAGE(101, @imgscalable)
mirror = LOADIMAGE(102, @imgscalable)

' load images ..
c[1] = LOADIMAGE(103,@imgscalable)
c[2] = LOADIMAGE(104,@imgscalable)
c[3] = LOADIMAGE(105,@imgscalable)
c[4] = LOADIMAGE(106,@imgscalable)
c[5] = LOADIMAGE(107,@imgscalable)

SHOWIMAGE w,holly,4,150,245,220,220
SHOWIMAGE w,candle,4,96,157,60,180
SHOWIMAGE w,mirror,4,300,-10,180,280
' reflection ..
SHOWIMAGE w,candle,4,385,132,15,50

n = 3
th = 0.0
STARTTIMER w,200,1
STARTTIMER w,200,2
SETFONT w,"Times New Roman",48,500,@SFITALIC
run = 1

WAITUNTIL run = 0
STOPTIMER w,1
STOPTIMER w,2

FOR i = 1 to 5
DELETEIMAGE c[i], @IMGBITMAP
NEXT i

DELETEIMAGE candle,4
DELETEIMAGE holly,4
DELETEIMAGE mirror,4

FREEMEM song

CLOSEWINDOW w
END

sub handler:
SELECT @CLASS
CASE @IDCLOSEWINDOW
  run = 0

CASE @IDCHAR
' pressing the 'ESC'(ape) key will stop the program ...
    key = @CODE
IF (key = 27) THEN run = 0

CASE @IDCONTROL
SELECT @CONTROLID
' clicking the Exit button ...
CASE 1
run = 0
ENDSELECT

CASE @IDTIMER
'Timer 1?
IF (@CODE = 1) THEN
flame
ENDIF

'Timer 2?
IF (@CODE = 2) THEN
shade
ENDIF
ENDSELECT
RETURN

SUB Rn(low, high)
' generates a random number between Low and High ..
n = int((high - low + 1) * rnd(1.0) + low)
RETURN n

SUB shade
' slowly change the text color ..
th = th + 0.04
red = 127.5 * (1 + COS(th))
grn = 127.5 * (1 + COS(th + twopi/3))
blu = 127.5 * (1 + COS(th + 2 * twopi/3))

FRONTPEN w,RGB(red,grn,blu)
MOVE w,450,250
PRINT w,"Merry"
MOVE w,450,350
PRINT w,"Christmas"
RETURN

sub flame
' choose the next flame position
SELECT n
CASE 1
n = Rn(1,2)
CASE 2
n = Rn(1,3)
CASE 3
n = Rn(2,4)
CASE 4
n = Rn(3,5)
CASE 5
n = Rn(4,5)
ENDSELECT

SHOWIMAGE w,c[n],@IMGSCALABLE,100,65,50,90
' reflection ..
SHOWIMAGE w,c[n],@IMGSCALABLE,385,107,14,24
RETURN

Title: Re: Linking Resources to my Win32 Application
Post by: LarryMc on June 12, 2015, 02:23:21 am
the 2nd path format is the correct one.

and you get a runtime error when you run the exe file?
Title: Re: Linking Resources to my Win32 Application
Post by: Techno on June 12, 2015, 02:51:51 am
Quote from: LarryMc on June 12, 2015, 02:23:21 am
the 2nd path format is the correct one.

and you get a runtime error when you run the exe file?


Yes it give me a runtime error when I execute te file.