Search results for 'Windows API'. 31 post(s) found.

  1. 2007/09/25 Window flashing
  2. 2007/09/25 How to use TTF Font Without Installing
  3. 2007/09/25 How to show window contents while dragging
  4. 2007/09/25 How to save text from Clipboard to a file
  5. 2007/09/25 How to send char as message to another application
  6. 2007/09/25 How to restrict mouse movement
  7. 2007/09/25 List Devices (LPT, COM ports, ...)
  8. 2007/09/25 How to know whether the font is TrueTypeFont or not
  9. 2007/09/25 How to track a user's idle time
  10. 2007/09/25 How to remove your application from TaskBar
2007/09/25 14:30

Window flashing


Flashing a window means changing the appearance of its caption bar as if the window were changing from inactive to active status, or vice versa.

Typically, a window is flashed to inform the user that the window requires attention but that it does not currently have the keyboard focus.

The FlashWindow API function flashes the window only once.

To create a flashing window add a TTimer component on a form, and use the following code in the OnTimer event handler:

procedure TForm1.Timer1Timer(Sender: TObject) ;
begin
   FlashWindow (Handle, True) ;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 01:44 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 09:57 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/25 14:29

How to use TTF Font Without Installing


Here's how to use a TTF (true type font) in your Delphi application without having to install it in Windows:

1. In the OnCreate event for the main form in your Delphi application call the AddFontResource API function. The AddFontResource function adds the font resource from the specified file to the system font table.
2. When an application no longer needs a font resource that it loaded by calling the AddFontResource function, it must remove that resource by calling the RemoveFontResource function. Do this in the OnDestroy event for the main form.

procedure TForm1.FormCreate(Sender: TObject) ;
begin
  AddFontResource('c:\FONTS\MyFont.TTF') ;
  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;

{Before application terminates we must remove our font:}
procedure TForm1.FormDestroy(Sender: TObject; var Action: TCloseAction) ;
begin
  RemoveFontResource('C:\FONTS\MyFont.TTF') ;
  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;
Trackback 7 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/25 08:18 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 21:37 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 06:09 delete

    moneyideas

  4. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

  5. Subject Phentermine 37.5 mg online prescription.

    Tracked from Phentermine pill online d. 2010/03/05 07:58 delete

    Phentermine online. Lowest online phentermine price. Online phentermine. Lowes t online phentermine price.

  6. Subject Cheap 37 5 phentermine.

    Tracked from Cheap phentermine free shipping. 2010/03/07 23:04 delete

    Cheap phentermine. Phentermine cheap. Cheap phentermine online no rx saturday delivery. Cheap phentermine online. Cheap phentermine cod.

  7. Subject Buy phentermine online.

    Tracked from Buy phentermine on line. 2010/03/09 16:38 delete

    Buy phentermine online buy. Buy phentermine. Buy phentermine online without a prescription. Buy phentermine online no prescription. Buy phentermine mexico. Buy phentermine on line to nevada. Buy no phentermine prescription. Buy cheap phentermine.

2007/09/25 14:27

How to show window contents while dragging


Here's how to enable or disable the "Show window contents while dragging" Windows fature from Delphi code:

//To Show window contents while dragging:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 1, nil, 0) ;

//To disable this option call the function:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, 0, nil, 0) ;

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 22:26 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 06:42 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/25 14:19

How to save text from Clipboard to a file


If you want to save the text data contained in the Clipboard to a text file on a disk, use the next code:

{
Usage:

ClipboardTxtToFile(c:\dir\cliptext.txt)
}

uses Clipbrd;

function ClipboardTxtToFile
         (sFileTXT : string) : boolean;
var
   ps1, ps2 : PChar;
   dwLen : DWord;
   tf : TextFile;
   hData : THandle;
begin
  Result := False;
  with Clipboard do begin
   try
    Open;
     if(HasFormat(CF_TEXT)) then begin
      hData := GetClipboardData(CF_TEXT) ;
      ps1 := GlobalLock(hData) ;
      dwLen := GlobalSize(hData) ;
      ps2 := StrAlloc(1 + dwLen) ;
      StrLCopy( ps2, ps1, dwLen ) ;
      GlobalUnlock( hData ) ;

      AssignFile(tf, sFileTXT) ;
      ReWrite(tf) ;
      Write(tf, ps2) ;
      CloseFile(tf) ;

      StrDispose( ps2 ) ;
      Result := True;
     end;
    finally
     Close;
   end;
  end;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 03:13 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 12:10 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/25 14:17

How to send char as message to another application


The following code is used to insert a character into another application - Notepad.

