Board index » off-topic » class

class


2004-10-30 09:40:15 PM
off-topic13
Please,look at the following program:
.386
Locals
jumps
.model flat,stdCall;
mb_ok equ 0
hWnd equ 0
lpText equ offset text
lpCaption equ offset caption
extrn ExitProcess :proc
extrn MessageBoxA :proc
DATA segment use32 public
text db "Happy new academic year",13,10
caption db "Hello Students",0,'$'
DATA ends
code segment use32 public
start:
push mb_ok
push lpCaption
push lpText
push hWnd
call MessageBoxA
CALL ExitProcess
code ends
End start
Assembling this program with tasm32 is ok, but the linker, ilink32, displays the following fatal error: "...additional segment need to be defined in a .DEF file"
Who can explain and solve this error, especially, what is a DEF file ?
I found,that including the class 'code' in only one segment's declaration,will solve the problem.
Please, explain me the reason.
I know that in 16-bit programs,the class directive is an option.
I see that in 32-bits it is a must.I would like to understand the diffrence between these two meanings of class.
Regards,
xyoavx
 
 

Re:class

You are using 'simplified' directives and declare two segments, 'DATA'
and 'code'. 'code' is not one of the pre-declared segment names
provided with simplified directives. You have not defined the class
of that segment so it will not be bundled in with the default defined
ones. It therefore needs to be defined somewhere, either in the
source file or in a module definition file.
Change this:
code segment use32 public
To this:
code segment use32 public 'CODE'
To cause it to be grouped into the CODE class of segments.
While you are at it, read up on assembly and investigate the use of
the proc and endp directives.
Quote
... what is a DEF file ?
A module definition file is an accompanying text file in which items
such as export and import names, DLL's used, segments and their
attributes, stack size and heap size can be defined. The module
definition file has an extension of '.DEF' and is often referred to as
a 'def file'. The help has a section on module definition files.
--------------------------------------
Quote
type ques068.asm
.386p
.model flat,stdCall;
Locals
jumps
mb_ok equ 0
hWnd equ 0
lpText equ offset text
lpCaption equ offset caption
extrn ExitProcess :proc
extrn MessageBoxA :proc
DATA segment use32 public
text db "Happy new academic year",13,10
caption db "Hello Students",0,'$'
DATA ends
code segment use32 public 'CODE'
start:
push mb_ok
push lpCaption
push lpText
push hWnd
call MessageBoxA
CALL ExitProcess
code ends
End start
C:\Documents and Settings\Administrator\My Documents\Lookat\q068
Quote
tasm32 -ml -zi ques068
Turbo Assembler Version 5.3 Copyright (c) 1988, 2000 Inprise
Corporation
Assembling file: ques068.ASM
Error messages: None
Warning messages: None
Passes: 1
C:\Documents and Settings\Administrator\My Documents\Lookat\q068
Quote
ilink32 /Tpe/ap/c/v ques068,,,import32
Turbo Incremental Link 5.66 Copyright (c) 1997-2002 Borland
C:\Documents and Settings\Administrator\My Documents\Lookat\q068
Quote
ques068
C:\Documents and Settings\Administrator\My Documents\Lookat\q068

--------------------------------------
. Ed
Quote
borland.public.tasm wrote in message
news:418399bf$ XXXX@XXXXX.COM ...

Please,look at the following program:
.386
Locals
jumps
.model flat,stdCall;
mb_ok equ 0
hWnd equ 0
lpText equ offset text
lpCaption equ offset caption

extrn ExitProcess :proc
extrn MessageBoxA :proc

DATA segment use32 public
text db "Happy new academic year",13,10
caption db "Hello Students",0,'$'
DATA ends
code segment use32 public
start:
push mb_ok
push lpCaption
push lpText
push hWnd
call MessageBoxA
CALL ExitProcess
code ends
End start
Assembling this program with tasm32 is ok, but the linker,
ilink32, displays the following fatal error: "...additional
segment need to be defined in a .DEF file" Who can
explain and solve this error, especially, what is a DEF file ?
I found,that including the class 'code' in only one segment's
declaration,will solve the problem.
Please, explain me the reason.
I know that in 16-bit programs,the class directive is an option.
I see that in 32-bits it is a must.I would like to understand
the diffrence between these two meanings of class.
 

Re:class

Hello Ed Mulroy [TeamB]
Thanks a lot for your answer.
I found that instead of writing 'CODE' in this declaration:
code segment use32 public 'CODE'
It could be written here:
DATA segment use32 public 'code'
but not in both declarations !!
So, what is the exact duty of the claas directive in 32-bits ?
Where can I read more about creating and using the module definition file ?
Thanks in advance
xyoavx
"Ed Mulroy [TeamB]" < XXXX@XXXXX.COM >wrote:
Quote
You are using 'simplified' directives and declare two segments, 'DATA'
and 'code'. 'code' is not one of the pre-declared segment names
provided with simplified directives. You have not defined the class
of that segment so it will not be bundled in with the default defined
ones. It therefore needs to be defined somewhere, either in the
source file or in a module definition file.

Change this:

code segment use32 public

To this:

code segment use32 public 'CODE'

To cause it to be grouped into the CODE class of segments.

While you are at it, read up on assembly and investigate the use of
the proc and endp directives.

>... what is a DEF file ?

A module definition file is an accompanying text file in which items
such as export and import names, DLL's used, segments and their
attributes, stack size and heap size can be defined. The module
definition file has an extension of '.DEF' and is often referred to as
a 'def file'. The help has a section on module definition files.

--------------------------------------
>type ques068.asm
.386p
.model flat,stdCall;
Locals
jumps

mb_ok equ 0
hWnd equ 0
lpText equ offset text
lpCaption equ offset caption

extrn ExitProcess :proc
extrn MessageBoxA :proc

DATA segment use32 public
text db "Happy new academic year",13,10
caption db "Hello Students",0,'$'
DATA ends

code segment use32 public 'CODE'
start:
push mb_ok
push lpCaption
push lpText
push hWnd
call MessageBoxA
CALL ExitProcess
code ends

End start

C:\Documents and Settings\Administrator\My Documents\Lookat\q068
>tasm32 -ml -zi ques068
Turbo Assembler Version 5.3 Copyright (c) 1988, 2000 Inprise
Corporation

Assembling file: ques068.ASM
Error messages: None
Warning messages: None
Passes: 1


C:\Documents and Settings\Administrator\My Documents\Lookat\q068
>ilink32 /Tpe/ap/c/v ques068,,,import32
Turbo Incremental Link 5.66 Copyright (c) 1997-2002 Borland

C:\Documents and Settings\Administrator\My Documents\Lookat\q068
>ques068

C:\Documents and Settings\Administrator\My Documents\Lookat\q068
>
--------------------------------------

. Ed

>borland.public.tasm wrote in message
>news:418399bf$ XXXX@XXXXX.COM ...
>
>Please,look at the following program:
>.386
>Locals
>jumps
>.model flat,stdCall;
>mb_ok equ 0
>hWnd equ 0
>lpText equ offset text
>lpCaption equ offset caption
>
>extrn ExitProcess :proc
>extrn MessageBoxA :proc
>
>DATA segment use32 public
>text db "Happy new academic year",13,10
>caption db "Hello Students",0,'$'
>DATA ends
>code segment use32 public
>start:
>push mb_ok
>push lpCaption
>push lpText
>push hWnd
>call MessageBoxA
>CALL ExitProcess
>code ends
>End start
>Assembling this program with tasm32 is ok, but the linker,
>ilink32, displays the following fatal error: "...additional
>segment need to be defined in a .DEF file" Who can
>explain and solve this error, especially, what is a DEF file ?
>I found,that including the class 'code' in only one segment's
>declaration,will solve the problem.
>Please, explain me the reason.
>I know that in 16-bit programs,the class directive is an option.
>I see that in 32-bits it is a must.I would like to understand
>the diffrence between these two meanings of class.


 

{smallsort}

Re:class

usual Data segment:
DATA segment use32 public 'DATA'
 

Re:class

You are using an assembler, not a compiler. It will
not hold your hand and whisper hints to you as a
compiler will.
Quote
DATA segment use32 public 'code'
That is the data segment which is defined by using
'simplified' directives. The assembler is not
tolerant of the multiple definition.
Quote
Where can I read more about creating and using
the module definition file ?
I said to read the help entries about module definition
files.
After reading that look at the Microsoft page for them.
www.shorl.com/gefestytololi
or, in its long form
msdn.microsoft.com/library/en-us/vccore/html/_core_module.2d.definition_files.asp
. Ed
Quote
xyoavx wrote:

