Q&A

  • 채팅프로그램에서 쪽지받고 답장쓰기 에러.
쪽지보내기를 하면 제대로 보내지는데. 답장을 쓰고, 버튼클릭하면 에러가 뜨거든요,,,,에러가-->>Access violation at address 04c49374 in module 'APT2580 BrowserFormProject.ocx' Read of address 00000040



이렇게 에러가 뜨거든요,,,뭘 어디를 수정해야 할까요???

부탁트립니당,,,,,,



참고로 쪽지보내기 소스와 받은 쪽지에 답장하기 소스를 같이 올립니당,



**쪽지보내기***

unit SendMemoUnit;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, ComCtrls, GlobalVariable;



type

TSendMemoForm = class(TForm)

Label1: TLabel;

PaperText: TEdit;

SmPaper: TMemo;

SndButton: TButton;

OptionCombo: TComboBox;

procedure SndButtonClick(Sender: TObject);

procedure FormShow(Sender: TObject);

procedure SmPaperKeyUp(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

private

{ Private declarations }

public

iUserNum: Integer;

iUserID: String;

{ Public declarations }

end;



var

SendMemoForm: TSendMemoForm;



implementation



{$R *.DFM}



procedure TSendMemoForm.SndButtonClick(Sender: TObject);

begin

if PaperText.Text = '' then

begin

myShowMessage1('쪽지를 받을 사람을 입력하십시요');

Exit;

end;



Case OptionCombo.ItemIndex of

0: begin

if iUserID = PaperText.Text then

begin

myShowMessage1('쪽지를 받을 사람이 자신의 아이디입니다.' + #13 +

'자신에게 쪽지를 보낼수는 없습니다.');

Exit;

end;

end;



1: begin

if iUserNum = StrToInt(Trim(PaperText.Text)) then

begin

myShowMessage1('쪽지를 받을 사람이 자신의 번호입니다.' + #13 +

'자신에게 쪽지를 보낼수는 없습니다.');

Exit;

end;

end;

end;

ModalResult := mrOk;

end;



procedure TSendMemoForm.FormShow(Sender: TObject);

begin

// OptionCombo.ItemIndex := 0;



end;



procedure TSendMemoForm.SmPaperKeyUp(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if (Key = Ord('S')) and (Shift = [ssAlt]) then

begin

SndButtonClick(Sender);

end;

end;



procedure TSendMemoForm.FormClose(Sender: TObject;

var Action: TCloseAction);

begin

Action := caFree;

end;



end.





***답장하기*****

unit RecvMemoUnit;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, Buttons, GlobalVariable, ComCtrls, ScktComp, MMsystem;



type

TRecvMemoForm = class(TForm)

Label1: TLabel;

PaperText: TEdit;

SmPaper: TMemo;

Button1: TButton;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

Button2: TButton;

Label2: TLabel;

MemoNumLabel: TLabel;

procedure Button1Click(Sender: TObject);

procedure SmPaperKeyUp(Sender: TObject; var Key: Word;

Shift: TShiftState);

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure FormShow(Sender: TObject);

procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

iCurrNum: Integer;

iMyInfo: TMyData;

iSocket: TCustomWinSocket;



{ Public declarations }

procedure ShowMemoList(iNum: Integer);

procedure AddMemoData(iUser: String; iStrList: TStringList);

end;



var

RecvMemoForm: TRecvMemoForm;



implementation



uses SendMemoUnit;



{$R *.DFM}



procedure TRecvMemoForm.SmPaperKeyUp(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if (Key = Ord('R')) and (Shift = [ssAlt]) then

begin

Button1Click(Sender);

end;

end;



procedure TRecvMemoForm.ShowMemoList(iNum: Integer);

begin

PaperText.Text := iMemoUser[iNum];

SmPaper.Lines.Assign(iMemoList[iNum]);

MemoNumLabel.Caption := IntToStr(iNum + 1) + ' / ' + IntToStr(iMemoCnt);

end;



procedure TRecvMemoForm.BitBtn2Click(Sender: TObject);

begin

if iCurrNum < iMemoCnt-1 then Inc(iCurrNum);

ShowMemoList(iCurrNum);

end;



procedure TRecvMemoForm.BitBtn1Click(Sender: TObject);

begin

if iCurrNum > 0 then Dec(iCurrNum);

ShowMemoList(iCurrNum);

end;



procedure TRecvMemoForm.AddMemoData(iUser: String; iStrList: TStringList);

var

i: Integer;

begin

{ if iMemoCnt > 9 then

begin

for i:=0 to 9 do

begin

iMemoUser[i] := iMemoUser[i+1];

iMemoList[i].Assign( iMemoList[i+1] );

end;

iMemoCnt := 10;

end;

iMemoUser[iMemoCnt] := iUser;

iMemoList[iMemoCnt].Assign(iStrList);



Inc(iMemoCnt);

ShowMemoList(iMemoCnt-1); }

end;



procedure TRecvMemoForm.FormShow(Sender: TObject);

var

iDirStr: String;

iWinDir: array[0..100] of Char;

begin

iCurrNum := iMemoCnt - 1;



GetWindowsDirectory(iWinDir, 101);

iDirStr := iWinDir + 'Mediachimes.wav';

StrPCopy(iWinDir, iDirStr);



try

PlaySound(iWinDir, 0, SND_ASYNC);

except

// ShowMessage('벨소리가 없어서 재생이 불가능합니다.');

end;

end;



procedure TRecvMemoForm.Button1Click(Sender: TObject);

var

i: Integer;

iRecvID: String;

iCarryRtn: String;

iSendStr: String;

iSendData: TChatStreamBuff;

begin

iRecvID := Copy(PaperText.Text, 1, Pos('/', PaperText.Text)-1);



SendMemoForm := TSendMemoForm.Create(Application);

With SendMemoForm do

begin

Left := (Screen.Width - Width) div 2;

Top := (Screen.Height - Height) div 2;



PaperText.Text := iRecvID;

PaperText.ReadOnly := True;



OptionCombo.ItemIndex := 0;

OptionCombo.Enabled := False;





iUserNum := iMyInfo.iNum;

iUserID := iMyInfo.iUID;



if ShowModal = mrOK then

begin

FillChar(iSendData, MSG_LENGTH, 0);

iSendData.iType := cmSendMemo_Req;

iSendData.iSubNum := cmpNoMessage_Msg;

iSendData.iNum := iUserNum;



iCarryRtn := '';

for i:=0 to SmPaper.Lines.Count-1 do

begin

if SmPaper.Lines[i] = '' then

begin

iCarryRtn := iCarryRtn + ' ';

Continue;

end;

iSendStr := '0|' + PaperText.Text + '|' + iCarryRtn + SmPaper.Lines[i];

StrPCopy(iSendData.iBuff, iSendStr);

iSocket.SendBuf(iSendData, MSG_LENGTH);



iCarryRtn := '';

end;

iSendStr := IntToStr(OptionCombo.ItemIndex) + '|' +

PaperText.Text + '|#End#`' + iMyInfo.iUID + '`' + iMyInfo.iName;

StrPCopy(iSendData.iBuff, iSendStr);

iSocket.SendBuf(iSendData, MSG_LENGTH);



SmPaper.Clear; //보낸쪽지 정리함

end;

end;

end;



procedure TRecvMemoForm.Button2Click(Sender: TObject);

begin

Self.Hide;

end;



end.



0  COMMENTS