procedure TForm1.Button1Click(Sender: TObject) ;
var g,d:integer;
begin
  {Find the main window of the Application}
  g:=FindWindow('Notepad',nil) ;
  {Find the window of the application's text box}
  d:=ChildWindowFromPoint(g,point(50,50)) ;
  {Now send it a character!!}
  SendMessage(d,WM_CHAR,Ord('A'),0) ;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 03:54 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 12:46 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/25 14:16

How to restrict mouse movement


Here's how to restrict the mouse movement to a form and release this restriction after a click on a form:

procedure TForm1.FormCreate(Sender: TObject) ;
var r : TRect;
begin
    //it would be good idea to move the
    //mouse inside the form before restriction
   r := BoundsRect;
   ClipCursor(@R) ;
end;

procedure TForm1.FormClick(Sender: TObject) ;
begin
   //always be sure to release the cursor
   ClipCursor(nil) ;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 22:28 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 06:39 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/25 14:15

List Devices (LPT, COM ports, ...)


The following procedure will list all the devices on your computer. You can then extract the com ports and printer ports by looking for the 'COM' and 'LPT' characters in the list.

Add a Memo and a Button and place this code in the OnClick of a button...

procedure TForm1.Button1Click(Sender: TObject) ;
var
  istr: string;
  isize, j: dword;
begin
   setlength(istr, 4000) ;
   isize := QueryDosDevice(nil, @istr[1], 4000) ;
   for j := 1 to isize do
     if istr[j] = #0 then istr[j] := #10;
   memo1.lines.CommaText := istr;
end;
Trackback 6 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Percocet.

    Tracked from Percocet side effects. 2009/03/17 14:40 delete

    How long does percocet 7.5 stay in your system. Symtoms of withdrawl from percocet. Percocet. Percocet 93-490 10 mg.

  2. Subject Weight gain and nexium.

    Tracked from Nexium. 2009/04/18 17:29 delete

    Generic name nexium. Side effects from going off nexium. Nexium.

  3. Subject Viagra.

    Tracked from Re viagra cello. 2009/05/02 15:03 delete

    Viagra. Free viagra. Re viagra cello. Buy viagra uk.

  4. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 00:55 delete

    moneyideas

  5. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 09:26 delete

    moneyideas

  6. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/25 14:13

How to know whether the font is TrueTypeFont or not


Given a font's name (such as Arial,Verdana, Times New Roman, etc), function returns a boolean value indicating whether the font is or isn't a True Type font.

function IsTrueTypeFont(FontName : string):boolean;
const
  PITCH_MASK: byte = $0F;
var
  TxMet: TTextMetric;
  TempCanvas : TCanvas;
  PitchTest : byte;
begin
  TempCanvas:=TCanvas.Create;
  TempCanvas.Handle:=CreateCompatibleDC(0) ;
  TempCanvas.Font.Name:=FontName;
  GetTextMetrics(TempCanvas.Handle, TxMet) ;
  PitchTest:=TxMet.tmPitchAndFamily and PITCH_MASK;
  Result:=(PitchTest and TMPF_TRUETYPE) <> 0;
  TempCanvas.free;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 00:44 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 09:01 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/25 14:12

How to track a user's idle time


Suppose you have a data-critical type of application where you would not want a non-authored user to work with the data. Such an application could automatically log out the current user if no user activity has taken place in a lengthy time.

To track a user's idle time you could hook keyboard and mouse activity. Note, however, that installing a system-wide message hook is a very invasive thing to do and should be avoided if possible, since it will require your hook DLL to be loaded into all processes.

Another solution is to use the GeTLastInputInfo API function (if your application is running on Win2000 (and up) machines).
GeTLastInputInfo retrieves the time (in milliseconds) of the last input event (when the last detected user activity has been received, be it from keyboard or mouse).

Here's a simple example.

The SecondsIdle function returns a number of second with no user activity (called in an OnTimer event of a TTimer component).

function SecondsIdle: DWord;
var
   liInfo: TLastInputInfo;
begin
   liInfo.cbSize := SizeOf(TLastInputInfo) ;
   GeTLastInputInfo(liInfo) ;
   Result := (GetTickCount - liInfo.dwTime) DIV 1000;
end;

procedure TForm1.Timer1Timer(Sender: TObject) ;
begin
   Caption := Format('System IDLE last %d seconds', [SecondsIdle]) ;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 05:01 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 13:54 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/09/25 14:11

How to remove your application from TaskBar


If you need to hide your application from the Windows TaskBar, you can use the following trick:

procedure TForm1.FormCreate(Sender: TObject) ;
begin
   ShowWindow(Application.Handle, SW_HIDE) ;
   SetWindowLong(Application.Handle, GWL_EXSTYLE,
     getWindowLong(Application.Handle, GWL_EXSTYLE) or
     WS_EX_TOOLWINDOW) ;
   ShowWindow(Application.Handle, SW_SHOW) ;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 23:46 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 08:18 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas