Einzelnen Beitrag anzeigen

Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#2

AW: TMaskEdit mit Maske prüfen ob Eingabe erfolgt ist

  Alt 25. Sep 2012, 22:15
was hältst Du hiervon?
Delphi-Quellcode:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    ButtonCreateInput: TButton;
    ButtonAcceptInput: TButton;
    procedure ButtonCreateInputClick(Sender: TObject);
    procedure ButtonAcceptInputClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    MyIPEdit: HWND;
    MyIPAddress: integer;
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.ButtonCreateInputClick(Sender: TObject);
Const
 x=10;
 y=10;
 w=130;
 h=22;
begin
  MyIPAddress := MAKEIPADDRESS(127, 0, 0, 1); // Vorbelegung
  InitCommonControl(ICC_INTERNET_CLASSES);
  MyIPEdit := CreateWindow(WC_IPADDRESS, nil, WS_CHILD or WS_VISIBLE, x, y,
    w, h, self.Handle, 0, hInstance, nil);
  SendMessage(MyIPEdit, IPM_SETADDRESS, 0, MyIPAddress);
  // Vorbelegung eintragen wenn gewünscht
  SendMessage(MyIPEdit, IPM_SETFOCUS, 0, 0);

end;

procedure TForm2.ButtonAcceptInputClick(Sender: TObject);
begin
  SendMessage(MyIPEdit, IPM_GETADDRESS, 0, longint(@MyIPAddress));
  if MyIPAddress = 0 then
  begin
    Showmessage('Keine IP-Adresse');
    SendMessage(MyIPEdit, IPM_SETFOCUS, 0, 0);
  end
  else
    Showmessage('IP: ' + IntToStr(FIRST_IPADDRESS(MyIPAddress)) + '.' + IntToStr
        (SECOND_IPADDRESS(MyIPAddress)) + '.' + IntToStr
        (THIRD_IPADDRESS(MyIPAddress)) + '.' + IntToStr
        (FOURTH_IPADDRESS(MyIPAddress)) + '.')
end;

end.
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat