::: µ¨ÆÄÀÌ Tip&Trick :::

µ¨ÆÄÀÌ Tip&Trick ¼º°Ý¿¡ ¸ÂÁö ¾Ê´Â ±¤°í,ºñ¹æ,Áú¹®ÀÇ ±ÛÀº Áï½Ã »èÁ¦Çϸç
³»¿ëÀ» º¹»çÇÏ¿© »ç¿ëÇÒ °æ¿ì ¹Ýµå½Ã À̰÷(http://www.howto.pe.kr)À» Ãâó·Î ¸í½ÃÇÏ¿© ÁÖ¼¼¿ä


Category

  ±è¿µ´ë(2003-03-06 21:55:35, Hit : 5351, Vote : 1226
 JPEG, WAVE ¸¦ resource ÆÄÀÏ¿¡ ³Ö°í Àоî¿À±â

Here are the answers to both questions. How to
load a WAVE resource, and ho to load a JPEG
resource.

Joe Hecht


-----------------------------------------------

The following demonstrates creating a resource file containing
a JPEG image, and loading the JPEG file from the resource file.
The resulting JPEG image is displayed in a Image component.

1) Create a text file with the extension of ".rc". The text file should
be
named something different than the project name or any unit name
in your application to avoid any confusion for the compiler. The
text file should contain the following line:

MYJPEG JPEG C:DownLoadMY.JPG

Where:
"MYJPEG" is the name you wish to name the resource
"JPEG" is the user defined resource type.
"C:DownLoadMY.JPG" is the path and filename of the JPEG file.

For our example we will name the file "foo.rc" .

Now run the BRCC32.exe (Borland Resource CommandLine Compiler) program
found
in the Delphi/C++ Builders bin directory giving the full path to the rc
file:

C:DelphiPathBINBRCC32.EXE  C:ProjectPathFOO.RC

You should now have a compiled resource file named the same as the ".rc"
file  you compiled  with the extension of ".res".

The following demonstrates using the embedded JPEG in your application.

{Link the res file}
{$R FOO.RES}

uses Jpeg;

procedure LoadJPEGFromRes(TheJPEG : string;
                          ThePicture : TPicture);
var
  ResHandle : THandle;
  MemHandle : THandle;
  MemStream : TMemoryStream;
  ResPtr    : PByte;
  ResSize   : Longint;
  JPEGImage : TJPEGImage;
begin
  ResHandle := FindResource(hInstance, PChar(TheJPEG), 'JPEG');
  MemHandle := LoadResource(hInstance, ResHandle);
  ResPtr    := LockResource(MemHandle);
  MemStream := TMemoryStream.Create;
  JPEGImage := TJPEGImage.Create;
  ResSize := SizeOfResource(hInstance, ResHandle);
  MemStream.SetSize(ResSize);
  MemStream.Write(ResPtr^, ResSize);
  FreeResource(MemHandle);
  MemStream.Seek(0, 0);
  JPEGImage.LoadFromStream(MemStream);
  ThePicture.Assign(JPEGImage);
  JPEGImage.Free;
  MemStream.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  LoadJPEGFromRes('MYJPEG', Image1.Picture);
end;

-----------------------------------------------

1) Use the sndPlaySound() function to directly
play a wave file.

2) Read the wave file into memory, then use the
sndPlaySound() to play the wave file

3) Use sndPlaySound to directly play a wave
file thats embedded in a resource file attached
to your application.

4) Read a wave file thats embedded in a resource
file attached to your application into memory,
then use the sndPlaySound() to play the wave file.

To build the project you will need to:

1) Create a wave file called 'hello.wav'
in the project's directory.

2) Create a text file called 'snddata.rc'
in the project's directory.

3) Add the following line to the file 'snddata.rc':
HELLO WAVE hello.wav

4) At a dos prompt, go to your project directory
and compile the .rc file using the Borland Resource
compiler (brcc32.exe) by typing the path to brcc32.exe
and giving 'snddata.rc' as a parameter.

Example:

binbrcc32 snddata.rc

This will create the file 'snddata.res' that
Delphi will link with your application's .exe
file.

Final Note: Keep on Jamm'n!

*)

unit PlaySnd1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
PlaySndFromFile: TButton;
PlaySndFromMemory: TButton;
PlaySndbyLoadRes: TButton;
PlaySndFromRes: TButton;
procedure PlaySndFromFileClick(Sender: TObject);
procedure PlaySndFromMemoryClick(Sender: TObject);
procedure PlaySndFromResClick(Sender: TObject);
procedure PlaySndbyLoadResClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

{$R snddata.res}

uses MMSystem;