I found that instead of writing 'CODE' in
this declaration:
code segment use32 public 'CODE'
It could be written here:
DATA segment use32 public 'code'
but not in both declarations !!
So, what is the exact duty of the claas directive
in 32-bits ?
Where can I read more about creating and using
the module definition file ?
 

Re:class

Hi,
I want to create a Class which stores user information such as username,
password etc when the user logs into the project. Please help me out with ur
valuable suggestions
Thanks
 

Re:class

On 27 Dec 2004, "Antony" < XXXX@XXXXX.COM >wrote:
Quote
I want to create a Class which stores user information such as
username, password etc when the user logs into the project.
You'll have better luck getting answers if you ask in a more appropriate
newsgroup.
--
-Mike (TeamB)
Newsgroup guidelines: www.borland.com/newsgroups/guide.html
 

Re:class

Antony schreef:
Quote
I want to create a Class which stores user information such as username,
password etc when the user logs into the project. Please help me out with ur
valuable suggestions
One valuable suggestion: *never* store passwords, only store a hash
(SHA-1) of the passwords.
Danny
---
 

Re:class

I have this component with a TMyMaskEdit with some modification of
TMaskEdit, so I need in a Method of TMyMaskEdit (ValidateError) access the
Label in LabelEdit, any ideia?
----------- .cpp -------------
void __fastcall LabelEdit::TMyMaskEdit::ValidateError(void)
{
ShowMessage(MensagemErro);
Label->Color = FSetActiveColor;
// Here I got a error!
//[C++ Error] LabelEdit.cpp(130): E2231 Member LabelEdit::Label cannot be
used without an object
}
----------- .h -------------
class PACKAGE LabelEdit : public TWinControl
{
private:
TColor FColor;
TColor FSetActiveColor;
protected:
TLabel *Label;
class TMyMaskEdit : public TMaskEdit
{
private:
protected:
AnsiString MensagemErro;
void __fastcall SetErrorMessage(AnsiString value);
AnsiString __fastcall GetErrorMessage(void);
virtual void __fastcall TMyMaskEdit::ValidateError(void);
public:
__fastcall TMyMaskEdit(TComponent* Owner);
__published:
__property AnsiString ErrorMessage = {read = GetErrorMessage, write =
SetErrorMessage};
} *Edit;
public:
__fastcall LabelEdit(TComponent* Owner);
__published:
};
 

Re:class

"Arnaldo Giacomitti Junior" < XXXX@XXXXX.COM >wrote in message
Quote
void __fastcall LabelEdit::TMyMaskEdit::ValidateError(void)
That method belongs to TMyMaskEdit, not LabelEdit.
Quote
Label->Color = FSetActiveColor;
// Here I got a error!
//[C++ Error] LabelEdit.cpp(130): E2231 Member LabelEdit::Label
cannot be used without an object
Label and FSetActiveColor are not members of TMyMaskEdit. You need a
LabelEdit* pointer in order to access them from within TMyMaskEdit. For
example:
class PACKAGE LabelEdit : public TWinControl
{
private:
TColor FSetActiveColor;
//...
protected:
TLabel *FLabel;
//...
class TMyMaskEdit : public TMaskEdit
{
protected:
LabelEdit *FLabelEdit;
virtual void __fastcall ValidateError();
//...
public:
__fastcall TMyMaskEdit(LabelEdit *Owner);
//...
} *FEdit;
field class TMyMaskEdit;
public:
__fastcall LabelEdit(TComponent* Owner);
__fastcall ~LabelEdit();
};
__fastcall LabelEdit::LabelEdit(TComponent* Owner)
: TWinControl(Owner)
{
FEdit = new TMyMaskEdit(this);
//...
}
__fastcall LabelEdit::~LabelEdit()
{
delete FEdit;
}
__fastcall LabelEdit::TMyMaskEdit::TMyMaskEdit(LabelEdit *Owner)
: TMaskEdit(Owner), FLabelEdit(Owner)
{
}
void __fastcall LabelEdit::TMyMaskEdit::ValidateError()
{
//...
FLabelEdit->FLabel->Color = FLabelEdit->FSetActiveColor;
//...
}
Gambit
 

Re:class

