My problem is that if (upon closing) any of the edit box contents are
empty, I get a general Failure Error and the whole application
closes! I am using a transfer record to stuff/extract the
contents of the edit boxes, and nulling out the first char in
any field that is to appear as empty.
Any hints as to what I am doing wrong? I would greatly appreciate
any help that is offered!
--
thomas LeMense, RF Product Design Engineer
Ford Motor Company Electronics Division (std. disclaimers apply)
tlem...@rchp33.eld.ford.com
Easier to help you if you send us the Init and evt. SetupWindows
routines for the dialog.
Do you remember to create pointers to the three editors in the Init
procedure? Do you use Initresource(@Self, id, Sizeof(Textfield)).
Have you remembered to make a transfer record with some Array
[0..TextLen-1] OF Char?
Have you remembered to assign the address of the transfer record to
TransferBuffer? TransferBuffer := @MyTransferRecord;
Have you remembered to call the inherited Init procedure??
Well, this is some stuff to remind you some easy errors:-)
Alf Christophersen
alf.chris...@basalmed.uio.no
---
> MegaMail 2.10 #0:
----
+-----------------------------------------------------------------------+
| Thunderball Cave BBS 47 22 29 94 41 / 47 22 29 94 42 (HST DS V.32bis) |
| -- thcave.bbs.no -- Oslo Norway -- |
+-----------------------------------------------------------------------+
Below is an example I wrote up (consists of two files - one main
program and one resource script)
I hope it helps.
Best regards,
Michael Vincze
m...@asd470.dseg.ti.com
---------- start transbuf.pas ----------
program TransBuf;
uses WinTypes, WinProcs, Objects, OWindows, ODialogs, Strings;
{$R TransBuf}
const
ApplicationName: PChar = 'TransBuf';
id_Field1 = 101;
id_Field2 = 102;
id_Field3 = 103;
type
TCharBuf = array [0..$FF] of Char;
TEditField = record
Field1: TCharBuf;
Field2: TCharBuf;
Field3: TCharBuf;
end;
type
PTransBufDialog = ^TTransBufDialog;
TTransBufDialog = object (TDialog)
end;
type
PTransBufWindow = ^TTransBufWindow;
TTransBufWindow = object (TWindow)
EditField: TEditField;
constructor Init (AParent: PWindowsObject; ATitle: PChar);
procedure Paint (PaintDC: HDC; var PaintInfo: TPaintStruct); virtual;
procedure WMRButtonDown (var Msg: TMessage); virtual wm_First + wm_RButtonDown;
end;
constructor TTransBufWindow.Init (AParent: PWindowsObject; ATitle: PChar);
begin
inherited Init (AParent, ATitle);
with EditField do
begin
StrCopy (Field1, 'Field 1');
StrCopy (Field2, 'Field 2');
StrCopy (Field3, 'Field 3');
end;
end;
procedure TTransBufWindow.Paint (PaintDC: HDC; var PaintInfo: TPaintStruct);
const
Instructions: PChar = 'Click Right Mouse Button to Activate Dialog';
begin
TextOut (PaintDC, 10, 20, Instructions, lstrlen (Instructions));
end;
procedure TTransBufWindow.WMRButtonDown (var Msg: TMessage);
var
D : PDialog;
E : PEdit;
Message: array [0..sizeof (TEditField)] of Char;
begin
D := New (PTransBufDialog, Init (@Self, ApplicationName));
D^.TransferBuffer := @EditField;
New (E, InitResource (D, id_Field1, SizeOf (TCharBuf)));
New (E, InitResource (D, id_Field2, SizeOf (TCharBuf)));
New (E, InitResource (D, id_Field3, SizeOf (TCharBuf)));
if Application^.ExecDialog (D) = idOk then
begin
with EditField do
begin
StrCopy (Message, 'EditField:'^M);
StrCat (Message, Field1); StrCat (Message, ^M);
StrCat (Message, Field2); StrCat (Message, ^M);
StrCat (Message, Field3);
end;
MessageBox (hWindow, Message, ApplicationName, mb_Ok);
end;
end;
type
TTransBufApplication = object (TApplication)
procedure InitMainWindow; virtual;
end;
procedure TTransBufApplication.InitMainWindow;
begin
MainWindow := New (PTransBufWindow, Init (nil, ApplicationName));
end;
var
Application: TTransBufApplication;
begin
Application.Init (ApplicationName);
Application.Run;
Application.Done;
end.
---------- end transbuf.pas ----------
---------- start transbuf.rc ----------
TRANSBUF DIALOG 18, 18, 140, 81
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Transfer Buffer Test"
BEGIN
CONTROL "", 101, "EDIT", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 40, 8, 92, 12
CONTROL "", 102, "EDIT", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 40, 24, 92, 12
CONTROL "", 103, "EDIT", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 40, 40, 92, 12
CONTROL "Field 1:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 8, 28, 8
CONTROL "Field 2:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 24, 28, 8
CONTROL "Field 3:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 40, 28, 8
CONTROL "&Ok", 1, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 100, 60, 32, 14
CONTROL "&Cancel", 2, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 60, 32, 14
END
---------- end transbuf.rc ----------