PDA

View Full Version : school project problems



SuperBoy
17-05-2006, 06:12 PM
i have to make a program that shows graphs. i made one already, but is a console application.

i will like to mention that i only know Pascal, Delphi is a big blank space for me so pls don't treat me with Lazarus.

Pls point me to a IDE that will be okay for use in windows style applications and perhaps some tutorials for opengl. until at this point i haven't succeded in generating a window using opengl due to compiler issues.


somebody pls help me

jdarling
17-05-2006, 06:16 PM
Well, if Delphi would be a leap, then your only choice for a GUI IDE for windows is Lazarus.

As far as a graph, what type, kind, size, etc... You have given us little to go off of.

What are the other stipulations presented by the assignment?

SuperBoy
17-05-2006, 06:18 PM
the assignment specifies that i use Pascal. other than that i can do it any way i want....


i need some way to input data (haven't figured this part yet)
and some way to draw on the screen


edit: i am preety good at console programming and i figured out the part about the graphs... i am having problems at the windows programming part

XProger
17-05-2006, 06:54 PM
proga.dpr



program proga;

uses
SysUtils, Dialogs;

var
x : Integer;
y : Single;
begin
DecimalSeparator := '.';
x := StrToIntDef( InputBox('Bugaga!', 'X :', ''), 0);
y := StrToFloatDef( InputBox('Muhaha!', 'Y :', ''), 0);
ShowMessage('Summ = ' + FloatToStr(x + y));
end.

SuperBoy
17-05-2006, 07:00 PM
i can't seem to find the dialogs unit :?

jdarling
17-05-2006, 08:31 PM
I'll try this again, you will either have to use FPC (and figure it out), Lazarus (witch lets you design your windows gui in a semi-wysiwyg), or Delphi (slightly more stable then Lazarus).

If your using an older copy of Pascal from Turbo or Borland then you won't be able to do Win32 applications that include visual forms.

Using FPC, Lazarus, or Delphi do a google. Their are litterly 1000's of tutorials on how to build "Hello World!" and more in them.

The code that was posted was for Delphi, and won't work in older version of Turbo/Borland Pascal, nor will it work in FPC. It should work in Lazarus (without too much tweaking).

SuperBoy
17-05-2006, 08:45 PM
i am currently using Dev-Pascal in combination with FPC :?

hmm... i can now draw lines and output text... i'm diggin on the MSDN to find useful link.. though they are written for C++ i am converting them to Pascal :twisted:

Huehnerschaender
17-05-2006, 08:48 PM
Hi Superboy,

you said you know Pascal, so it should be absolutely no problem to do your school project in Delphi. There are free versions of Delphi available (personal editions) which you could use. Take an hour or two to become a little familiar with the IDE.

After that you can easily build your program using Pascal! Nobody forces you to use object oriented programming or something.
Delphi is a good decision if you are already familiar with Pascal...

And your school work is really no problem with the features Delphi provides.

And in addition to that, if you have one of the above mentioned IDEs, we can help you here ^^

Ok, I only know Delphi, but there are many people here knowing the other IDEs, too.

Greetings,
Dirk

WILL
17-05-2006, 10:47 PM
It's important to know the distinction between the language that Delphi uses and Delphi it's self. Lest you get confused. (Well Borland, the company that made Delphi did a good job of that already.)

Borland created Delphi to be Pascal for Windows, using a newly created 'Object Pascal' language. 'Object Pascal' was the name of the version of the Pascal language that Apple Computer made for their software development teams on the Macintosh hardware/OS. Borland then decided to instead call the IDE Delphi and at a later date call the language(at about Delphi 4 and up) Delphi aswell, disguising the new version of the Pascal language with a new name. I guess they thought they would trick or fool people into wanting to learn Pascal again against the wishes of all those C fanatics out there. :roll:

So when some people refer to 'Delphi' they sometimes mean the IDE product and sometimes the Object Pascal language that Delphi uses.

Object Pascal is a new version of the Pascal language. Object Pascal when you look at it, is just Pascal, but redesigned to be a Object Oriented Programming language. There are only a select few compilers that support it. FPC, GNU Pascal(though I don't consider it to be a Pascal compiler at all) and Delphi. Lazarus is FPC with a IDE built on top of it. This is the same with Dev-Pascal (an IDE built on top of FPC), only Dev-Pascal is a discontinued product. (Created with Delphi btw.) Object Pascal is still compatable with most of the original Pascal code. Except for a few of the functions that were changed for the better anyways. ;)

If you want to make Windows Applications, it is best to use either Delphi or Lazarus.

If you want to make a console program then you can still use Delphi or Lazarus, but also Dev-Pascal, GNU Pascal, raw FPC distribution or some other 3rd party non-language support specific IDE may also be of use with FPC or GNU Pascal.


How to write console programs using:

Delphi (MyProgramName.dpr)program MyProgramName;

{$APPTYPE CONSOLE}

uses
{...};
const
{...};
type
{...};
var
{...};
begin
end.

Lazarus (MyProgramName.lpr)program MyProgramName;

{$APPTYPE GUI}

uses
{...};
const
{...};
type
{...};
var
{...};
begin
end.

If you are working with console programs then all you have to do is work with the Code Editor and disreguard all the rest of the VCL/LCL stuff. he features of bot of the IDEs make it worth it though! :)


As per your assignment. I don't know enough from what you've described to be able to direct you to anything specific so I'll assume that you want to learn how to draw and display graphics on screen. In this case, look into either DirectX, SDL or OpenGL. There are a ton of libraries that support these 3 main ways to display graphics in both a windowed app and a console program.

If you are using Lazarus or Delphi you can have the other option to then use the GDI for the visual component system(Lazarus' LCL or Delphi's VCL) drawing directly to it. This is however much slower and not recommended for real-time application or required highspeed or 3D graphics.


Hope I've helped. Welcome to PGD! :)

SuperBoy
18-05-2006, 02:11 PM
i am using WinApi at the moment and i am preety happy with the results. And i still use Dev-Pascal and FPC.


but i have difficulties at the use of DialogBox. Can someone explain how do i create one windows of this type to input a string pls? i can fill in the rest.



ps: i promise to upload it somewhere so we can see what i did when i will finish 8)


pps: thank you for the warm welcome :wink:



edit:
i call: DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(1) , hwnd, DialogProc);

i get: 86 / 98 atestat.pas
Error: Wrong amount of parameters specified

savage
18-05-2006, 04:38 PM
There should be at least 2 versions of DrawDialog one for Ansi strings and one for WideStrings. Have a look at which one FPC's DrawDialog is pointing to. It should be either DialogBoxA() or DialogBoxW().

SuperBoy
18-05-2006, 05:47 PM
i tried them both and neither of them seem to work. it displays the same error



edit: i use the compiler set to default.. when i change the compiler to the latest version of FPC i get an error at msg:MSG :?

SuperBoy
21-05-2006, 12:16 PM
i need help pls....


DialogBox doesn't works... so.. i need help at creating a new window inside my application sa i can input something.... pls help me

fragle
21-05-2006, 08:12 PM
SuperBoy, the posted error's strange indeed.. Not DialogBox's fault though :)
Umm.. anyway. I've just hacked a simple app, which creates a modal dialog as its main window. It might give you some ideas about what you could be doing wrong, or you can use it as a starting point ;). Here it is:
example.pas:
program example;

{$APPTYPE GUI}
{$R '*.res'}

uses
Windows,
Messages;

const
MainDlg = 1000;
IDC_TEXT = 1001;
IDC_BUTTON = 1002;

var
//----- Window vars -----
hInst,
hWindow: HWND;

Buffer: array[0..100] of char;

function DlgWindowProc(hWnd,Msg: LongWord; wParam,lParam:Longint):LongInt; stdcall;
begin
case Msg of
WM_CLOSE:
begin
PostQuitMessage (0);
end;
WM_COMMAND:
begin
case LoWord(wParam) of
IDC_BUTTON:
begin
Buffer[0] := #0;
GetDlgItemText(hWnd, IDC_TEXT, Buffer, 100);
MessageBox(hWindow, Buffer, 'Wazzat', MB_OK or MB_ICONINFORMATION);
end;
end;
end;
else
Result := 0;//false
Exit;
end;
Result := 1;//true
end;