I think you have typed incorret, you want to mean friend class TMyMaskEdit
over field class TMyMaskEdit below, right?
Another doubt my component is a descent of twincontrol, I want to use OnExit
event of twincontrol inside of component but after execute my code it need
to call OnExit event of LabelEdit, you understand me? But if I do it, its
override the OnExit of twincontrol there is a way to contorn this or I need
to change the name of OnExit event of labeledit?
---.h---
__published:
__property TNotifyEvent OnExit = {read=FOnMyExit, write=FOnMyExit};
---.c---
__fastcall LabelEdit::LabelEdit(TComponent* Owner)
: TWinControl(Owner)
{
OnExit = EditOnExit;
}
void __fastcall LabelEdit::EditOnExit(TObject *Sender) // this code not
execute, if I delete the property OnExit it work ok!
{
Label->Color = FColor;
if(FOnMyExit)
FOnMyExit;
}
Thanks for all help!
Arnaldo.
Quote
>void __fastcall LabelEdit::TMyMaskEdit::ValidateError(void)

That method belongs to TMyMaskEdit, not LabelEdit.

>Label->Color = FSetActiveColor;
>// Here I got a error!
>//[C++ Error] LabelEdit.cpp(130): E2231 Member LabelEdit::Label
>cannot be used without an object

Label and FSetActiveColor are not members of TMyMaskEdit. You need a
LabelEdit* pointer in order to access them from within TMyMaskEdit. For
example:

class PACKAGE LabelEdit : public TWinControl
{
private:
TColor FSetActiveColor;
//...
protected:
TLabel *FLabel;
//...
class TMyMaskEdit : public TMaskEdit
{
protected:
LabelEdit *FLabelEdit;
virtual void __fastcall ValidateError();
//...
public:
__fastcall TMyMaskEdit(LabelEdit *Owner);
//...
} *FEdit;
field class TMyMaskEdit;
^^^^^^^^^^^^^^^^^^^^^^^^^
friend class TMyMaskEdit right?
Quote
public:
__fastcall LabelEdit(TComponent* Owner);
__fastcall ~LabelEdit();
};

__fastcall LabelEdit::LabelEdit(TComponent* Owner)
: TWinControl(Owner)
{
FEdit = new TMyMaskEdit(this);
//...
}

__fastcall LabelEdit::~LabelEdit()
{
delete FEdit;
}

__fastcall LabelEdit::TMyMaskEdit::TMyMaskEdit(LabelEdit *Owner)
: TMaskEdit(Owner), FLabelEdit(Owner)
{
}

void __fastcall LabelEdit::TMyMaskEdit::ValidateError()
{
//...
FLabelEdit->FLabel->Color = FLabelEdit->FSetActiveColor;
//...
}


Gambit


 

Re:class

I have done it! Thanks again!
I had used:
__fastcall LabelEdit::LabelEdit(TComponent* Owner): TWinControl(Owner)
{
TWinControl::OnExit = EditOnExit;
}
void __fastcall LabelEdit::EditOnExit(TObject *Sender)
{
Label->Color = FColor;
if(FOnMyExit)
FOnMyExit(this);
}
And in the .H.....
__property TNotifyEvent LabelEdit::OnExit = {read=FOnMyExit,
write=FOnMyExit};
"Arnaldo Giacomitti Junior" < XXXX@XXXXX.COM >wrote in message
Quote
I think you have typed incorret, you want to mean friend class TMyMaskEdit
over field class TMyMaskEdit below, right?
Another doubt my component is a descent of twincontrol, I want to use
OnExit event of twincontrol inside of component but after execute my code
it need to call OnExit event of LabelEdit, you understand me? But if I do
it, its override the OnExit of twincontrol there is a way to contorn this
or I need to change the name of OnExit event of labeledit?

---.h---
__published:
__property TNotifyEvent OnExit = {read=FOnMyExit, write=FOnMyExit};

---.c---
__fastcall LabelEdit::LabelEdit(TComponent* Owner)
: TWinControl(Owner)
{
OnExit = EditOnExit;
}

void __fastcall LabelEdit::EditOnExit(TObject *Sender) // this code not
execute, if I delete the property OnExit it work ok!
{
Label->Color = FColor;
if(FOnMyExit)
FOnMyExit;
}

Thanks for all help!
Arnaldo.

>>void __fastcall LabelEdit::TMyMaskEdit::ValidateError(void)
>
>That method belongs to TMyMaskEdit, not LabelEdit.
>
>>Label->Color = FSetActiveColor;
>>// Here I got a error!
>>//[C++ Error] LabelEdit.cpp(130): E2231 Member LabelEdit::Label
>>cannot be used without an object
>
>Label and FSetActiveColor are not members of TMyMaskEdit. You need a
>LabelEdit* pointer in order to access them from within TMyMaskEdit. For
>example:
>
>class PACKAGE LabelEdit : public TWinControl
>{
>private:
>TColor FSetActiveColor;
>//...
>protected:
>TLabel *FLabel;
>//...
>class TMyMaskEdit : public TMaskEdit
>{
>protected:
>LabelEdit *FLabelEdit;
>virtual void __fastcall ValidateError();
>//...
>public:
>__fastcall TMyMaskEdit(LabelEdit *Owner);
>//...
>} *FEdit;
>field class TMyMaskEdit;
^^^^^^^^^^^^^^^^^^^^^^^^^
friend class TMyMaskEdit right?


>public:
>__fastcall LabelEdit(TComponent* Owner);
>__fastcall ~LabelEdit();
>};
>
>__fastcall LabelEdit::LabelEdit(TComponent* Owner)
>: TWinControl(Owner)
>{
>FEdit = new TMyMaskEdit(this);
>//...
>}
>
>__fastcall LabelEdit::~LabelEdit()
>{
>delete FEdit;
>}
>
>__fastcall LabelEdit::TMyMaskEdit::TMyMaskEdit(LabelEdit *Owner)
>: TMaskEdit(Owner), FLabelEdit(Owner)
>{
>}
>
>void __fastcall LabelEdit::TMyMaskEdit::ValidateError()
>{
>//...
>FLabelEdit->FLabel->Color = FLabelEdit->FSetActiveColor;
>//...
>}
>
>
>Gambit
>
>


 

Re:class

"Arnaldo Giacomitti Junior" < XXXX@XXXXX.COM >wrote in message
Quote
Another doubt my component is a descent of twincontrol, I want
to use OnExit event of twincontrol inside of component but after
execute my code it need to call OnExit event of LabelEdit, you
understand me? But if I do it, its override the OnExit of twincontrol
there is a way to contorn this or I need to change the name of
OnExit event of labeledit?
TWinControl already has its own OnExit event, so you do not need to declare
your own event at all. Also, components should never assign handlers to
their own events. It prevents the user from being able to assign his/her
own handlers. Instead, you should be overriding the virtual methods that
trigger the events. In this case, it would be the DoExit() method, ie:
class LabelEdit : public TWinControl
{
//...
protected:
DYNAMIC void __fastcall DoExit();
//...
};
void __fastcall LabelEdit::DoExit()
{
Label->Color = FColor;
TWinControl::DoExit();
}
Gambit
 

Re:class

"Arnaldo Giacomitti Junior" < XXXX@XXXXX.COM >wrote in message
Quote
I have done it! Thanks again!
Please see my other reply. The approach you are using is all wrong.
Gambit
 

Re:class

OK, I have do it, and work perfect, another doubt, I have inside of
TWinControl two components TLabel, and TMyMaskEdit is this correct?
If I assign event for this components I am doing the things right? Or have
another approach to do this?
Thanks again!
Arnaldo Giacomitti Junior.
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Arnaldo Giacomitti Junior" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Another doubt my component is a descent of twincontrol, I want
>to use OnExit event of twincontrol inside of component but after
>execute my code it need to call OnExit event of LabelEdit, you
>understand me? But if I do it, its override the OnExit of twincontrol
>there is a way to contorn this or I need to change the name of
>OnExit event of labeledit?

TWinControl already has its own OnExit event, so you do not need to
declare
your own event at all. Also, components should never assign handlers to
their own events. It prevents the user from being able to assign his/her
own handlers. Instead, you should be overriding the virtual methods that
trigger the events. In this case, it would be the DoExit() method, ie:

class LabelEdit : public TWinControl
{
//...
protected:
DYNAMIC void __fastcall DoExit();
//...
};

void __fastcall LabelEdit::DoExit()
{
Label->Color = FColor;
TWinControl::DoExit();
}


Gambit