procedure TForm1.PlaySndFromFileClick(Sender: TObject);
begin
sndPlaySound('hello.wav',
SND_FILENAME or SND_SYNC);
end;

procedure TForm1.PlaySndFromMemoryClick(Sender: TObject);
var
f: file;
p: pointer;
fs: integer;
begin
AssignFile(f, 'hello.wav');
Reset(f,1);
fs := FileSize(f);
GetMem(p, fs);
BlockRead(f, p^, fs);
CloseFile(f);
sndPlaySound(p,
SND_MEMORY or SND_SYNC);
FreeMem(p, fs);
end;

procedure TForm1.PlaySndFromResClick(Sender: TObject);
begin
PlaySound('HELLO',
hInstance,
SND_RESOURCE or SND_SYNC);
end;

procedure TForm1.PlaySndbyLoadResClick(Sender: TObject);
var
h: THandle;
p: pointer;
begin
h := FindResource(hInstance,
'HELLO',
'WAVE');
h := LoadResource(hInstance, h);
p := LockResource(h);
sndPlaySound(p,
SND_MEMORY or SND_SYNC);
UnLockResource(h);
FreeResource(h);
end;

end.





411   [À©µµ¿ìÁî API] ¸ð¼­¸®°¡ µÕ±Ù(rounded ends) TEdit ¸¸µé±â  ±è¿µ´ë 2003/03/07 4958 1288
410   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TOpenDialog ÀÇ '¼±ÅÃ','Ãë¼Ò' ¹öư À̸§ ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4375 1334
409   [À©µµ¿ìÁî API] ·¹Áö½ºÆ®¸® Àüü °Ë»öÇÏ±â  ±è¿µ´ë 2003/03/07 4220 1141
408   [À©µµ¿ìÁî API] ALT_F4 hot key °¡·Îä±â  ±è¿µ´ë 2003/03/07 5655 1618
407   [µ¥ÀÌÅͺ£À̽º] µ¿ÀûÀ¸·Î SELECTÀÇ GROUP BY ¹® ¸¸µé±â  ±è¿µ´ë 2003/03/07 4201 946
406   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ListView ÀÇ item À» °­Á¦·Î ÆíÁý»óÅ·Π¸¸µé±â  ±è¿µ´ë 2003/03/07 4666 1217
405   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] MessageDlg()ÀÇ ÆùÆ®¸¦ ¹Ù²Ù¾î¼­ ¶ç¿ì±â  ±è¿µ´ë 2003/03/07 3890 1070
404   [À©µµ¿ìÁî API] À©µµ¿ìÁî Ž»ö±âÀÇ ÆÄÀÏ, ÄÄÇ»ÅÍ Ã£±â È­¸é ¶ç¿ì±â  ±è¿µ´ë 2003/03/07 6187 1630
403   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] WideString À» String À¸·Î ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4519 1129
402   [À©µµ¿ìÁî API] ´Ù¸¥ ApplicationÀÇ È­¸é¿¡ ±ÛÀÚ,±×¸²À» Ãâ·ÂÇÏ±â  ±è¿µ´ë 2003/03/07 3399 868
401   [À©µµ¿ìÁî API] À©µµ¿ìÁî '½ÃÀÛ' ¸Þ´º Refresh ½ÃŰ±â  ±è¿µ´ë 2003/03/07 4625 1419
400   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] StringGrid ¿¡¼­ ÇÁ·Î±×·¥À¸·Î MultiSelect ½ÃŰ±â  ±è¿µ´ë 2003/03/06 5472 1192
399   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] StringGrid ÀÇ ¼±Åÿµ¿ª¸¸ Ŭ¸³º¸µå·Î º¹»çÇÏ±â  ±è¿µ´ë 2003/03/06 4903 1088
398   [À©µµ¿ìÁî API] RichEdit¿¡ ÀÔ·ÂÇÑ ¹®ÀåÀÇ ½ÇÁ¦ ³ôÀÌ ±¸ÇÏ±â  ±è¿µ´ë 2003/03/06 5074 1430
397   [À©µµ¿ìÁî API] DDE ¾²Áö ¾Ê°í IEÀÇ ÇöÀç URL °¡Á®¿À±â  ±è¿µ´ë 2003/03/06 6002 1680
396   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] MemoÀÇ ÇàÀÇ ¹®ÀÚ¼ö¸¦ Á¦ÇÑÇϰí WordWrap½ÃŰ±â  ±è¿µ´ë 2003/03/06 5264 1315
395   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] OEM conversion  ±è¿µ´ë 2003/03/06 4340 1265
394   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ASCII printing  ±è¿µ´ë 2003/03/06 5329 1220
393   [COM/OLE] DelphiÀÇ OCX¸¦ InstallShield·Î ¹èÆ÷ÇÏ´Â ¹æ¹ý  ±è¿µ´ë 2003/03/06 8387 5644
392   [µ¥ÀÌÅͺ£À̽º] Save DBGrid To Excel  ±è¿µ´ë 2003/03/06 7087 1939
391   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] StringGrid ÀÇ ³»¿ëÀ» Ŭ¸³º¸µå·Î º¹»çÇÏ±â  ±è¿µ´ë 2003/03/06 4489 1061
390   [À©µµ¿ìÁî API] ·¹Áö½ºÆ®¸®ÀÇ º¯°æ¿©ºÎ ¾Ë¸®´Â 2°¡Áö ¹æ¹ý  ±è¿µ´ë 2003/03/06 4786 1286
389   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] desktop ¹è°æÈ­¸éÀ» ÆûÀÇ ¹è°æÈ­¸éÀ¸·Î ±×¸®±â  ±è¿µ´ë 2003/03/06 3713 1037
  [¸ÖƼ¹Ìµð¾î] JPEG, WAVE ¸¦ resource ÆÄÀÏ¿¡ ³Ö°í Àоî¿À±â  ±è¿µ´ë 2003/03/06 5351 1226