//----- WinMain --------
begin

hInst := GetModuleHandle(nil);

hWindow := DialogBox (hInst, MAKEINTRESOURCE (MainDlg), 0, @DlgWindowProc);

end.
example.rc:

#define MAINDLG 1000
#define IDC_TEXT 1001
#define IDC_BUTTON 1002

MAINDLG DIALOG 11, 32, 206, 62
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
CAPTION "example"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_TEXT, 15,17,111,13, ES_AUTOHSCROLL | ES_LEFT
DEFPUSHBUTTON "Do Work", IDC_BUTTON, 141,17,52,13
END


Hope this helps ;)
Fragle

P.S.: is it me, or do resources not get built automatically by fpc (its default ide - Rhino(?) to be more precise) when compiling an application? Did i forget some option or something? Now it just fails with linker error unless i build the resources myself... Downloaded FPC just an hour ago, so i might be missing something obvious :oops:. Thanks in advance for any hints on that!

SuperBoy
21-05-2006, 10:03 PM
you have to build them manually. i use GORC

you can get it here: http://www.GoDevTool.com.


i have trouble compiling your code though... it sais: can't find unit MESSAGES :?


edit: that is the error from Dev-Pascal.. in FPC it works
edit2: i deleted the call for MESSAGES and works in Dev-Pascal also now

SuperBoy
22-05-2006, 01:12 AM
how can i erase every thing i already drawed?

edit: i found out :?


next: how can i input a matrix for a graph


edit: i figured it out... now i want to know how to use the LISTBOX control pls

WILL
22-05-2006, 03:10 AM
Superboy, I'm gonna recommend a book for you.

I got this years ago and it was an excellent reference when I was first making Windows Applications under Delphi.

'Delphi 3 SuperBible' by Paul Thurrott, Gary Brent, Richard Bagdazian & Steve Tendon -- Waite Group Press (ISBN 1-57169-027-1)

Now, I'm VERY sure that there is a newer version of this book. Possibly a 'Delphi SuperBible', but in any case this this is packed with the entire VCL as of Delphi 3, including every property, mehtod and onevent handler for every object.

It sold for $54.99 USD back in 1997... you might be able to get a used copy for less now.

Another one that might help is 'Mastering Delphi 7' or a whole bunch of others... Besicailly you want a reference to the VCL object model.

SuperBoy
22-05-2006, 06:47 PM
can someone help me pls with a basic application that has a dialog box with a listbox in it pls

fragle
23-05-2006, 03:17 PM
WILL, but.. but... but he's working with win32 api... in freepascal :shock: Umm.. shutting up. You weren't writting to me afterall :)

Superboy, a listbox is nothing more than another control, so you just create a resource, pump out the messages and windows does the rest. Here's another example (just posting the differences from an earlier one):

example.pas
program example;
...
const
...
IDC_LISTBOX = 1003;
...

case Msg of
WM_CLOSE:
begin
EndDialog(hWnd, 0); //Messed up last time. That's the supposed way of closing dialogs
end;
WM_COMMAND:
begin
case LoWord(wParam) of
IDC_BUTTON:
begin
Buffer[0] := #0;
GetDlgItemText(hWnd, IDC_TEXT, Buffer, 100);
SetDlgItemText(hWnd, IDC_TEXT, nil);
SendMessage(GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING, 0, LongInt(@Buffer));
end;
end;
end;
...
example.rc

#define IDC_LISTBOX 1003
...
LISTBOX IDC_LISTBOX, 15, 35, 111, 100, WS_VSCROLL
...
Tadaa!

Btw, SuperBoy, you might wanna check out one site (there (http://www.angelfire.com/hi5/delphizeus/index.html)). It covers the basics of working with win32 api in delphi, so you might find some questions answered in it already ;)

Bye,
fragle

SuperBoy
25-05-2006, 02:33 AM
how can i change the color of the pen?

i tried setdcpencolor but it is not recognized :?