Board index » delphi » Can anyone post 'Hello Wordl' coded using just the API?

Can anyone post 'Hello Wordl' coded using just the API?

I have looked in several sources (mostly Lloyd's help file for Delphi) for a
way to write a simple Win95 program using just WinTypes, WinProcs, Messages
etc. so that th eEXE is small.

I have coded a program that compiles ok and includes the message loop, as well
as the createwindow func, just as it says in Lloyd's help file, byt the window
doesn't appear!

Does anyone have a simple Hello World program coded in Delphi using the api
instead of the Forms unit that would share this info. with the rest of us?

Thanks,
        Phil Jones

Author of OmniCon 96 - The BEST Unit Converter for Win95!
WWW: http://darwin.biology.queensu.ca/~jonesp/omnicon/index.html
E-Mail: jon...@darwin.biology.QueensU.Ca

 

Re:Can anyone post 'Hello Wordl' coded using just the API?


In <4jn62i$...@knot.queensu.ca>, jon...@biology.queensu.ca (Phil Jones) writes:

Quote
>I have looked in several sources (mostly Lloyd's help file for Delphi) for a
>way to write a simple Win95 program using just WinTypes, WinProcs, Messages
>etc. so that th eEXE is small.

>I have coded a program that compiles ok and includes the message loop, as well
>as the createwindow func, just as it says in Lloyd's help file, byt the window
>doesn't appear!

>Does anyone have a simple Hello World program coded in Delphi using the api
>instead of the Forms unit that would share this info. with the rest of us?

>Thanks,
>        Phil Jones

>Author of OmniCon 96 - The BEST Unit Converter for Win95!
>WWW: http://darwin.biology.queensu.ca/~jonesp/omnicon/index.html
>E-Mail: jon...@darwin.biology.QueensU.Ca

Phil,
This may be a stupid question, but have you tried the ShowWindow API, which takes
a window handle and a show method as input args ?
Once your window is created, you should get a window handle returned if successfull.
I haven't actually read Lloyd's help file. Is it good ?

Cheers,
Karsten

Re:Can anyone post 'Hello Wordl' coded using just the API?


Quote
In article <Dp69pv....@unx.sas.com>, Karst...@dk-online.dk wrote:
>In <4jn62i$...@knot.queensu.ca>, jon...@biology.queensu.ca (Phil Jones) writes:
>>Does anyone have a simple Hello World program coded in Delphi using the api
>>instead of the Forms unit that would share this info. with the rest of us?

>Phil,
>This may be a stupid question, but have you tried the ShowWindow API, which
> takes
>a window handle and a show method as input args ?
>Once your window is created, you should get a window handle returned if
> successfull.

Lloyd's file is quite good. Yes, I did try this api func., but it doesn't make
it work!

Somebody! Help us build small apps!

Phil

Author of OmniCon 96 - The BEST Unit Converter for Win95!
WWW: http://darwin.biology.queensu.ca/~jonesp/omnicon/index.html
E-Mail: jon...@darwin.biology.QueensU.Ca

Re:Can anyone post 'Hello Wordl' coded using just the API?


On Mon, 01 Apr 96 12:59:08 GMT, jon...@biology.queensu.ca (Phil Jones)
wrote:

Quote
>In article <Dp69pv....@unx.sas.com>, Karst...@dk-online.dk wrote:
>>In <4jn62i$...@knot.queensu.ca>, jon...@biology.queensu.ca (Phil Jones) writes:
>>>Does anyone have a simple Hello World program coded in Delphi using the api
>>>instead of the Forms unit that would share this info. with the rest of us?
>>This may be a stupid question, but have you tried the ShowWindow API, which
>> takes
>>a window handle and a show method as input args ?
>>Once your window is created, you should get a window handle returned if
>> successfull.

>Somebody! Help us build small apps!

Have you tried modifying \delphi\demos\generic.dpr to your needs
already?

--
Viele Gruesse / Best regards

Stefan
Stefan.Hoffmeis...@Uni-Passau.de

Re:Can anyone post 'Hello Wordl' coded using just the API?


Quote
>>>>Does anyone have a simple Hello World program coded in Delphi using the api
>>>>instead of the Forms unit that would share this info. with the rest of us?
>>Somebody! Help us build small apps!

>Have you tried modifying \delphi\demos\generic.dpr to your needs
>already?

Yes, strangely enough, if one recompiles this code under Delphi 2.0, it
doesn't work! Does anyone know how to get this program to compile and WORK
under Delphi 2.0/Win95?

Thanks,
        Phil

Author of OmniCon 96 - The BEST Unit Converter for Win95!
WWW: http://darwin.biology.queensu.ca/~jonesp/omnicon/index.html
E-Mail: jon...@darwin.biology.QueensU.Ca

Re:Can anyone post 'Hello Wordl' coded using just the API?


Quote
Phil Jones wrote:

> In article <Dp69pv....@unx.sas.com>, Karst...@dk-online.dk wrote:
> >In <4jn62i$...@knot.queensu.ca>, jon...@biology.queensu.ca (Phil Jones) writes:
> >>Does anyone have a simple Hello World program coded in Delphi using the api
> >>instead of the Forms unit that would share this info. with the rest of us?

> >Phil,
> >This may be a stupid question, but have you tried the ShowWindow API, which
> > takes
> >a window handle and a show method as input args ?
> >Once your window is created, you should get a window handle returned if
> > successfull.

> Lloyd's file is quite good. Yes, I did try this api func., but it doesn't make
> it work!

> Somebody! Help us build small apps!

> Phil

> Author of OmniCon 96 - The BEST Unit Converter for Win95!
> WWW: http://darwin.biology.queensu.ca/~jonesp/omnicon/index.html
> E-Mail: jon...@darwin.biology.QueensU.Ca

World's smallest Windows Program:

begin
  Messagebox(0, 'Hello World', 'Hello', MB_OK);
end;

The generic.pas file in the demos directory on the 1.0 cd
uses only WinApi calls.

Joe

--
Joe C. Hecht
Borland Delphi Developer Support Group
http://www.borland.com

Re:Can anyone post 'Hello Wordl' coded using just the API?


Quote
In article <31615FD9.3...@wpo.borland.com>, Joe Hecht <jhe...@wpo.borland.com> wrote:
>Phil Jones wrote:
>World's smallest Windows Program:

>begin
>  Messagebox(0, 'Hello World', 'Hello', MB_OK);
>end;

>The generic.pas file in the demos directory on the 1.0 cd
>uses only WinApi calls.

Joe. I have compilled and used successfully the generic sample from D1.
However, I cannot compile or run this code from D2. I need to show a window
(not just a messagebox) using just the api so that the one or two functions I
call won't incur the 150K barrier that Delphi gives me.

Can you figure out why this prog. won't compile in D2?

Thanks,
        Phil Jones

Author of OmniCon 96 - The BEST Unit Converter for Win95!
WWW: http://darwin.biology.queensu.ca/~jonesp/omnicon/index.html
E-Mail: jon...@darwin.biology.QueensU.Ca

Re:Can anyone post 'Hello Wordl' coded using just the API?


jo>Does anyone have a simple Hello World program coded in Delphi using the ap
jo>instead of the Forms unit that would share this info. with the rest of us?

Delphi comes with just such an example, GENERIC.PAS

--
Mr. HillBilly (hillbi...@programmers.bbs.no)
Programmers BBS er oppe igjen, n? p? tlf. 22217666/22217669!
 tHyperSoft HyperReader 1.0t

Re:Can anyone post 'Hello Wordl' coded using just the API?


Quote
In article <MBIN.29624....@infolink.no>, eiv...@infolink.no wrote:
>jo>Does anyone have a simple Hello World program coded in Delphi using the ap
>jo>instead of the Forms unit that would share this info. with the rest of us?

>Delphi comes with just such an example, GENERIC.PAS

Yes... but have you tried to compile this code in D2? No go! Do you know why
this won't work??

Thanks,
        Phil

Author of OmniCon 96 - The BEST Unit Converter for Win95!
WWW: http://darwin.biology.queensu.ca/~jonesp/omnicon/index.html
E-Mail: jon...@darwin.biology.QueensU.Ca

Re:Can anyone post 'Hello Wordl' coded using just the API?


Quote
In article <4jud25$...@knot.queensu.ca> jon...@biology.queensu.ca (Phil Jones) writes:
>In article <MBIN.29624....@infolink.no>, eiv...@infolink.no wrote:
>>jo>Does anyone have a simple Hello World program coded in Delphi using the ap
>>jo>instead of the Forms unit that would share this info. with the rest of us?

>>Delphi comes with just such an example, GENERIC.PAS
>Yes... but have you tried to compile this code in D2? No go! Do you know why
>this won't work??

I'm sorry, but Mr. Wo is out of the office at the moment.  But I'll tell him
you said hello...

{ Good grief, why would you want to program to the API if you have Delphi?  
Lessee... LODSB... no wait a minute, let's get REALLY low level... $E6... no
wait a sec...  11100110... ;-)  }

Re:Can anyone post 'Hello Wordl' coded using just the API?


Quote
Phil Jones wrote:

> In article <31615FD9.3...@wpo.borland.com>, Joe Hecht <jhe...@wpo.borland.com> wrote:
> >Phil Jones wrote:
> >World's smallest Windows Program:

> >begin
> >  Messagebox(0, 'Hello World', 'Hello', MB_OK);
> >end;

> >The generic.pas file in the demos directory on the 1.0 cd
> >uses only WinApi calls.

> Joe. I have compilled and used successfully the generic sample from D1.
> However, I cannot compile or run this code from D2. I need to show a window
> (not just a messagebox) using just the api so that the one or two functions I
> call won't incur the 150K barrier that Delphi gives me.

> Can you figure out why this prog. won't compile in D2?

> Thanks,
>         Phil Jones

> Author of OmniCon 96 - The BEST Unit Converter for Win95!
> WWW: http://darwin.biology.queensu.ca/~jonesp/omnicon/index.html
> E-Mail: jon...@darwin.biology.QueensU.Ca

Ok... a quick hack produces:

program Generic;

(* Save this section as GENERIC.RC and
   Compile to GENERIC.RES with the
   Borland 32 bit Resource Command Line Compiler
   (BRCC32.EXE) located in the Delphi 2.0 Bin Directory.

MAINICON ICON LOADONCALL MOVEABLE DISCARDABLE IMPURE
BEGIN
        '00 00 01 00 01 00 20 40 10 00 00 00 00 00 E8 02'
        '00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00'
        '00 00 01 00 04 00 00 00 00 00 00 02 00 00 00 00'
        '00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00'
        '00 00 00 00 80 00 00 80 00 00 00 80 80 00 80 00'
        '00 00 80 00 80 00 80 80 00 00 C0 C0 C0 00 80 80'
        '80 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00'
        '00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 08'
        'F7 88 76 76 78 F7 88 60 F7 37 38 80 00 00 00 08'
        'F7 88 67 67 68 F7 88 70 F7 37 38 80 00 00 00 08'
        'F7 88 76 76 78 F7 88 60 F7 37 38 80 00 00 00 08'
        'F7 88 67 67 68 F7 88 70 F7 37 38 80 00 00 00 08'
        'F7 88 76 76 78 F7 88 60 F7 37 38 80 00 00 00 08'
        'F7 88 67 67 68 F7 88 70 F7 37 38 80 00 00 88 88'
        '88 88 88 88 88 88 88 80 F7 37 38 80 88 00 87 77'
        '77 77 77 77 88 88 88 80 F7 37 38 80 78 00 88 88'
        '88 88 88 88 88 88 88 80 F7 37 38 80 88 00 00 88'
        'FF 77 77 77 77 77 77 70 F7 37 38 80 80 00 00 00'
        '88 FF 78 88 88 88 88 80 F7 37 38 80 00 00 00 00'
        '00 88 FF 78 87 77 78 80 F3 78 83 80 00 00 00 00'
        '00 00 88 FF 78 77 87 0F 37 87 88 38 00 00 00 00'
        '00 00 00 88 FF 88 70 F3 78 70 08 83 80 00 00 00'
        '00 00 00 00 88 FF 0F 37 87 77 77 88 38 00 00 00'
        '00 00 00 00 00 80 F3 78 73 03 03 08 78 80 00 00'
        '00 00 00 00 00 80 37 87 00 00 00 00 88 30 00 00'
        '00 00 00 00 00 00 00 01 11 11 11 11 11 00 00 00'
        '00 00 00 00 00 00 00 99 B9 99 B9 99 99 00 00 00'
        '00 00 00 00 00 00 00 99 B9 B9 9B B9 B9 00 00 00'
        '00 00 00 00 00 00 09 9B B9 BB 99 BB 99 00 00 00'
        '00 00 00 00 00 00 09 9B 99 9B 99 99 99 00 00 00'
        '00 00 00 00 00 00 09 9B 9B 9B B9 BB 99 00 00 00'
        '00 00 00 00 00 00 00 9B 9B 9B B9 99 90 00 00 00'
        '00 00 00 00 00 00 00 9B 99 B9 BB 9B 00 00 00 00'
        '00 00 00 00 00 00 00 09 99 B9 99 90 00 00 00 00'
        '00 00 00 00 00 00 00 00 99 BB 99 90 00 00 00 00'
        '00 00 00 00 00 00 00 00 09 99 B9 00 00 00 00 00'
        '00 00 00 00 00 00 00 00 00 09 99 00 00 00 00 00'
        '00 00 00 00 00 00 00 00 00 00 99 00 00 00 00 00'
        '00 00 00 00 00 00 00 00 00 00 90 00 00 00 00 00'
        '00 00 00 00 00 00 00 00 00 00 00 00 00 00 E0 00'
        '00 0F E0 00 00 0F E0 00 00 0F E0 00 00 0F E0 00'
        '00 0F E0 00 00 0F 00 00 00 03 00 00 00 03 00 00'
        '00 03 C0 00 00 07 F0 00 00 0F FC 00 00 0F FF 00'
        '00 07 FF C0 01 83 FF F0 00 01 FF FC 02 A0 FF FC'
        '0F F0 FF FE 00 00 FF FF C0 03 FF FF C0 03 FF FF'
        '80 03 FF FF 80 03 FF FF 80 03 FF FF C0 07 FF FF'
        'C0 0F FF FF E0 1F FF FF F0 1F FF FF F8 3F FF FF'
        'FE 3F FF FF FF 3F FF FF FF 7F FF FF FF FF'
END

GENERIC MENU
BEGIN
        POPUP "&Help"
        BEGIN
                MENUITEM "&About Generic...", 100
        END

END

ABOUTBOX DIALOG 10, 35, 144, 88
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About Generic"
FONT 8, "System"
BEGIN
        CONTROL "&OK", 1, "BUTTON", BS_PUSHBUTTON | WS_CHILD |
WS_VISIBLE | WS_TABSTOP, 53, 66, 38, 15
        CONTROL "Generic Application", 102, "STATIC", SS_CENTER |
WS_CHILD | WS_VISIBLE, 35, 20, 75, 9
        CONTROL "Delphi Demo", 103, "STATIC", SS_CENTER | WS_CHILD |
WS_VISIBLE, 30, 10, 85, 10
        CONTROL "Copyright \251 1996", 104, "STATIC", SS_CENTER |
WS_CHILD | WS_VISIBLE, 35, 39, 71, 10
        CONTROL "Borland International", 105, "STATIC", SS_CENTER |
WS_CHILD | WS_VISIBLE, 37, 49, 70, 10
END

*)

{$R GENERIC.RES}  

uses Windows, Messages;

const
  AppName = 'Generic';

const
  idm_About = 100;

function About(Dialog: HWnd; Message: UINT; WPram: WPARAM;
  LPram: LPARAM): LRESULT; stdcall; export;
begin
  About := LRESULT(True);
  case Message of
    wm_InitDialog:
      Exit;
    wm_Command:
      if (WPram = id_Ok) or (WPram = id_Cancel) then
      begin
        EndDialog(Dialog, 1);
        Exit;
      end;
  end;
  About := LRESULT(False);
end;

function WindowProc(Window: Longint; Message: UINT; WPram: WPARAM;
  LPram: LPARAM): LRESULT; stdcall; export;
var
  AboutProc: TFarProc;
begin
  WindowProc := 0;
  case Message of
    wm_Command:
    if WPram = idm_About then
    begin
      AboutProc := MakeProcInstance(@About, HInstance);
      DialogBox(HInstance, 'AboutBox', Window, AboutProc);
      FreeProcInstance(AboutProc);
      Exit;
    end;
   wm_Destroy:
     begin
       PostQuitMessage(0);
       Exit;
     end;
  end;
  WindowProc := DefWindowProc(Window, Message, WPram, LPram);
end;

procedure WinMain;
var
  Window: HWND;
  Message: TMsg;
  WindowClass: TWndClass;
begin
  WindowClass.style:= 0;
  WindowClass.lpfnWndProc:= @WindowProc;
  WindowClass.cbClsExtra:= 0;
  WindowClass.cbWndExtra:= 0;
  WindowClass.hIcon:= LoadIcon(HInstance, 'MAINICON');
  WindowClass.hCursor:= LoadCursor(0, IDC_ARROW);
  WindowClass.hbrBackground:= 0;
  WindowClass.lpszMenuName:= AppName;
  WindowClass.lpszClassName:= AppName;
  WindowClass.hInstance := HInstance;
  WindowClass.hbrBackground := GetStockObject(white_Brush);
  RegisterClass(WindowClass);
  Window := CreateWindow(
    AppName,
    'Delphi Generic',
    ws_OverlappedWindow,
    cw_UseDefault,
    cw_UseDefault,
    cw_UseDefault,
    cw_UseDefault,
    0,
    0,
    HInstance,
    nil);
  ShowWindow(Window, CmdShow);
  UpdateWindow(Window);
  while GetMessage(Message, 0, 0, 0) do
  begin
    TranslateMessage(Message);
    DispatchMessage(Message);
  end;
  Halt(Message.wParam);
end;

begin
  WinMain;
end.

--
Joe C. Hecht
Borland Delphi Developer Support Group
http://www.borland.com

Re:Can anyone post 'Hello Wordl' coded using just the API?


Quote
Joe Hecht <jhe...@wpo.borland.com> wrote:

>begin
>  Messagebox(0, 'Hello World', 'Hello', MB_OK);
>end;
>The generic.pas file in the demos directory on the 1.0 cd
>uses only WinApi calls.

program Test;
var
 I:integer;
begin
 for I:=1 to 100 do
  writeln('Delphi 32 - DOS mode');
end.

then dcc -cc test.pas

bingo.

C.L.Burke

Re:Can anyone post 'Hello Wordl' coded using just the API?


In article <4jpgfp$...@knot.queensu.ca>,
   jon...@biology.queensu.ca (Phil Jones) wrote:

Quote
>>>>>Does anyone have a simple Hello World program coded in Delphi using the
api
>>>>>instead of the Forms unit that would share this info. with the rest of
us?
>>>Somebody! Help us build small apps!

>>Have you tried modifying \delphi\demos\generic.dpr to your needs
>>already?

>Yes, strangely enough, if one recompiles this code under Delphi 2.0, it
>doesn't work! Does anyone know how to get this program to compile and WORK
>under Delphi 2.0/Win95?

You didn't mention whether it wouldn't compile or wouldn't work after it was
compiled.

If it doesn't work but compiles alright, the problem may be the resource file.
If you didn't rebuild the resource file, the 32 bit file will try to use a 16
bit resource file and crash.

Re:Can anyone post 'Hello Wordl' coded using just the API?


Am having trouble getting a Delphi form inside the Netscape API client
window. Netscape API gives a handel to its client area but I can't
figure out how to paint my form inside of that. I've got my form in a
DLL.

Been able to accomplish this in C++ by using the WIndows API function
GetWindowLong and SetWindowLong but Form.Handle in Delphi is a read
only property. Also having trouble instantiating the form inside the
DLL.

Any insight is appreciated.

Thank You,

Sam Stone
sa...@ix.netcom.com  

Other Threads