Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How can I create a form without using the Forms unit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
04-Oct-02
Category
Win API
Language
Delphi 2.x
Views
33
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius 

How can I create a form without using the Forms unit?

Answer:

1   program InputAPI;
2   
3   uses
4     Windows, Messages;
5   
6   var
7     WinClass: TWndClassA;
8     Inst, Handle, Button1, Button2: Integer;
9     Msg: TMsg;
10    hFont: Integer;
11  
12    { Custom WindowProc function }
13  
14  function WindowProc(hWnd, uMsg, wParam, lParam: Integer): Integer; stdcall;
15  begin
16    Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
17    { Checks for messages }
18    if uMsg = WM_DESTROY then
19      Halt;
20  end;
21  
22  begin
23    { Register Custom WndClass }
24    Inst := hInstance;
25    with WinClass do
26    begin
27      style := CS_CLASSDC or CS_PARENTDC;
28      lpfnWndProc := @WindowProc;
29      hInstance := Inst;
30      hbrBackground := color_btnface + 1;
31      lpszClassname := 'Test';
32      hCursor := LoadCursor(0, IDC_ARROW);
33    end;
34    RegisterClass(WinClass);
35    { Create Main Window }
36    Handle := CreateWindowEx(WS_EX_WINDOWEDGE or WS_EX_CONTROLPARENT, 'Test',
37      'TestWindow', WS_VISIBLE or WS_CAPTION or WS_SYSMENU, 300, 200, 300, 100,
38      0, 0, Inst, nil);
39    { Create a button }
40    Button1 := CreateWindow('Button', 'Ok', WS_VISIBLE or WS_CHILD or WS_TABSTOP or
41      BS_PUSHLIKE or BS_TEXT, 50, 20, 75, 25, handle, 0, Inst, nil);
42    Button2 := CreateWindow('Button', 'Cancel', WS_VISIBLE or WS_CHILD or WS_TABSTOP 
43  or
44      BS_PUSHLIKE or BS_TEXT, 150, 20, 75, 25, handle, 0, Inst, nil);
45    { Create Font Handle }
46    hFont := CreateFont(-15, 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 
47  OUT_DEFAULT_PRECIS,
48      CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH or FF_DONTCARE,
49      'MS Sans Serif');
50    { Change fonts }
51    if hFont <> 0 then
52    begin
53      SendMessage(Button1, WM_SETFONT, hFont, 0);
54      SendMessage(Button2, WM_SETFONT, hFont, 0);
55    end;
56    SetFocus(Button1);
57    UpdateWindow(Handle);
58    { Message Loop }
59    while (GetMessage(Msg, 0, 0, 0)) do
60      if not IsDialogMessage(handle, msg) then
61      begin
62        TranslateMessage(msg);
63        DispatchMessage(msg);
64      end;
65  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC