was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

42 Visitors Online


 
...ein Fenster mit purem API erzeugen?
Autor: Thomas Stutz
[ Tip ausdrucken ]  

Tip Bewertung (14):  
     


// Put this code in your Project file (*.dpr).
// Den Code in eine Projekt Datei (*.dpr) einfügen.

program Project1;

uses
  
windows, messages;


// Main Window Procedure

function MainWndProc(hWindow: HWND; Msg: UINT; wParam: wParam;
  lParam: lParam): LRESULT; stdcallexport;
var
  
ps: TPaintStruct;
begin
  
Result := 0;
  case Msg of
    
WM_PAINT:
      begin
        
BeginPaint(hWindow, ps);
        SetBkMode(ps.hdc, TRANSPARENT);
        TextOut(ps.hdc, 10, 10, 'Hello, World!', 13);
        EndPaint(hWindow, ps);
      end;
    WM_DESTROY: PostQuitMessage(0);
    else
      begin
        
Result := DefWindowProc(hWindow, Msg, wParam, lParam);
        Exit;
      end;
  end;
end;

// Main Procedure

var
  
wc: TWndClass;
  hWindow: HWND;
  Msg: TMsg;
begin
  
wc.lpszClassName := 'YourAppClass';
  wc.lpfnWndProc   := @MainWndProc;
  wc.Style         := CS_VREDRAW or CS_HREDRAW;
  wc.hInstance     := hInstance;
  wc.hIcon         := LoadIcon(0, IDI_APPLICATION);
  wc.hCursor       := LoadCursor(0, IDC_ARROW);
  wc.hbrBackground := (COLOR_WINDOW + 1);
  wc.lpszMenuName  := nil;
  wc.cbClsExtra    := 0;
  wc.cbWndExtra    := 0;
  RegisterClass(wc);
  hWindow := CreateWindowEx(WS_EX_CONTROLPARENT or WS_EX_WINDOWEDGE,
    'YourAppClass',
    'API',
    WS_VISIBLE or WS_CLIPSIBLINGS or
    
WS_CLIPCHILDREN or WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, 0,
    400, 300,
    0,
    0,
    hInstance,
    nil);

  ShowWindow(hWindow, CmdShow);
  UpDateWindow(hWindow);

  while GetMessage(Msg, 0, 0, 0) do
  begin
    
TranslateMessage(Msg);
    DispatchMessage(Msg);
  end;
  Halt(Msg.wParam);
end.


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners