December 22, 2008

Create A WebClip Icon For Your Site

1 comments
This is a good tip for those of you who design web sites and applications geared toward the iPhone. Dan Dickinson posted instructions for creating the icon for your site that shows up on the springboard when someone creates a web clip for it.

Create a 57×57 PNG.
Name it “apple-touch-icon.png”

Throw it in the root folder of your website. (Not the root of your server ,the root of your web documents.)
You can also place the image in a link tag in the head of your document, like so:

You can get more info at the iPhone Dev Center under “Create a WebClip Bookmark Icon”.

December 21, 2008

Changing iPod Icons

0 comments


By the default, the buttons at the bottom of the iPod scren are “Playlists”, “Artists”, “Songs”, “Videos”, and “More”. You can change them by pressing the “More” button, and then tap on the “Edit” button in the upper left corner. A Configure screen will appear with icons for “Albums”, “Podcasts”, “Audiobooks”, “Genres”, “Composers”, “Compilations”, “Playlists”, “Artists”, “Songs”, and “Videos”. To substitute one of these icons for one that appears at the bottom of the iPod screen, just tap and hold on the icon you prefer and drag it over the icon you want to replace. Tap on Done when you’re finished.

December 19, 2008

Move Dock Icons

0 comments
Just press and hold any icons on the screen, then drag them while they are shaking. You can put any 4 icons on your dock (grey bar at the bottom of your iPhone).

December 13, 2008

iPhone Applications

0 comments
Press the Home button at any time to go to the Home screen, which contains your iPhone applications. Tap any application icon to get started.

The following applications are included with iPhone:

Phone :
Make calls, with quick access to recent callers, favorites, and all your contacts. Or dial manually using the numeric keypad. Visual voicemail presents a list of your voicemail messages. Just tap to listen to any message you want, in any order you want.

Mail :
iPhone works with MobileMe, Microsoft Exchange, and many of the most popular email systems—including Yahoo! Mail, Google email, and AOL—as well as most industry-standard POP3 and IMAP email systems. View PDFs and other attachments within Mail. Save attached photos and graphics to your Camera Roll album.

Safari :
Browse websites over a cellular data network or over Wi-Fi. Rotate iPhone sideways for widescreen viewing. Double-tap to zoom in or out—Safari automatically fits the webpage column to the iPhone screen for easy reading. Sync bookmarks with Safari or Microsoft Internet Explorer on your computer. Add Safari web clips to the Home screen for fast access to favorite websites. Save images from websites to your Photo Library.

iPod :
Listen to your songs, audiobooks, and podcasts. Create on-the-go playlists or use the Genius feature to automatically create a playlist with songs from your library that go great together. Watch movies and video podcasts in widescreen.

Text :
Send and receive SMS text messages with anyone who has an SMS-capable phone. Conversations are saved in an iChat-like presentation, so you can see a history of messages you’ve sent and received.

Calendar :
View your MobileMe, iCal, Microsoft Entourage, Microsoft Outlook, or Microsoft Exchange calendars. Enter events on iPhone and they get synced back to the calendar on your computer. Set alerts to remind you of events, appointments, and deadlines.

Photos :
View photos and images transferred from your computer or saved on iPhone. View them in portrait or landscape mode. Zoom in on any photo for a closer look. Watch a slideshow. Email photos, add them to a MobileMe gallery, assign them to contacts, and use them as wallpaper.

Camera :
Take two-megapixel photos and view them on iPhone, email them, or upload them to your computer. Take a friend’s picture and set iPhone to display it when that person calls you.

YouTube :
Play videos from YouTube’s online collection. Search for any video, or browse featured, most viewed, most recently updated, and top-rated videos.

Stocks :
Watch your favorite stocks, updated automatically from the Internet.

Maps :
See a street map, satellite view, or hybrid view of locations around the world. Zoom in for a closer look, or check out the Google Street View. Find and track your current (approximate) location. Get detailed driving, public transit, or walking directions and see current highway traffic conditions. Find businesses in the area and call with a single tap.

Weather :
Get current weather conditions and a six-day forecast. Add your favorite cities for a quick weather report anytime.

Clock :
View the time in cities around the world—create clocks for your favorites. Set one or more alarms. Use the stopwatch, or set a countdown timer.

Calculator :
Add, subtract, multiply, and divide. Rotate iPhone sideways to use expanded scientific functions.

Notes :
Jot notes on the go—reminders, grocery lists, brilliant ideas. Send them in email.

Settings :
Set up accounts and adjust all iPhone settings in one convenient place. Set your own volume limit for listening comfort. Set your ringtone, wallpaper, screen brightness, and settings for network, phone, mail, web, music, video, photos, and more. Set auto-lock and a passcode for security. Restrict access to explicit iTunes content and certain applications. Reset iPhone.

iTunes :
Search the iTunes Wi-Fi Music Store music catalog, or browse, preview, and purchase new releases, top-ten songs and albums, and more. Stream and download podcasts. In select U.S. Starbucks locations, find out what song is playing in the café, then buy it instantly. Browse, preview, and purchase other songs from featured Starbucks Collections.

App Store :
Search the App Store for iPhone applications you can purchase or download using your Wi-Fi or cellular data network connection. Read or write your own reviews for your favorite apps. Download and install the application on your Home screen.

Contacts :
Get contact information synced from MobileMe, Mac OS X Address Book, Yahoo! Address Book, Google Address Book, Windows Address Book (Outlook Express), Microsoft Outlook, or Microsoft Exchange. Search, add, change, or delete contacts, which get synced back to your computer.

NOTE: Application functionality may vary depending on the country or region where you purchase and use iPhone. Contact your carrier for more information.

December 03, 2008

Save Any Image from Safari

1 comments

To save any image from the web to your camera roll, simply press and hold the image. A menu will appear asking "Save Image" or "Cancel". Once the image is in your camera roll, you can set it as your wallpaper.

December 01, 2008

Set Parental Controls

0 comments

You can enable certain restrictions or parental controls on your iPhone. You can block explicit lyrics, Safari, YouTube, iTunes, or the App Store. Just go to Settings, General, Restrictions.

November 30, 2008

Take a Screenshot

0 comments

To take a screenshot, hold the home button and click the sleep button. The screen will flash white and the screenshot will be stored in your camera roll.

November 28, 2008

Soft Reset

0 comments

Press and hold the Home button and the Sleep button to restart your iPhone. A white light will flash, the screen will shut off and then turn back on. Keep holding until the screen turns back on.

November 25, 2008

Click & Hold URL's

0 comments


















In Safari, hold a link to see the URL and site name.

November 17, 2008

Press & Hold Alternate Characters

0 comments
















Hold a letter for a popup of various versions of the character (i.e. to type España with the "ñ" simply hold "n" and simply slide/release to the appropriate character).

November 15, 2008

Domain Suffix - On firmware 2.0

0 comments





Hold down the ".com" key for ".net, .edu, .org" keys. Note: Slide your finger from .com to .net/.edu/.org, rather than lifting and pressing.

November 07, 2008

Tips 4

0 comments
Implement a Fast Reset Method within a Form

There are many occasions where you need to reset the controls on a form, either in readiness for a new record, or perhaps when a record has been displayed and the user clicks the button to enter a new record.

You could, of course, reference each control on the form individually to reset its display. However, I tend to whip through every control on the form and perform the same function on each. Of course, not all controls have the same properties, so I preface my procedure with an On Error Resume Next statement that tells my code to ignore any errors and continue with the next line of code:

On Error Resume Next
For Each oControl In Controls
oControl.Text = "" 'mainly for text box controls
oControl.ListIndex = -1 'reset combo and list boxes.
Next

November 06, 2008

Tips 3

0 comments
Implement an Exists Method within a Collection Class

One of my long standing gripes about the Collection object is the complete absence lack of an easy method to determine whether the member you're looking for exists within the collection. Therefore, when I'm writing a wrapper class for a collection, I always include my own.

However, I add a little more to the method than simply determining if the member exists in the collection. If the member is not found within the collection, I attempt to add it to the collection. This way, I can simplify the code at the client end by always calling the Exists method prior to assigning the member to a local object variable. Therefore, I know that if the Exists method returns true, I can safely go on to assign the member to the local object variable.

The code for a typical Exists method is shown below:

Public Function Exists(sDomainName As String) As Boolean

On Error GoTo Exists_Err

Dim oTemp As Domain
Set oTemp = mcolDomains.Item(sDomainName)
Exists = True
Set oTemp = Nothing
Exit Function

TrytoGet:
If Not LoadDomain(sDomainName) Then
Exit Function
Else
Exists = True
End If
Exit Function

Exists_Err:
If Err.Number = 5 Then
Resume TrytoGet
Else
'further error handling here for other error types
End If

End Function

As you can see, the idea is to test for the presence of a particular member of the collection by attempting to assign it to a temporary local object variable. If the member is not present, then error 5 ("Invalid Procedure Call or Argument") is raised. Trapping this, program flow proceeds to the LoadDomain function, which attempts to load the member into the collection.

The new VB6 Dictionary object (found in the Scripting Runtime Library) contains its own built-in Exists property. The custom Exists method for the collection object can therefore be cut down dramatically but still achieve the same results, as the following method illustrates:

Public Function Exists(sDomainName As String) As Boolean
If mdicWebsites.Exists(sDomainName) Then
Exists = True
Else
Exists = GetWebsite(sDomainName)
End If
End Function

Whether you're using the (now old fashioned) Collection object or the (new and fast) Dictionary object, your client code is identical, as the following fragment shows:

Private Sub cboDomainName_Click()
If moWebsites.Exists(cboDomainName.Text) Then
Set moWebsite = moWebsites.Website(cboDomainName.Text)
End If
End Sub

November 05, 2008

Tips 2

0 comments
Implement a For Each...Next Statement against a Collection Class

Most of the time, we take for granted the For Each...Next loop, which iterates the members of an array or a collection. It's the fastest, most efficient method of visiting all the members of the collection or array, and we could care less that, as it enumerates the collection, the unseen code is actually generating new references to members of the collection with each iteration of the loop. However, as the provider of a collection class, it is up to you to provide an interface that the For Each...Next statement can work with.

This may sound a little daunting, but you'll be pleasantly surprised how easy it is to implement a property that enumerates members of the collection within your class. First of all, you must create a Property Get procedure called NewEnum with the type of IUnknown. Its syntax is always the same:

Public Property Get NewEnum() As IUnknown
Set NewEnum = mCol.[_NewEnum]
End Property

where mCol is the name of your private collection object variable.

Second, set the Procedure ID for this Property Get procedure to -4. To do this, select the Procedure Attributes option from the Tools menu, then click the Advanced button on the Procedure Attributes dialog. Enter a Procedure ID of -4. You should also check the "Hide this member" option to prevent the property from appearing in the IntelliSense drop down.

November 03, 2008

Implement an IsSaved Property

0 comments
Implement an IsSaved (or IsDirty) Property

I often find this technique very useful, but it takes a little extra work when you're creating your object classes. On balance, despite this up front investment of time, it saves a good deal of programming time by making it easy to determining when an object has changed and therefore needs to be saved.

To implement an IsSaved or IsDirty property, each Property Let procedure of a particular object must contain a line of code to determine if the value to be assigned to the property is different than its current value (which should be stored in a private member variable). If it is different, then the private member variable that represents the IsSaved property is set to False. For example:

Property Let CustStreetAddr(sVal as String)
If msCustStreetAddr <> sVal Then
msCustStreetAddr = sVal
mbIsSaved = False
End If
End Property

(Of course, you can also implement this the other way round by having an IsDirty property that returns True when the object needs to be saved.)

Back at the client end you can check to see if the object needs saving quickly and easily as follows:

If Not myObject.IsSaved Then
SaveTheObject
End If

On the server object, this is implemented as a simple Property Get procedure:

Property Get IsSaved() As Boolean
IsSaved = mbIsSaved
End Property

Another neat addition to this is to define an object event called something like ObjectChanged. Then the event can be fired whenever some attribute of the object changes:

Property Let CustStreetAddr(sVal As String)
If msCustStreetAddr <> sVal Then
msCustStreetAddr = sVal
mbIsSaved = False
RaiseEvent ObjectChanged()
End If
End Property

On the client form, you can then implement an event handler for the ObjectChanged event that enables the Save button when the object needs to be saved:

Sub MyObject_ObjectChanged()
cmdSave.Enabled = Not myObject.IsSaved
End Sub

This code enables the Save button when the object is not saved and disables the button when the object has been changed.

I should add a major qualification to this tip: don't update your object property based on the Change event handler of a text box. The Change event is fired for each keystroke that the text box receives. Therefore typing a word like "Stupid" into the text box will fire off 6 Change events - and the final result is that the text box could contain the same word that it originally started with, so that in fact its contents haven't changed at all despite the firing of six unnecessary events.

November 02, 2008

Domain Resolution

0 comments
















When typing a URL in Safari, you don't have to type the "www" or the ".com".For instance, for www.cnn.com just type "cnn" in the URL box. Note: Your search engine must be set to Google, not Yahoo.

Tips 1

0 comments
Use #If ccDebug to View Hidden Automation Servers

One of the problems with testing and debugging a remote automation server is that the server application typically remains hidden, doing its work in the background. Hence, when something goes wrong, you frequently can't tell what has happened or where in your code your application is being derailed.

Consequently, when you're developing, testing, and debugging your application, it's a good idea to make sure that otherwise hidden automation server remain visible. You can do this by using code like the following to make sure that a new instance of an automation server (in this case Microsoft Word) is visible:

Dim objWord as Word.Application
Set objWord = New Application

#If ccDebug Then
objWord.Visible = True
#End If

You can define the project-level conditional compiler constant ccDebug in either of two ways:

*

By including the line
#Const ccDebug = 1

in the declarations section of a form or code module.
*

By using the Make tab of the Project Properties dialog (select the Project Properties option from the VB Project menu) and entering the following in the Conditional Compilation Arguments text box:
ccDebug = 1

Then, whenever your code runs in the design-time environment, you automation server will be visible. When you are ready to create the final executable, you should either set the ccDebug conditional compilation constant to 0 or, if you've used the Conditional Compilation Arguments text box, remove its definition.

November 01, 2008

Scroll to Top of Page

0 comments



















In any application, Safari included, you can automatically scroll to the top of the page by tapping on the "top bar", which has the time, service bars, and battery. In Safari, this not only brings you to the top of the page, but also brings up the URL bar.

Use vbCrLf in Embedded SQL Scripts

0 comments
Use vbCrLf in Embedded SQL Scripts

Visual Basic contains quite a few intrinsic constants -- that is, constants that are now part of the VBA language but that you used to have to define in your code either explicitly or by adding the Constant.Bas file to your project. One of these is vbCrLf, which equates to the carriage return/line feed -- or Chr$(13) & Chr$(10) - character combination.

But why would I suggest that you include this constant in an embedded SQL script? After all, the code means nothing to SQL Server; it could care less that you want a carriage return and line feed at the end of each line. The answer: debugging, plain and simple. Quite often, you'll find yourself creating embedded SQL scripts that run to 10, 20 or more lines. For example,

sSQL = "SELECT * FROM anytable" _
& " WHERE userid = " & lUser _
& " AND color = '" & sColor "'"

If you define the SQL statement in this way, the SQL script is readable when viewed in the procedure, but what about when you want use the Immediate window to see the value of the sSQL variable at run time?

You enter
? sSQL

in the Immediate window, and a long, unbroken string is shown, running miles off into the distance.

However, if you simply suffix each line with vbCrLf, like this:

sSQL = "SELECT * FROM anytable" & vbCrLf _
& "WHERE userid = " & lUser & vbCrLf _
& "AND color = '" & sColor "'"

then you can quickly and easily read your completed SQL code to find the problem.

The previous example illustrates another benefit of vbCrLf: if you don't use it, you must remember to start (or end) each line with a space; otherwise,

sSQL = "SELECT * FROM anytable" & _
& "WHERE userid = " & lUser

becomes
"SELECT * FROM anytableWHERE userid = 1"

and your code will generate a SQL syntax error.

October 12, 2008

Tips 12

0 comments
Listbox with colored lines

Colored lines in listbox are more user-friendly and easy to read. Here is how to do it…
First of all, place ListBox component on a form and set Style property to lbOwnerDrawFixed. The rest is simple:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;

type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
ListBox1.Style := lbOwnerDrawFixed;
end;

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with Control as TListBox do
begin
Canvas.FillRect(Rect);
Canvas.Font.Color := TColor(Items.Objects[Index]);
Canvas.TextOut(Rect.Left + 2, Rect.Top, Items[Index]);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.AddObject('Red line', Pointer(clRed));
ListBox1.Items.AddObject('Green line', Pointer(clGreen));
end;

end.

October 11, 2008

Tips 11

0 comments
Change color of ListView items

To change background color of ListView items, you need to write your own OnCustomDrawItem event handler.
The best result is when you set the ViewStyle to vsReport, but it’s completely functional even with vsList style. OnCustomDrawItem code is very simple:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;

type
TForm1 = class(TForm)
ListView1: TListView;
procedure ListView1CustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
with ListView1.Canvas.Brush do
begin
case Item.Index of
0: Color := clYellow;
1: Color := clGreen;
2: Color := clRed;
end;
end;
end;

end.

October 10, 2008

Tips 10

0 comments
Change font, size and style of hint

Hints are everywhere. Almost every GUI element in Windows can be “hinted”. When user hover mouse over element, small yellow bubble with help text pops up. Is it possible to change hint “window” behavior? Of course…

To see how to change default color and timeouts of hint bubble, visit this post. To change font, size and style of the hint text, just use this code:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type
TExHint = class(THintWindow)
constructor Create(AOwner: TComponent); override;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

constructor TExHint.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
with Canvas.Font do
begin
Name := 'Verdana';
Size := Size + 15;
Style := [fsBold, fsItalic];
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
HintWindowClass := TExHint;
end;

end.

October 09, 2008

Tips 9

0 comments
Get Process Memory Info

If you want to know how many bytes of memory is using your process, here is simple example.
We will need standard psAPI unit. Using API function GetProcessMemoryInfo, we can get amount of used bytes of memory.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, psAPI;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
pmc: PPROCESS_MEMORY_COUNTERS;
cb: Integer;
begin
cb := SizeOf(_PROCESS_MEMORY_COUNTERS);
GetMem(pmc, cb);
pmc^.cb := cb;
if GetProcessMemoryInfo(GetCurrentProcess(), pmc, cb) then ShowMessage(IntToStr(pmc^.WorkingSetSize) + ' Bytes')
else ShowMessage('Unable to get process info');
FreeMem(pmc);
end;

end.

October 08, 2008

Tips 8

0 comments
How to detect system time change

If the user changes the system time either with Date and Time properties dialog box or using command line, we can detect this by catching WM_TIMECHANGE system message. Here is how.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMTimeChange(var Msg: TMessage); message WM_TIMECHANGE;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMTimeChange(var Msg: TMessage);
begin
ShowMessage('System time was just changed!');
end;

end.

October 07, 2008

Tips 7

0 comments
How to detect clipboard change

Detecting clipboard change is very similar to detecting system time change. We will detect WM_DRAWCLIPBOARD system message.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure ClipBoardChanged(var Message: TMessage); message WM_DRAWCLIPBOARD;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ClipBoardChanged(var Message: TMessage);
begin
ShowMessage('Clipboard changed!');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
SetClipboardViewer(Handle);
end;

end.

October 06, 2008

Tips 6

0 comments
Add own item to Internet Explorer Tools menu

If you want to add own items to Tools menu of Internet Explorer, it’s simple. All we have to do is to add some keys to Windows registry, therefore we must use Registry unit.
As you can see in source code, we must specify the menu item label (or button label) and of course the path of file we want to run. As example, we will run Calc.exe.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Registry;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure IEButton(Path: string);
const
Tagit = '\{10954C80-4F0F-11d3-B17C-00C0DFE39736}\';
var
Reg: TRegistry;
Key: string;
begin
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
Key := 'Software\Microsoft\Internet Explorer\Extensions' + Tagit;
OpenKey(Key, True);
WriteString('ButtonText', 'Toolbar button label');
WriteString('MenuText', 'Menu item label');
WriteString('MenuStatusBar', 'Run Script');
WriteString('ClSid', '{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}');
WriteString('Default Visible', 'Yes');
WriteString('Exec', Path);
WriteString('HotIcon', ',4');
WriteString('Icon', ',4');
end
finally
Reg.CloseKey;
Reg.Free;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
IEButton('c:\windows\system32\calc.exe');
end;

end.

October 05, 2008

Tips 5

0 comments
Own cool text cursor in Editbox

Standard text cursor is boring. What about replacing default vertical line with some cool shape?



unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
CaretBm : TBitmap;
CaretBmBk : TBitmap;
OldEditsWindowProc : Pointer;
end;

type
WParameter = LongInt;
LParameter = LongInt;



var
Form1: TForm1;

implementation

{$R *.dfm}

function NewWindowProc(WindowHandle : hWnd; TheMessage : WParameter; ParamW : WParameter; ParamL : LParameter) : LongInt stdcall;
begin
NewWindowProc := CallWindowProc(Form1.OldEditsWindowProc, WindowHandle, TheMessage, ParamW, ParamL);

if TheMessage = WM_SETFOCUS then
begin
CreateCaret(WindowHandle, Form1.CaretBm.Handle, 0, 0);
ShowCaret(WindowHandle);
end;

if TheMessage = WM_KILLFOCUS then
begin
HideCaret(WindowHandle);
DestroyCaret;
end;

if TheMessage = WM_KEYDOWN then
begin
if ParamW = VK_BACK then CreateCaret(WindowHandle, Form1.CaretBmBk.Handle, 0, 0)
else CreateCaret(WindowHandle, Form1.CaretBm.Handle, 0, 0);
ShowCaret(WindowHandle);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin

//normal cursor
CaretBm := TBitmap.Create;
CaretBm.Canvas.Font.Name := 'WingDings';
CaretBm.Canvas.Font.Height := Edit1.Font.Height;
CaretBm.Canvas.Font.Color := clWhite;
CaretBm.Width := CaretBm.Canvas.TextWidth('J') + 2;
CaretBm.Height := CaretBm.Canvas.TextHeight('J') + 2;
CaretBm.Canvas.Brush.Color := clBlue;
CaretBm.Canvas.FillRect(Rect(0, 0, CaretBm.Width, CaretBm.Height));
CaretBm.Canvas.TextOut(1, 1, 'J');

//backspace cursor
CaretBmBk := TBitmap.Create;
CaretBmBk.Canvas.Font.Name := 'WingDings';
CaretBmBk.Canvas.Font.Height := Edit1.Font.Height;
CaretBmBk.Canvas.Font.Color := clWhite;
CaretBmBk.Width := CaretBmBk.Canvas.TextWidth('L') + 2;
CaretBmBk.Height := CaretBmBk.Canvas.TextHeight('L') + 2;
CaretBmBk.Canvas.Brush.Color := clBlue;
CaretBmBk.Canvas.FillRect(Rect(0, 0, CaretBmBk.Width, CaretBmBk.Height));
CaretBmBk.Canvas.TextOut(1, 1, 'L');
OldEditsWindowProc := Pointer(SetWindowLong(Edit1.Handle, GWL_WNDPROC, LongInt(@NewWindowProc)));
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
SetWindowLong(Edit1.Handle, GWL_WNDPROC, LongInt(OldEditsWindowProc));
CaretBm.Free;
CaretBmBk.Free;
end;

end.

October 04, 2008

Tips 4

0 comments
Edit and Display Boolean Fields using a CheckBox in Delphi's DBGrid


A series of articles titled Adding components to a DBGrid discusses placing just about any Delphi control (visual component) into a cell of a . The idea is to create visually more attractive user interfaces for editing fields inside a DBGrid: a ComboBox for drop down lists; a DateTimePicker (calendar) for date values; a check box for boolean fields.
CheckBox for Boolean Fields
The article CheckBox inside a DBGrid provides one method of using a check box control to edit and display values for boolean fields.

As noticed by Rene van der Heijden the solution is rather lengthy, and it doesn't work, at least not when using the mouse to click on the checkboxes.

Rene suggest an easier approach needing only two even handlers: OnCellClick and OnCustomDrawCell for your DBGrid control:

//OnCellClik event of a DBGrid1
procedure TForm.DBGrid1CellClick(Column: TColumn) ;
begin
if (Column.Field.DataType=ftBoolean) then
begin
{toggle True and False}
Column.Grid.DataSource.DataSet.Edit;
Column.Field.Value:= not Column.Field.AsBoolean;
{immediate post - see for yourself whether you want this}
Column.Grid.DataSource.DataSet.Post;
{you may add additional functionality here,
to be processed after the change was made}
end;
end;

//OnDrawColumnCell event of a DBGrid1
procedure TForm.DBGrid1DrawColumnCell(
Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumn;
State: TGridDrawState) ;
const
CtrlState: array[Boolean] of integer = (DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or DFCS_CHECKED) ;
begin
if (Column.Field.DataType=ftBoolean) then
begin
DBGrid1.Canvas.FillRect(Rect) ;
if VarIsNull(Column.Field.Value) then
DrawFrameControl(DBGrid1.Canvas.Handle,Rect, DFC_BUTTON, DFCS_BUTTONCHECK or DFCS_INACTIVE) {grayed}
else
DrawFrameControl(DBGrid1.Canvas.Handle,Rect, DFC_BUTTON, CtrlState[Column.Field.AsBoolean]) ; {checked or unchecked}
end;
end;

October 03, 2008

Tips 3

0 comments
Convert a Drive Letter ("C") to a Drive Number (3)



I have an application that needs to "export" a set of files into a specified folder on a drive. Files can come from various sources: hard disk, usb disk, network drive, etc.

Before the export action an export folder needs to be specified, for example "c:\export folder".

For a more user friendly approach, before the actual export I need to make sure there's enough space on the drive specified by the export folder.
In the above case the drive I'm interested in is "C".

If the export folder is set to "d:\some folder\export folder" then I need to find out how many bytes are available on the "D" drive.
RTL's DiskFree function
Lucky for us working in Delphi, we do not have to invent hot water. Most of the times Delphi already provides a function that serves the purpose, in the Run Time Library.

DiskFree returns the amount of free space in bytes on a specified drive.

There's a "but" :(

DiskFree is declared as:

function DiskFree(Drive: Byte): Int64;

DiskFree function takes a byte (an integer type holding values from 0..255) value - while "C" in "c:\export folder" or "D" in "d:\some folder\export folder" is a character.

The help for DiskFree states: DiskFree returns the number of free bytes on the specified drive, where 0 = Current, 1 = A, 2 = B, 3 = C, 4 = D and so on.

The question is how to come from "D" to 4 (or from "E" to 5)?

Here's the answer:

var
driveLetter : char;
driveNumber : byte;
directory : string;
freeBytes : int64;
begin
//looking for free space on C drive
directory := 'c:\Export Folder';

driveLetter := UpperCase(ExtractFileDrive(directory))[1];

driveNumber := 1 + Ord(driveLetter) - Ord('A') ;

freeBytes := DiskFree(driveNumber) ;

//here "freeBytes" holds the number of free bytes on a drive
//specified by a directory
end;

Note: RTL's Ord returns an integer representing the ordinal value of an ordinal value. Character types are ordinal types (originally modeled after the ANSI character set) - this is why Ord('A') is 65 since 'A' holds a value of 65 in the ASCII table.

Once you have the number of free bytes on a drive you can display it nicely to the user: Formatting a File Size in Bytes for Display.

October 02, 2008

Tips 2

0 comments
Is Computer Joined to a Domain - Programmatically Check using Delphi



If a computer is a part of a network it can either be part of a workgroup or a domain.

If you need to programmatically check if a machine running your application is a part of a domain you can exploit functions found in the netapi32.dll. The trick is in using the NetRenameMachineInDomain function which can be used to change the name of a computer in a domain.

If the function fails with the return value of "NERR_SetupNotJoined" when supplying it with "nil" values - a machine is NOT a part of a domain.

// returns true if the machine running this code is in a domain
function IsInDomain: boolean;
type
TNetRenameMachineInDomain = function(lpServer, MachineName, lpAccount, Password: PWideChar; Options: Longint): LongInt stdcall;
var
ResultCode: Integer;
NetRenameMachineInDomain: TNetRenameMachineInDomain;
NetAPIHandle: THandle;
const //ref : lmerr.h
NERR_BASE = 2100;
// This machine is already joined to a domain.
NERR_SetupAlreadyJoined = (NERR_BASE + 591) ;
// This machine is not currently joined to a domain.
NERR_SetupNotJoined = (NERR_BASE + 592) ;
// This machine is a domain controller and cannot be unjoined from a domain.
NERR_SetupDomainController = (NERR_BASE + 593) ;
// The destination domain controller does not support
// creating machine accounts in OUs.
NERR_DefaultJoinRequired = (NERR_BASE + 594) ;
// The specified workgroup name is invalid.
NERR_InvalidWorkgroupName = (NERR_BASE + 595) ;
// The specified computer name is incompatible with the
// default language used on the domain controller.
NERR_NameUsesIncompatibleCodePage = (NERR_BASE + 596) ;
// The specified computer account could not be found.
// Contact an administrator to verify the account is in the domain.
// If the account has been deleted unjoin, reboot, and rejoin the domain.
NERR_ComputerAccountNotFound = (NERR_BASE + 597) ;
// This version of Windows cannot be joined to a domain.
NERR_PersonalSku = (NERR_BASE + 598) ;
// An attempt to resolve the DNS name of a DC in the domain being joined has failed.
// Please verify this client is configured to reach a DNS server that can
// resolve DNS names in the target domain.
NERR_SetupCheckDNSConfig = (NERR_BASE + 599) ;
begin
try
NetAPIHandle := LoadLibrary(PChar('netapi32.dll')) ;
@NetRenameMachineInDomain := GetProcAddress(NetAPIHandle, PChar('NetRenameMachineInDomain')) ;
ResultCode := NetRenameMachineInDomain(nil, nil, nil, nil, 0) ;
FreeLibrary(NetAPIHandle) ;
finally
end;

Result := ResultCode <> NERR_SetupNotJoined;
end; (*IsInDomain*)

October 01, 2008

Tips 1

0 comments
How to Check if a Given File Name is Valid Using Delphi
A custom IsFileNameValid Delphi function


If you have an application that operates on the file system and one of the tasks of the application is creating or manipulating files, then you might need to check if a given file name is valid.

For example, if you're using the Windows Explorer to create a new file manually and you try to use the "pipe" (vertical bar) character "|", you will get an error:

A file name cannot contain any of the following characters: \ / : * ? " < > |

The solution to this is to make sure Windows will allow your code to save a file using the specified file name. This can be done with a custom Delphi function: IsValidFileName.
Is File Name Valid
The IsValidFileName validates a given file name to report if a string value represents a valid Windows file name.

The function will return false if the parameter "fileName" is an empty string or if it contains any of the invalid characters:

