Saturday, March 21, 2020

Tracon by Paul McElroy essays

Tracon by Paul McElroy essays Paul McElroy's novel "Tracon" is a gripping tale about the airline industry and in particular the air traffic controllers. McElroy has created a fast paced, page turning story that can cause even the most seasoned airline passenger to feel wary of ever flying again. McElroy gives the reader an intricate detailed account about the inner workings of the air traffic controllers and how stressful and difficult their work really is. The story portrays a behind-the-scenes of one of the nation's busiest airports, Chicago's O'Hare Airport, with such realistic description and dialogue that McElroy's novel reads more like McElroy begins his story with a mid-air collision of two passenger jetliners, a Coastal 757 and an Atlantic 727. From the first page, the author crabs the reader's attention. "the first officer saw the Coastal Airlines 757 burst out of the clouds from the left. He yanked on the control yoke and jammed one rudder pedal to the floor in a desperate attempt to steer above and behind the other plane. The 727 was starting to respond when the outboard edge of its port wing grazed the top of the 757's starboard wing. Then the Jurassic jet shook violently from a sickening crunch of metal as the wing slashed through the vertical stabilizer on Coastal's tail, ripping half of it away" (McElroy 9). In just four sentences McElroy sets the stage for the unthinkable tragedy about to unfold. He then goes on to describe the horror the passengers faced as they realized the plane was out of control and on a crash course. The author then jumps from the tragedies taking place on the planes to a yacht sailing below whose owner and afternoon date witness the debris falling from the sky. McElroy then flashes to O'Hare Airport. ...

Thursday, March 5, 2020

How to Add Items to a TPopUp Delphi Menu

How to Add Items to a TPopUp Delphi Menu When working with Menus or PopUp menus in Delphi applications, in most scenarios, you create the menu items at design-time. Each menu item is represented by a TMenuItem Delphi class. When a user selects (clicks) an item, the OnClick event is fired for you (as a developer) to grab the event and respond to it. There may be situations when the items of the menu are not known at design time, but need to be added at run-time (dynamically instantiated). Add TMenuItem at Run-Time Suppose there is a TPopupMenu component named PopupMenu1 on a Delphi form, to add an item to the popup menu you could write a piece of code as: var   Ã‚   menuItem : TMenuItem; begin   Ã‚  menuItem : TMenuItem.Create(PopupMenu1) ;   Ã‚  menuItem.Caption : Item added at TimeToStr(now) ;   Ã‚  menuItem.OnClick : PopupItemClick;   Ã‚  //assign it a custom integer value..   Ã‚  menuItem.Tag : GetTickCount;   Ã‚  PopupMenu1.Items.Add(menuItem) ; end; Notes In the above code, one item is added to the PopupMenu1 component. Note that we assigned an integer value to the Tag property. The Tag property (every Delphi component has it) is designed to allow a developer to assign an arbitrary integer value stored as part of the component.The GetTickCount API function retrieves the number of milliseconds that have elapsed since Windows was started.For the OnClick event handler, we assigned PopupItemClick - the name of the function with the *correct* signature. procedure TMenuTestForm.PopupItemClick(Sender: TObject) ; var   Ã‚   menuItem : TMenuItem; begin   Ã‚   if NOT (Sender is TMenuItem) then   Ã‚   begin   Ã‚  Ã‚  Ã‚   ShowMessage(Hm, if this was not called by Menu Click, who called this?!) ;   Ã‚  Ã‚  Ã‚   ShowMessage(Sender.ClassName) ;   Ã‚  Ã‚  Ã‚   exit;   Ã‚   end;   Ã‚   menuItem : TMenuItem(sender) ;   Ã‚   ShowMessage(Format(Clicked on %s, TAG value: %d,[menuItem.Name, menuItem.Tag])) ; end; Important When a dynamically added item is clicked, the PopupItemClick will be executed. In order to differentiate between one or more run-time added items (all executing the code in PopupItemClick) we can use the Sender parameter: The PopupItemClick method first checks if the Sender is actually a TMenuItem object. If the method is executed as a result of a menu item OnClick event handler we simply show a dialog message with the Tag value being assigned when the menu item was added to the menu. Custom String-In TMenuItem In real-world applications, you might/would need more flexibility. Lets say that each item will represent a web page - a string value would be required to hold the URL of the web page. When the user selects this item you could open the default web browser and navigate to the URL assigned with the menu item. Heres a custom TMenuItemExtended class equipped with a custom string Value property: type    TMenuItemExtended class(TMenuItem)    private   Ã‚  Ã‚   fValue: string;    published   Ã‚  Ã‚   property Value : string read fValue write fValue;    end; Heres how to add this extended menu item to a PoupMenu1: var   Ã‚   menuItemEx : TMenuItemExtended; begin   Ã‚   menuItemEx : TMenuItemExtended.Create(PopupMenu1) ;   Ã‚   menuItemEx.Caption : Extended added at TimeToStr(now) ;   Ã‚   menuItemEx.OnClick : PopupItemClick;   Ã‚   //assign it a custom integer value..   Ã‚   menuItemEx.Tag : GetTickCount;   Ã‚   //this one can even hold a string value   Ã‚   menuItemEx.Value : http://delphi.about.com;   Ã‚   PopupMenu1.Items.Add(menuItemEx) ; end; Now, the PopupItemClick must be modified to properly process this menu item: procedure TMenuTestForm.PopupItemClick(Sender: TObject) ; var   Ã‚   menuItem : TMenuItem; begin   Ã‚   //...same as above   Ã‚   if sender is TMenuItemExtended then   Ã‚   begin   Ã‚  Ã‚  Ã‚   ShowMessage(Format(Ohoho Extended item .. heres the string value : %s,[TMenuItemExtended(Sender).Value])) ;   Ã‚   end; end; Thats all. Its up to you to extend the TMenuItemExtended as per your needs. Creating custom Delphi components is where to look for help on creating your own classes/components. Note To actually open up the default Web Browser you can use the Value property as a parameter to a ShellExecuteEx API function.