387   [½Ã½ºÅÛ] ¸¶ÀÌÅ© º¼·ý Á¶ÀýÇÏ±â  ±è¿µ´ë 2003/03/06 4679 1289
386   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] À©µµ¿ìÁî "³¯Â¥/½Ã°£" ¼³Á¤È­¸é ¶ç¿ì±â  ±è¿µ´ë 2003/03/06 6226 1825
385   [½Ã½ºÅÛ] ¿Àµð¿À CDÀÇ º¼·ý Á¶ÀýÇÏ±â  ±è¿µ´ë 2003/03/06 3650 1026
384   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¹®ÀÚ¿­ ¼ö½Ä¹®Àå(expression)ÀÇ °á°ú ±¸ÇÏ±â  ±è¿µ´ë 2003/03/06 3421 891
383   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ƯÁ¤ ColorÀÇ Invert Color ±¸ÇÏ±â  ±è¿µ´ë 2003/03/06 4329 1319
382   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] µÎ°³ÀÇ RichEdit »çÀÌ¿¡ ³»¿ë º¹»çÇÏ±â  ±è¿µ´ë 2003/03/06 5897 1369
381   [½Ã½ºÅÛ] Redirecting DOS Application Output  ±è¿µ´ë 2003/03/06 4723 1220
380   [½Ã½ºÅÛ] How do I use SetWindowsHookEx ?  ±è¿µ´ë 2003/03/06 6917 960
379   [À©µµ¿ìÁî API] KeyDownÀÇ BeepÀ½À» ¾ø¾ÖÀÚ...  ±è¿µ´ë 2003/03/06 4671 1214
378   [µ¥ÀÌÅͺ£À̽º] ƯÁ¤ ÆûÀÇ ÇöÀç ÆíÁýÁßÀÎ DB Field ±¸ÇÏ±â  ±è¿µ´ë 2003/03/06 4105 1115
377   [À©µµ¿ìÁî API] ÇÁ·Î±×·¥À¸·Î Screensaver µî·ÏÇÏ´Â µÎ°¡Áö ¹æ¹ý  ±è¿µ´ë 2003/03/06 4521 1270
376   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TObjectÀÇ ÇÁ·ÎÆÛƼ¸¦ ¹®ÀÚ¿­·Î ÂüÁ¶ÇÏ±â  ±è¿µ´ë 2003/03/06 5237 1596
375   [À©µµ¿ìÁî API] ¿ÜºÎ ÇÁ·Î±×·¥À» ÃÖ»óÀ§·Î ¼³Á¤ÇÏ±â  ±è¿µ´ë 2003/03/06 5257 1236
374   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] À̹ÌÁö¸¦ ¸¶¿ì½º·Î drag ÇØ¼­ zoom ÇÏ±â  ±è¿µ´ë 2003/03/06 3628 1027
373   [À©µµ¿ìÁî API] Æú´õ³ª ÆÄÀÏÀÇ À©µµ¿ìÁî µî·ÏÁ¤º¸ dialog ¶ç¿ì±â  ±è¿µ´ë 2003/03/06 5116 1478
372   [³×Æ®¿÷/ÀÎÅͳÝ] How to bring a network down - "Win Nuke"  ±è¿µ´ë 2003/03/06 7343 1998

[ÀÌÀü 10°³] [1]..[11][12][13][14] 15 [16][17][18][19][20]..[25] [´ÙÀ½ 10°³]
 

Copyright 1999-2023 Zeroboard / skin by zero