Saturday, March 21, 2020

The Role Of A Government Essays - Civil Disobedience,

The Role Of A Government Sue Ellen Webb Mrs. Caudill English III Honors-5 20 January 2000 The Role of a Government Henry David Thoreau often took extreme positions on the issue of government and its role in society. To this somewhat rebellious transcendentalist, government should not govern people at all and law was often meant to be broken. Thoreau's belief in individualism was so strong in fact that it seems he often took sides on an in issue simply to be in favor of the minority, whether the majority was right or wrong. Certainly, it is important for one to be himself and stand up for what he believes in. However, to Thoreau's statement that that government is best which governs not at all is a bit extreme. Some form of government is necessary first and foremost to prevent chaos and widespread disorder. Without laws and consequences for breaking those laws, people will do exactly what pleases them without regard to how it affects others. Theft and murder will become everyday occurrences because men without ethics will see no reason not to commit these crimes. In fact, the entire population may ending killing themselves off. In addition to an increase of crime, a significant increase in poverty is likely to occur without government leadership. Without government funding, public schools, hospitals, and transportation would be nonexistent. This in conjunction with the lack of welfare funds would obviously lead to a society of poor, uneducated, Webb 2 and sickly people. Without a doubt, a society must be under the rule of a strong government power in order to function properly. Thoreau's statement is also too harsh because it has no regard for the fact that in a democratic society, the people essentially are the government. The whole purpose of a democracy is to ensure that the people govern themselves. Rather than being ruled by a dictator or monarch, members of a democratic society are able to have an input on how the government runs. Ideally, any law that is formed in this country is formed because the majority of the population want it to be formed. Rather than complaining about the existence of a government, Thoreau should have rejoiced at having the rights people in America have. It is doubtful that the laws of any other country would have allowed Thoreau more freedom or independence than the laws of the United States. If he felt otherwise or disagreed with the majority of the population, he should not have chosen to live in the United States. Certainly, one can see that Thoreau's complaints about the censorship placed upon individuals by the governme nt were unjustified. Obviously, Thoreau went too far in stating that the government should not govern at all. Without a government that does its job in governing the people, disaster will occur. While it is not the government's place to suppress the ideas or expressions of its people, it is vital to maintaining organization. As a society, people should strive to find a medium between total lack of government and total control by the government. Bibliography none

Thursday, March 5, 2020

Double Click for TListView

Implementing On Item Click / Double Click for TListView Delphis TListView control displays a list of items in columns with column headers and sub-items, or vertically or horizontally, with small or large icons. As do most Delphi controls, the TListView exposes the OnClick and OnDblClick (OnDoubleClick) events. Unfortunately, if you need to know what item was clicked or double clicked you cannot simply handle the OnClick / OnDblClick events to get the clicked item. The OnClick (OnDblClick) event for the TListView is fired whenever the user clicks the control - that is whenever the click occurs somewhere inside the client area of the control. The user can click inside the list view, BUT miss any of the items. Whats more, since list view can change its display depending on the ViewStyle property, the user might have clicked on an item, on an item caption, on an item icon, nowhere, on an item state icon, etc. Note: the ViewStyle property determines how items are displayed in the list view: the items can be displayed as a set of movable icons, or as columns of text. ListView.On Item Click ListView.On Item Double Click To be able to locate the clicked (if there is one) item when the OnClick event for the list view is fired, you need to determine what elements of the list view lie under the point specified by the X and Y parameters - that is the location of the mouse at the moment of click. The TListiews GetHitTestInfoAt function returns information about the specified point in the list view’s client area. To make sure the item was clicked (or double clicked) you need to call the GetHitTestInfoAt and react only if the click event occurred on an actual item. Heres an example implementation of the ListView1s OnDblClick event: //handles ListView1s On Double Click procedure TForm.ListView1DblClick(Sender: TObject) ; var   Ã‚  hts : THitTests;   Ã‚  ht : THitTest;   Ã‚  sht : string;   Ã‚  ListViewCursosPos : TPoint;   Ã‚  selectedItem : TListItem; begin   Ã‚  //position of the mouse cursor related to ListView   Ã‚  ListViewCursosPos : ListView1.ScreenToClient(Mouse.CursorPos) ;   Ã‚  //double click where?   Ã‚  hts : ListView1.GetHitTestInfoAt(ListViewCursosPos.X, ListViewCursosPos.Y) ;   Ã‚  //debug hit test   Ã‚  Caption : ;   Ã‚  for ht in hts do   Ã‚  begin   Ã‚  Ã‚  Ã‚  sht : GetEnumName(TypeInfo(THitTest), Integer(ht)) ;   Ã‚  Ã‚  Ã‚  Caption : Format(%s %s | ,[Caption, sht]) ;   Ã‚  end;   Ã‚  //locate the double-clicked item   Ã‚  if hts [htOnIcon, htOnItem, htOnLabel, htOnStateIcon] then   Ã‚  begin   Ã‚  Ã‚  Ã‚  selectedItem : ListView1.Selected;   Ã‚  Ã‚  Ã‚  //do something with the double clicked item!   Ã‚  Ã‚  Ã‚  Caption : Format(DblClcked : %s,[selectedItem.Caption]) ;   Ã‚  end; end; In the OnDblClick (or OnClick) event handler, read the GetHitTestInfoAt function by providing it with the location of the mouse inside the control. To get the location of the mouse related to the list view, the ScreenToClient function is used to convert a point (mouse X and Y) in screen coordinates to local, or client area, coordinates. The GetHitTestInfoAt return a value of THitTests type. The THitTests is a set of THitTest enumerated values. The THitTest enumeration values, with their description, are: htAbove - above the client area.htBelow - below the client area.htNowhere - inside the control, but not on an item.htOnItem - on an item, its text, or its bitmap.htOnButton - on a button.htOnIcon - on an icon.htOnIndent - on the indented area of an item.htOnLabel - on a label.htOnRight - on the right side of an item.htOnStateIcon - on a state icon or bitmap associated with an item.htToLeft - to the left of the client area.htToRight - to the right of the client area. If the result of the call to GetHitTestInfoAt is a subset (Delphi sets!) of [htOnIcon, htOnItem, htOnLabel, htOnStateIcon] you can be sure the user clicked on the item (or on its icon / state icon). Finally, if the above is true, read the Selected property of the list view, it returns the first selected item (if multiple can be selected) in the list view. Do something with the clicked / double clicked / selected item ... Be sure to download the full source code to explore the code and learn by adopting it.