-
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="firstapp" type="win32gui" installbase="system32" installname="firstapp.exe" unicode="yes">
<bootstrap installbase="$(CDOUTPUT)" />
<include base="firstapp">.</include>
<library>kernel32</library>
<library>gdi32</library>
<library>user32</library>
<file>firstapp.c</file>
</module>
now.. is time to write the c-code... is a good idea to write some REM, something like that:
( GNU licence infos.. date... developer... )
-
/*
* ReactOS Application
* Copyright (C) 2008-2009 :P Davy Bartoloni :P
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: firstapp.c 2008-28-12 21:17:12 $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Simple EXAMPLE
* FILE: base/setup/firstapp.c
* PROGRAMMERS: Davy Bartoloni <davy@bartoloni.org>
*/
next... write this code:
-
#include <windows.h> // managing windows...
#include <tchar.h> // for TEXT function ( unicode strings )
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
//this is the first Message BOX...
MessageBox(
0,
TEXT("This is my first Reactos-Application"),
TEXT("This is a MESSAGEBOX"),
MB_OK
);
//and this is the second... the code is the same, but on a single-line.
MessageBox(0,TEXT("This is another MESSAGEBOX"),TEXT("Press OK..."), MB_OK);
return(0);
}
the full code was:
-
/*
* ReactOS Application
* Copyright (C) 2008-2009 :P Davy Bartoloni :P
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: firstapp.c 2008-28-12 21:17:12 $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Simple COMPILER-TEST
* FILE: base/setup/firstapp.c
* PROGRAMMERS: Davy Bartoloni <davy@bartoloni.org>
*/
#include <windows.h> // managing windows...
#include <tchar.h> // for TEXT function ( unicode strings )
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
//this is the first Message BOX...
MessageBox(
0,
TEXT("This is my first Reactos-Application"),
TEXT("This is a MESSAGEBOX"),
MB_OK
);
//and this is the second... the code is the same, but on a single-line.
MessageBox(0,TEXT("This is another MESSAGEBOX"),TEXT("Press OK..."), MB_OK);
return(0);
}
now... JUST go on ROSBE shell... and type: MAKE FIRSTAPP
the compiled program are created on directory: C:/ReactOS-src/output-i386/base/setup/firstapp
now, copy FIRSTAPP.EXE on ReactOS desktop.. and double-click it!
( in Q-EMU just MOUNT the c-drive image using ROSTE, and copy firstapp.exe on UNIT:/Documents and Settings/Administrator/Desktop )
( in win.. just doubleclick the program )
now, we can introduce a simple DEBUG output...
this is the code:
OutputDebugStringW(L"Example Debug-line : Started first example <firstapp.exe>/n");
place it before the first MessageBox
-
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
OutputDebugStringW(L"Example Debug-line : Started first example <firstapp.exe>/n");
//this is the first Message BOX...
MessageBox(
0,
now.. start ROS (debug version) in QEMU and the debug-output will appear in the debug window
NOW, THE SECOND EXAMPLE.. a simple WINDOW
edit the firstapp.c.. and put in it this code:
-
/*
* ReactOS Application
* Copyright (C) 2008-2009 :P Davy Bartoloni :P
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: firstapp.c 2008-28-12 21:17:12 $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Simple NOT ACTIVE WINDOW EXAMPLE
* FILE: base/setup/firstapp.c
* PROGRAMMERS: Davy Bartoloni <davy@bartoloni.org>
*/
#include <windows.h>
#include <tchar.h>
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
CreateWindowEx(
0,
WC_DIALOG,
TEXT("My First Window"), // This is the title :)
WS_OVERLAPPEDWINDOW | WS_VISIBLE, // Some attributes...
200, // orizontal starting coord
100, // vertical starting coord
400, // lenght of the window
300, // Height of the window
NULL,
NULL,
NULL,
NULL
);
//and now, for preventing end of the application... a Message Box.
MessageBox(
NULL,
TEXT("Press OK to END application."), // main Text...
TEXT("I'm a Message BOX"), // title...
0 // 0 is the standard "OK"
);
return 0;
}
now.. building it with the usual MAKE FIRSTAPP .. the result is:
example number 3... ACTIVE WINDOW WITH SOME TEXTS
this is the code...
-
/*
* ReactOS Application
* Copyright (C) 2008-2009 :P Davy Bartoloni :P
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: firstapp.c 2008-28-12 21:17:12 $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Simple ACTIVE WINDOW EXAMPLE
* FILE: base/setup/firstapp.c
* PROGRAMMERS: Davy Bartoloni <davy@bartoloni.org>
*/
#include <windows.h>
#include <tchar.h>
TCHAR *applicationtitle=TEXT("Simple REACTOS application");
TCHAR *firsttext=TEXT("This is an ACTIVE/r/nWINDOW...");
TCHAR *secondtext=TEXT("CALLBACK with WM_PAINT and DESTROY");
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_PAINT: // drawing the content of window.
{
PAINTSTRUCT ps;
HDC dc;
RECT r;
GetClientRect(hwnd,&r);
dc=BeginPaint(hwnd,&ps);
DrawText(dc,firsttext,-1,&r,DT_CENTER|DT_VCENTER); // first line of text...
DrawText(dc,secondtext,-1,&r,DT_SINGLELINE|DT_CENTER|DT_VCENTER); // second line of text...
EndPaint(hwnd,&ps);
break;
}
case WM_DESTROY: // closing the window..
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wparam, lparam);
}
return 0;
}
// the winmain...
int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
// Window class and registerclass...
WNDCLASS wc;
HWND hwnd;
MSG msg;
wc.style=CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc=WindowProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,IDI_WINLOGO);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)COLOR_WINDOWFRAME;
wc.lpszMenuName=NULL;
wc.lpszClassName=applicationtitle;
if (!RegisterClass(&wc))
return 0;
// create a window from 0,0 to 400,120
hwnd = CreateWindow(applicationtitle,applicationtitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,400,120,
NULL,NULL,hInstance,NULL);
if (!hwnd)
return 0;
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
// main loop...
while (GetMessage(&msg,NULL,0,0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
and the compiled example...
now... the first graphical app...
create the RES folder on : C:/ReactOS-src/base/setup/firstapp
create firstapp.rc on C:/ReactOS-src/base/setup/firstapp and put this code in it...
-
#include "resource.h"
IDB_IMMAGINE BITMAP DISCARDABLE "res/immagine.bmp"
edit firstapp.rbuild and add this entry: firstapp.rc
like this:
-
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="firstapp" type="win32gui" installbase="system32" installname="firstapp.exe" unicode="yes">
<bootstrap installbase="$(CDOUTPUT)" />
<include base="firstapp">.</include>
<library>kernel32</library>
<library>gdi32</library>
<library>user32</library>
<file>firstapp.c</file>
<file>firstapp.rc</file>
</module>
now.. create resource.h on C:/ReactOS-src/base/setup/firstapp
and write this line in it...
-
#define IDB_IMMAGINE 101
ok... now download this image: http://www.wcn.it/immagine.bmp and put the bitmap on C:/ReactOS-src/base/setup/firstapp/res
(full image created by Rendergraf , THX! )
now... is the c-code time...
edit firstapp.c ...
-
Code:
Select all
-
/*
* ReactOS Application
* Copyright (C) 2008-2009 :P Davy Bartoloni :P
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: firstapp.c 2008-28-12 21:17:12 $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Simple BITMAP IN A WINDOW
* FILE: base/setup/firstapp.c
* PROGRAMMERS: Davy Bartoloni <davy@bartoloni.org>
*/
#include <windows.h>
#include "resource.h"
#include <tchar.h>
TCHAR *g_szClassName = TEXT("BITMAP IN A WINDOW");
HBITMAP immagine = NULL;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
immagine = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_IMMAGINE));
if(immagine == NULL)
MessageBox(hwnd, TEXT("Error loading BITMAP."), TEXT("Warning!"), MB_OK | MB_ICONEXCLAMATION);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_PAINT:
{
BITMAP bm;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, immagine);
GetObject(immagine, sizeof(bm), &bm);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
EndPaint(hwnd, &ps);
}
break;
case WM_DESTROY:
DeleteObject(immagine);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, TEXT("Error registering class."), TEXT("Warning!"),
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
TEXT("ReactOS Logo"),
WS_OVERLAPPEDWINDOW,
100, 100, 224, 214,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, TEXT("Error creating window."), TEXT("Warning!"),
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
Compile it.. and...
Some other examples.. on italian forum...
Thanks for your patience.. and sorry for my poor english
Davy