Wednesday, March 18, 2020

How to Make a Delphi Login Form

How to Make a Delphi Login Form The MainForm of a Delphi application is a form (window) that is the first one created in the main body of the application. If you need to implement some kind of authorization for your Delphi application, you might want to display a login/password dialog before the main form is created and displayed to the user. In short, the idea is to  create, display, and destroy the login dialog before creating the main form. The Delphi MainForm When a new Delphi project is created, Form1 automatically becomes the value of the MainForm property (of the global Application object). To assign a different form to the MainForm property, use the Forms page of the Project Options dialog box at design time. When the main form closes, the application terminates. Login/Password Dialog Lets start by creating the main form of the application. Create a new Delphi project containing one form. This form is, by design, the main form. If you change the name of the form to TMainForm and save the unit as main.pas, the projects source code looks like this (the project was saved as PasswordApp): program PasswordApp; uses Forms, main in main.pas {MainForm}; {$R *.res} begin Application.Initialize; Application.CreateForm(TMainForm, MainForm) ; Application.Run; end. Now, add a second form to the project. By design, the second form thats added gets listed in the Auto-Create Forms list on the Project Options dialog. Name the second form TLoginForm and remove it  from the Auto-Create Forms list. Save the unit as login.pas. Add a Label, Edit, and Button on the form, followed by a class method to create, show, and close the login/password dialog. The method Execute returns true if the user has entered the correct text in the password box. Heres the full source code: unit login; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TLoginForm class(TForm) LogInButton: TButton;pwdLabel: TLabel;passwordEdit: TEdit;procedure LogInButtonClick(Sender: TObject) ; publicclass function Execute : boolean;end; implementation{$R *.dfm} class function TLoginForm.Execute: boolean;beginwith TLoginForm.Create(nil) dotry Result : ShowModal mrOk; finally Free; end;end; procedure TLoginForm.LogInButtonClick(Sender: TObject) ;beginif passwordEdit.Text delphi then ModalResult : mrOK else ModalResult : mrAbort; end; end. The Execute method dynamically creates an instance of the TLoginForm and displays it using the ShowModal method. ShowModal does not return until the form closes. When the form closes, it returns the value of the ModalResult property. The LogInButton OnClick event handler assigns mrOk to the ModalResult property if the user has entered the correct password (which is delphi in the above example). If the user has provided a wrong password, ModalResult is set to mrAbort (it can be anything except mrNone). Setting a value to the ModalResult property closes the form. Execute returns true if ModalResult equals mrOk (if the user has entered the correct password). Don't Create MainForm Before Login You now only need to make sure the main form is not created if the user failed to provide the correct password. Heres how the projects source code should look: program PasswordApp; uses Forms, main in main.pas {MainForm}, login in login.pas {LoginForm}; {$R *.res} beginif TLoginForm.Execute thenbegin Application.Initialize; Application.CreateForm(TMainForm, MainForm) ; Application.Run; endelsebegin Application.MessageBox(You are not authorized to use the application. The password is delphi., Password Protected Delphi application) ; end;end. Note the usage of the if then else block to determine if the main form should be created. If Execute returns false, MainForm is not created and the application terminates without starting.

Monday, March 2, 2020

Oxford Dictionaries Word of the Year 2018

Oxford Dictionaries Word of the Year 2018 Oxford Dictionaries Word of the Year 2018 Oxford Dictionaries Word of the Year 2018 By Mark Nichol The Oxford Dictionaries has announced that its Word of the Year for 2018 is toxic, which visitors to its websites searched for not only in isolation but as an element in multiple phrases. Toxic, which derives ultimately from the Greek term toxon, meaning â€Å"arrow,† came to apply to poison delivered on the point of an arrow. In Greek, toxikon meant â€Å"poison arrow,† and later, the Latin word toxicum pertained to poison itself. The primary definition of the adjective toxic is â€Å"poisonous,† though by extension, it has come to mean â€Å"harmful† or â€Å"malicious.† Although several phrases frequently used in searches on the Oxford Dictionaries sites pertain to the literal meaning of toxic- reflecting concerns about pollution- several pertain to the latter senses, including â€Å"toxic culture† and â€Å"toxic environment,† which allude to a physical realm that is unhealthy for ones psychological (and therefore physical) health, such as a company or other organization that tacitly condones sexist or unethical behavior, or a dysfunctional domestic situation. A toxic relationship, meanwhile, is one in which one of the parties is emotionally and/or physically abusive toward the other, and toxic masculinity is the concept of a distorted perception about what it means to be a male in modern society; symptoms of this malady include aggression and excessive competitiveness, as well as sexism and homophobia. Toxicity is the quality of being toxic, and a toxin is a poison; antitoxin is an antidote to poison. The study of poisons, meanwhile is toxicology, and one who studies poisons is a toxicologist. (Toxic- and toxico- are combining forms referring to poisons.) The Oxford Dictionaries also listed other words and phrases that were most frequently entered in search boxes on its websites this year, including a couple that are little known in the United States- and, interestingly, they all are associated, more or less, with toxic behavior. One British English–centric term is cakeism, which alludes to the saying â€Å"You can’t have your cake and eat it, too,† meaning that one should not be greedy or try to have two things that are incompatible. Cakeism, by contrast, suggests that one can or should exploit two alternative opportunities at once. The other is gammon, extrapolated from the term for salted pork leg (which turns pink when cooked) and describing a white person, especially one with a conservative sociopolitical worldview, who develops a florid complexion due to the person becoming emotionally exercised about an issue such as Brexit, the controversial and contested decision by the United Kingdom to withdraw from the European Union. Other terms on the list also reflect current events and reactions to them. The phrase â€Å"big dick energy,† for example, pertains to an outsize confidence that suggests that the person in question (generally, a celebrity) has such an attitude because he is genitally well endowed, though the term is applied to charismatic women, too (and the idea is not to be confused with toxic masculinity, though someone with BDE may be a toxic person). The term gaslighting, referring to psychological manipulation to undermine a person’s confidence or sanity, is inspired by the title and plot device of the 1938 stage play Gas Light and its subsequent film, television, and radio adaptations (the titles of which treated the phrase as a closed compound), in which a man surreptitiously dims the gas-fueled lighting in the home he shares with his wife and then insists to her that the lights are as bright as usual, among other tactics, to drive her insane. Incel is a truncation of the phrase â€Å"involuntary celibate,† describing a man whose difficulty forming healthy relationships with women (or even obtaining dates with them) leads to sexual and emotional frustration that escalates to hostility toward not only women but also the men incels resent for being successful in sexual and romantic pursuits. The term applies especially to virtual communities of men who commiserate with each other in online forums, which, as closed (and therefore toxic) environments, amplify the condition. Orbiting, meanwhile, is when someone no longer communicates directly with another person through social media but still keeps track of that person online; the term, suggesting someone periodically looming over someone else, is a loose synonym for lurking (though lurkers usually leave no trace of their visit) and differs from ghosting- the term for a sudden, complete cessation of contact, generally from someone one has been dating- in that an orbiter leaves evidence of a continuing (and perhaps toxic) interest. The concept of the deleterious effects of excessive numbers of travelers to a vacation destination, including damage to historical sites and the local environment as well as negative impacts on the location’s residents, is called overtourism. Finally, techlash describes negative and hostile attitudes toward large technology companies because of the pervasive influence on society of their products, erosion of privacy for people who use them, and their inability to prevent identify theft. The term is a construction based on backlash, which means â€Å"adverse reaction† (or â€Å"sudden backward movement†), from the notion of a whip or rope inflicting pain or damage as it unexpectedly strikes someone or something when one uses the whip or rope. Want to improve your English in five minutes a day? Get a subscription and start receiving our writing tips and exercises daily! Keep learning! Browse the Vocabulary category, check our popular posts, or choose a related post below:"Because Of" and "Due To" Hyper and HypoWhat’s the Best Way to Refer to a Romantic Partner?