//test if a "fileName" is a valid Windows file name
//Delphi >= 2005 version
function IsValidFileName(const fileName : string) : boolean;
const
InvalidCharacters : set of char = ['\', '/', ':', '*', '?', '"', '<', '>', '|'];
var
c : char;
begin
result := fileName <> '';

if result then
begin
for c in fileName do
begin
result := NOT (c in InvalidCharacters) ;
if NOT result then break;
end;
end;
end; (* IsValidFileName *)

Note: "InvalidCharacters" is a set type constant.

If your Delphi version (<= Delphi 7) does not support the for in loop, use the next implementation of the IsValidFileName function: //test if a "fileName" is a valid Windows file name //Dellphi <= 7 version function IsValidFileName(const fileName : string) : boolean; const InvalidCharacters : set of char = ['\', '/', ':', '*', '?', '"', '<', '>', '|'];
var
cnt : integer;
begin
result := fileName <> '';

if result then
begin
for cnt := 1 to Length(fileName) do
begin
result := NOT (fileName[cnt] in InvalidCharacters) ;
if NOT result then break;
end;
end;
end; (* IsValidFileName *)

September 12, 2008

What is a Computer Printer?

4 comments
What is a Computer Printer?

Computer printer

Many printers are primarily used as computer peripherals, and are permanently attached to a computer which serves as a document source. Other printers, commonly known as network printers, have built-in network interfaces (typically wireless or Ethernet), and can serve as a hardcopy device for any user on the network. In addition, many modern printers can directly interface to electronic media such as memory sticks or memory cards, or to image capture devices such as digital cameras, scanners; some printers are combined with a scanners and/or fax machines in a single unit. A printer which is combined with a scanner can essentially function as a photocopier.

Printers are designed for low-volume, short-turnaround print jobs; requiring virtually no setup time to achieve a hard copy of a given document. However, printers are generally slow devices (10 pages per minute is considered fast; and many consumer printers are far slower than that), and the cost-per-page is relatively high, In contrast, the printing press (which serves much the same function), is designed and optimized for high-volume print jobs such as newspaper print runs--printing presses are capable of hundreds of pages per minute or more, and have an incremental cost-per-page which is a fraction of that of printers. The printing press remains the machine of choice for high-volume, professional publishing. However, as printers have improved in quality and performance, many jobs which used to be done by professional print shops are now done by users on local printers; see desktop publishing.

The world's first computer printer was a 19th-century mechanically driven apparatus invented by Charles Babbage for his Difference Engine.

Printing technology
Printers are routinely classified by the underlying print technology they employ; numerous such technologies have been developed over the years. The choice of print engine has a substantial effect on what jobs a printer is suitable for, as different technologies are capable of different levels of image/text quality, print speed, low cost, noise; in addition, some technologies are inappropriate for certain types of physical media (such as carbon paper or transparencies).

Another aspect of printer technology that is often forgotten is resistance to alteration: liquid ink such as from an inkjet head or fabric ribbon becomes absorbed by the paper fibers, so documents printed with liquid ink are more difficult to alter than documents printed with toner or solid inks, which do not penetrate below the paper surface. According to the website of security expert Frank Abagnale checks should either be printed with liquid ink or on special "check paper with toner anchorage" [1]. For similar reasons carbon film ribbons for IBM Selectric typewriters bore labels warning against using them to type negotiable instruments such as checks.

Modern print technology
The following printing technologies are routinely found in modern printers, as of April 2006:

Toner-based printers
Toner-based printers work using the Xerographic principle that is at work in most photocopiers: by adhering toner to a light-sensitive print drum, then using static electricity to transfer the toner to the printing medium to which it is fused with heat and pressure. The most common type of toner-based printer is the laser printer, which uses precision lasers to cause adherence. Laser printers are known for high quality prints, good print speed, and a low cost-per-copy; they are the most common printer for many general-purpose office applications. They are far less commonly used as consumer printers due to a high initial cost.

Laser printers are available in both color and monochrome varieties.

Another toner based printer is the LED printer which uses an array of LEDs instead of a laser to cause toner adhesion to the print drum.

Liquid inkjet printers
Inkjet printers spray very small, precise amounts (usually a few picolitres) of ink onto the media. Inkjet printing (and the related bubble-jet technology) are the most common consumer print technology; as high-quality inkjet printers are inexpensive to produce. Virtually all modern inkjet printers are color devices; some, known as photo printers, include extra pigments to better reproduce the color gamut needed for high-quality photographic prints (and are additionally capable of printing on photographic card stock, as opposed to plain office paper).

Inkjet printers consist of nozzles that produce very small ink bubbles that turn into tiny droplets of ink. The dots formed are the size of tiny pixels. Ink-jet printers can print high quality text and graphics. They are also almost silent in operation. Inkjet printers have a much lower initial cost than do laser printers, but have a much higher cost-per-copy, as the ink needs to be frequently replaced. In addition, consumer printer manufacturers have adapted a business model similar to that employed by manufacturers of razors; the printers themselves are frequently sold below cost, and the ink is then sold at a high markup. Various legal and technological means are employed to try and force users to only purchase ink from the manufacturer (thus leading to vendor lock-in); however there is a thriving aftermarket for such things as third-party ink cartridges (new or refurbished) and refill kits.

Inkjet printers are also far slower than laser printers. Inkjet printers also have the disadvantage that pages must be allowed to dry before being aggressively handled; premature handling can cause the inks (which are adhered to the page in liquid form) to run.

Solid Ink printers
Solid Ink printers, also known as phase-change printers, are a type of thermal transfer printer. They use solid sticks of CMYK colored ink (similar in consistency to candle wax), which are melted and fed into a piezo crystal operated print-head. The printhead sprays the ink on a rotating, oil coated drum. The paper then passes over the print drum, at which time the image is transferred, or transfixed, to the page.

Solid ink printers are most commonly used as color office printers, and are excellent at printing on transparencies and other non-porous media. Solid ink printers can produce excellent results, and are commonly found in office environments. Acquisition and operating costs are similar to laser printers. Drawbacks of the technology include high power consumption and long warm-up times from a cold state. Also, some users complain that the resulting prints are difficult to write on (the wax tends to repel inks from pens), and are difficult to feed through Automatic Document Feeders, however these traits have been significantly reduced in later models. In addition, this type of printer is only available from one manufacturer, Xerox, manufactured as part of their Xerox Phaser office printer line. Previously, solid ink printers were manufactured by Tektronix, but Tek sold the printing business to Xerox in 2000.

Dye-sublimation printers
A dye-sublimation printer (or dye-sub printer) is a printer which employs a printing process that uses heat to transfer dye to a medium such as a plastic card, paper or canvas. The process is usually to lay one color at a time using a ribbon that has color panels. Dye-sub printers are intended primarily for high-quality color applications, including color photography; and are less well-suited for text. While once the province of high-end print shops, dye-sublimation printers are now increasingly used as dedicated consumer photo printers.

Thermal printers
Thermal printers work by selectively heating regions of special heat-sensitive paper. These printers are limited to special-purpose applications such as cash registers and the printers in ATMs and gasoline dispensers. They are also used in some older inexpensive fax machines.

Obsolete and special-purpose printing technologies
The following technologies are either obsolete, or limited to special applications though most were, at one time, in widespread use. Among these types are impact printers and pen-based plotters.

Impact printers rely on a forcible impact to transfer ink to the media, similar to the action of a typewriter. All but the dot matrix printer rely on the use of formed characters, letterforms that represent each of the characters that the printer was capable of printing. In addition, most of these printers were limited to monochrome printing in a single typeface at one time, although bolding and underlining of text could be done by overstriking, that is, printing two or more impressions in the same character position. Impact printers varieties include, Typewriter-derived printers, Teletypewriter-derived printers, Daisy wheel printers, Dot matrix printers and Line printers.

Pen-based plotters were an alternate printing technology once common in engineering and architectural firms. Pen-based plotters rely on contact with the paper (but not impact, per se), and special purpose pens that are mechanically run over the paper to create text and images.

Only plotters, dot matrix printers, and certain line printers were capable of printing graphics.

Typewriter-derived printers
Several different computer printers were simply computer-controlable versions of existing electric typewriters. The Friden Flexowriter and IBM Selectric typewriter were the most-common examples. The Flexowriter printed with a conventional typebar mechanism while the Selectric used IBM's well-known "golf ball" printing mechanism. In either case, the letter form then struck a ribbon which was pressed against the paper, printing one character at a time. The maximum speed of the Selectric printer (the faster of the two) was 15.5 characters per second.

Teletypewriter-derived printers
The common teleprinter could easily be interfaced to the computer and became very popular except for those computers manufactured by IBM. Some models used a "typebox" that was positioned (in the X- and Y-axes) by a mechanism and the selected letter from was struck by a hammer. Others used a type cylinder in a similar way as the Selectric typewriters used their type ball. In either case, the letter form then struck a ribbon to print the letterform. Most teleprinters operated at ten characters per second although a few achieved 15 CPS.

Daisy wheel printers
Daisy-wheel printers operate in much the same fashion as a typewriter. A hammer strikes a wheel with petals (the daisy wheel), each petal containing a letter form at its tip. The letter form strikes a ribbon of ink, depositing the ink on the page and thus printing a character. By rotating the daisy wheel, different characters are selected for printing.

These printers were also referred to as letter-quality printers because, during their heyday, they could produce text which was as clear and crisp as a typewriter (though they were nowhere near the quality of printing presses). The fastest letter-quality printers printed at 30 characters per second.

Dot-matrix printers
In the general sense many printers rely on a matrix of pixels, or dots, that together form the larger image. However, the term dot matrix printer is specifically used for impact printers that use a matrix of small pins to create precise dots. The advantage of dot-matrix over other impact printers is that they can produce graphical images in addition to text; however the text is generally of poorer quality than impact printers that use letterforms (type).

A Tandy 1000 HX with a Tandy DMP-133 dot-matrix printer.Dot-matrix printers can be broadly divided into two major classes:

Ballistic wire printers (discussed in the dot matrix printers article)
Stored energy printers
Dot matrix printers can either be character-based or line-based (that is, a single horizontal series of pixels across the page), referring to the configuration of the print head.

At one time, dot matrix printers were one of the more common types of printers used for general use - such as for home and small office use. Such printers would have either 9 or 24 pins on the print head. 24 pin print heads were able to print at a higher quality. Once the price of inkjet printers dropped to the point where they were competitive with dot matrix printers, dot matrix printers began to fall out of favor for general use.

Some dot matrix printers, such as the NEC P6300, can be upgraded to print in color. This is achieved through the use of a four-color ribbon mounted on a mechanism (provided in an upgrade kit that replaces the standard black ribbon mechanism after installation) that raises and lowers the ribbons as needed. Color graphics are generally printed in four passes at standard resolution, thus slowing down printing considerably. As a result, color graphics can take up to four times longer to print than standard monochrome graphics, or up to 8-16 times as long at high resolution mode.

Dot matrix printers are still commonly used in low-cost, low-quality applications like cash registers, or in demanding, very high volume applications like invoice printing. The fact that they use an impact printing method allows them to be used to print multi-part documents using carbonless copy paper (like sales invoices and credit card receipts), whereas other printing methods are unusable with paper of this type. Dot-matrix printers are now (as of 2005) rapidly being superseded even as receipt printers.

Line printers
Line printers, as the name implies, print an entire line of text at a time. Three principle designs existed. In drum printers, a drum carries the entire character set of the printer repeated in each column that is to be printed. In chain printers (also known as train printers), the character set is arranged multiple times around a chain that travels horizontally past the print line. In either case, to print a line, precisely timed hammers strike against the back of the paper at the exact moment that the correct character to be printed is passing in front of the paper. The paper presses forward against a ribbon which then presses against the character form and the impression of the character form is printed onto the paper.

Comb printers represent the third major design. These printers were a hybrid of dot matrix printing and line printing. In these printers, a comb of hammers printed a portion of a row of pixels at one time (for example, every eighth pixel). By shifting the comb back and forth slightly, the entire pixel row could be printed (continuing the example, in just eight cycles). The paper then advanced and the next pixel row was printed. Because far less motion was involved than in a conventional dot matrix printer, these printers were very fast compared to dot matrix printers and were competitive in speed with formed-character line printers while also being able to print dot-matrix graphics.

Line printers were the fastest of all impact printers and were used for bulk printing in large computer centres. They were virtually never used with personal computers and have now been replaced by high-speed laser printers.

The legacy of line printers lives on in many computer operating systems, which use the abbreviations "lp", "lpr", or "LPT" to refer to printers.

Pen-based plotters
A plotter is a vector graphics printing device which operates by moving a pen over the surface of paper. Plotters have been (and still are) used in applications such as computer-aided design, though they are being replaced with wide-format conventional printers (which nowadays have sufficient resolution to render high-quality vector graphics using a rasterized print engine). It is commonplace to refer to such wide-format printers as "plotters", even though such usage is technically incorrect.

Other printers
A number of other sorts of printers are important for historical reasons, or for special purpose uses:

Digital minilab (photographic paper)
Electrolytic printers
Microsphere (printer) (special paper)
Spark printer (supplied for Sinclair ZX81)
barcode printer uses heat to print barcodes

Printing mode
The data received by a printer may be:

a string of characters
a bitmapped image
a vector image
Some printers can process all three types of data, others not.

Daisy wheel printers can handle only plain text data or rather simple point plots.
Plotters typically process vector images.
Modern printing technology, such as laser printers and inkjet printers, can adequately reproduce all three. This is especially true of printers equipped with support for PostScript and/or PCL; which includes the vast majority of printers produced today.
Today it is common to print everything (even plain text) by sending ready bitmapped images to the printer, because it allows better control over formatting. Many printer drivers do not use the text mode at all, even if the printer is capable of it.

Monochrome, color and photo printers
A monochrome printer can only produce an image consisting of one color, usually black. A monochrome printer may also be able to produce various hues of that color, such as a grey-scale.

A color printer can produce images of multiple colors.

A photo printer is a color printer that can produce images that mimic the color range (gamut) and resolution of photographic methods of printing.

The printer manufacturing business
Often the razor and blades business model is applied. That is, a company may sell a printer at cost, and make profits on the ink cartridge, paper, or some other replacement part. This has caused legal disputes regarding the right of companies other than the printer manufacturer to sell compatible ink cartridges.

Printing speed
The speed of early printers was measured in units of characters per second. More modern printers are measured in pages per minute. These measures are used primarily as a marketing tool, and are not well standardised. Usually pages per minute refers to sparse monochrome office documents, rather than dense pictures which usually print much more slowly.

Printer job classes
They are collections of printers. Print jobs sent to a class are forwarded to the first available printer in the class.

Forensic identification
Similar to forensic identification of typewriters, computer printers and copiers can be traced down by imperfections in their output. The mechanical tolerances of the toner and paper feed mechanisms cause banding, which contain information about the individual device's mechanical properties. It is sometimes possible to identify the manufacturer and brand, but in some cases the individual printer can be identified from a set of known ones by comparing their outputs. [2] [3]

Some high-quality color printers and copiers steganographically embed their identification code into the printed pages, as fine and almost invisible patterns of yellow dots. The sources identify Xerox and Canon as companies doing this [4] [5]. The Electronic Frontier Foundation has investigated[6] this issue and documented how the Xerox DocuColor printer's serial number, as well as the date and time of the printout, are encoded in a repeating 8×15 dot pattern in the yellow channel. EFF is working to reverse engineer additional printers.

September 11, 2008

What is a Computer display?

0 comments
What is a Computer display?

Computer display

A cable connects the monitor to a video adapter (video card) that is installed in an expansion slot on the computer’s motherboard. This system converts signals into text and pictures and displays them on a TV-like screen (the monitor).

The computer sends a signal to the video adapter, telling it what character, image, or graphic to display. The video adapter converts that signal to a set of instructions that tell the display device (monitor) how to draw the image on the screen.

It is important that the monitor have a TCO Certification.

Cathode ray tube
The CRT, or cathode ray tube, is the picture tube of your monitor. Although it is a large vacuum tube, it is shaped more like a bottle. The tube tapers near the back where there is a negatively charged cathode, or electron gun. The electron gun shoots electrons at the back of the positively charged screen, which is coated with a phosphorous chemical. This excites the phosphors causing them to glow as individual dots called pixels (picture elements). The image you see on the monitor's screen is made up of thousands of tiny dots (pixels). If you have ever seen a child's LiteBrite toy, then you have a good idea of the concept. The distance between the pixels has a lot to do with the quality of the image. If the distance between pixels on a monitor screen is too great, the picture will appear fuzzy, or grainy. The closer together the pixels are, the sharper the image on screen. The distance between pixels on a computer monitor screen is called its dot pitch and is measured in millimeters. (See sidebar.) Most modern monitors have a monitor with a dot pitch of .28 mm or less.

Note: From an environmental point of view, the monitor is the most difficult computer peripheral to dispose of because of the lead it contains.

There are two electromagnets (yokes) around the collar of the tube, which bend the beam of electrons. The beam scans (is bent) across the monitor from left to right and top to bottom to create, or draw the image, line by line. The number of times in one second that the electron gun redraws the entire image is called the refresh rate and is measured in Hertz (Hz). If the scanning beam hits each line of pixels, in succession, on each pass, then the monitor is known as a non-interlaced monitor. The electron beam on an interlaced monitor scans the odd numbered lines on one pass, and then scans the even lines on the second pass. Interlaced Monitors are typically harder to look at, and have been attributed to eyestrain and nausea.

Imaging technologies

19" inch (48 cm) CRT computer monitorAs with television, several different hardware technologies exist for displaying computer-generated output:

Liquid crystal display (LCD). (LCD-based monitors can receive television and computer protocols (SVGA, DVI, PAL, SECAM, NTSC). As of this writing (June 2006), LCD displays are the most popular display device for new computers in North America.
Cathode ray tube (CRT)
Vector displays, as used on the Vectrex, many scientific and radar applications, and several early arcade machines (notably Asteroids (game) - always implemented using CRT displays due to requirement for a deflection system, though can be emulated on any raster-based display.
Television receivers were used by most early personal and home computers, connecting composite video to the television set using a modulator. Image quality was reduced by the additional steps of composite video → modulator → TV tuner → composite video, though it reduced costs of adoption because one did not have to buy a specialized monitor.
Plasma display
Surface-conduction electron-emitter display (SED)
Video projector - implemented using LCD, CRT, or other technologies. Recent consumer-level video projectors are almost exclusively LCD based.
Organic light-emitting diode (OLED) display
During the era of early home computers, television sets were almost exclusively CRT-based.

Performance measurements
The relevant performance measurements of a monitor are:

Luminance
Size
Dot pitch. In general, the lower the dot pitch (e.g. 0.24), the sharper the picture will rate.
V-sync rate
Response time
Refresh rate

Display resolutions
A modern CRT display has considerable flexibility: it can usually handle a range of resolutions from 320 by 200 up to 2560 by 2040 pixels.

Issues and problems
Screen burn-in has been an issue for a long time with CRT computer monitors and televisions. Commonly, people use screensavers in order to prevent their computer monitors from getting screen burn-in. How this happens is that if an image is displayed on the screen for a long period without changing, the screen that is showing will embed itself into the glass. Generally, you will find this phenomenon at older ATM machines. In order to prevent screen burn-in on computer monitors, it is recommended that you use a good screensaver program that rotates often.

The other issue with computer monitors is that some LCD monitors may get dead pixels over time. This generally applies to older LCD monitors from the 1990s.

Things on both issues have changed over time and are improving in order to prevent these things from happening.

With exceptions of DLP, most display technologies (especially LCD) have an inherent misregistration of the color planes, that is, the centres of the red, green, and blue dots do not line up perfectly. Subpixel rendering depends on this misalignment; technologies making use of this include the Apple II from 1976 [1], and more recently Microsoft (ClearType, 1998) and XFree86 (X Rendering Extension).

Display interfaces

Computer Terminals
Early CRT-based VDUs (Visual Display Units) such as the DEC VT05 without graphics capabilities gained the label glass teletypes, because of the functional similarity to their electromechanical predecessors.

Composite monitors
Early home computers such as the Apple II and the Commodore 64 used composite monitors. However, they are now used with video game consoles.

Digital monitors
Early digital monitors are sometimes known as TTLs because the voltages on the red, green, and blue inputs are compatible with TTL logic chips. Later digital monitors support LVDS, or TMDS protocols.

TTL monitors

IBM PC with green monochrome displayMonitors used with the MDA, Hercules, CGA, and EGA graphics adapters used in early IBM Personal Computers and clones were controlled via TTL logic. Such monitors can usually be identified by a male DB-9 connector used on the video cable. The primary disadvantage of TTL monitors was the extremely limited number of colors available due to the low number of digital bits used for video signaling.

TTL Monochrome monitors only made use of five out of the nine pins. One pin was used as a ground, and two pins were used for horizontal/vertical synchronization. The electron gun was controlled by two separate digital signals, a video bit, and an intensity bit to control the brightness of the drawn pixels. Only four unique shades were possible; black, dim, medium or bright.

CGA monitors used four digital signals to control the three electron guns used in color CRTs, in a signalling method known as RGBI, or Red Green and Blue, plus Intensity. Each of the three RGB colors can be switched on or off independently. The intensity bit increases the brightness of all guns that are switched on, or if no colors are switched on the intensity bit will switch on all guns at a very low brightness to produce a dark grey. A CGA monitor is only capable of rendering 16 unique colors. The CGA monitor was not exclusively used by PC based hardware. The Commodore 128 could also utilize CGA monitors. Many CGA monitors were capable of displaying composite video via a separate jack.

EGA monitors used six digital signals to control the three electron guns in a signalling method known as RrGgBb. Unlike CGA, each gun is allocated its own intensity bit. This allowed each of the three primary colors to have four different states (off, soft, medium, and bright) resulting in 64 possible colors.

Although not supported in the original IBM specification, many vendors of clone graphics adapters have implemented backwards monitor compatibility and auto detection. For example, EGA cards produced by Paradise could operate as a MDA, or CGA adapter if a monochrome or CGA monitor was used place of an EGA monitor. Many CGA cards were also capable of operating as MDA or Hercules card if a monochrome monitor was used.

Modern technology

Analog RGB monitors
Most modern computer displays can show thousands or millions of different colors in the RGB color space by varying red, green, and blue signals in continuously variable intensities.

Digital and analog combination
Many monitors have analog signal relay, but some more recent models (mostly LCD screens) support digital input signals. It is a common misconception that all computer monitors are digital. For several years, televisions, composite monitors, and computer displays have been significantly different. However, as TVs have become more versatile, the distinction has blurred.

Configuration and usage

Multi-head

Some users use more than one monitor. The displays can operate in multiple modes. One of the most common spreads the entire desktop over all of the monitors, which thus act as one big desktop. The X Window System refers to this as Xinerama.

A monitor may also clone another monitor.

Dualhead - Using two monitors
Triplehead - using three monitors
Display assembly - multi-head configurations actively managed as a single unit

Virtual displays
The X Window System provides configuration mechanisms for using a single hardware monitor for rendering multiple virtual displays, as controlled (for example) with the Unix DISPLAY global variable or with the -display command option.

Major manufacturers
Apple Computer
BenQ
Dell, Inc.
Eizo
Iiyama Corporation
LaCie
LG Electronics
NEC Display Solutions
Philips
Samsung
Sony
ViewSonic
 

Copyright 2008 All Rights Reserved | Blogger Template by Computer Science and Computer Tips