Basic Windows tutorial

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Basic Windows tutorial

Ryan Joseph
I’d like to start doing some basic Windows programming to learn but not use the higher level Lazarus cross-platform library.

Keeping in mind I know literally nothing about Windows programming, where is a good place to start? I installed Lazarus which I think is the preferred IDE for FPC (if not are there others?) and I would like to start with making a simple window programmatically and adding some controls and a menu.

Are there are any example projects for this and a place I could reference the Windows headers in Pascal? I don’t even know what the Windows GUI library is called or where I could reference that online (.net maybe?).

Sorry for being vague but I’m starting from absolute ground zero. ;) Thanks.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Graeme Geldenhuys-6
On 2015-10-22 05:20, Ryan Joseph wrote:
> Keeping in mind I know literally nothing about Windows programming,
> where is a good place to start?

Start reading MSDN and study the Win32 API.

> I installed Lazarus which I think is the preferred IDE for FPC (if not are there others?)

Yes, MSEide is also very good. Even using a very good text editor like
EditPad Pro is very nice. Geany IDE also works well with FPC.


> Are there are any example projects for this and a place I could
> reference the Windows headers in Pascal? I don’t even know what the
> Windows GUI library is called

Wow, you are in for a world of pain. ;-) Plus even writing the most
basic programs will to magnitudes longer. You should rethink your goal.
What do you want to accomplish?

If LCL is to bloated for you, there are other GUI toolkits (100% Object
Pascal based) that produce much smaller executables. By no means does
this means less features or widgets though. Take a look at fpGUI Toolkit
and MSEide+MSEgui projects.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Sven Barth-2
In reply to this post by Ryan Joseph

Am 22.10.2015 09:25 schrieb "Ryan Joseph" <[hidden email]>:
> Keeping in mind I know literally nothing about Windows programming, where is a good place to start? I installed Lazarus which I think is the preferred IDE for FPC (if not are there others?) and I would like to start with making a simple window programmatically and adding some controls and a menu.

You should maybe google for "Delphi non VCL tutorial" or something like this to find tutorials. And on that level you can more or less use everything they show in FPC as well.

> Are there are any example projects for this and a place I could reference the Windows headers in Pascal? I don’t even know what the Windows GUI library is called or where I could reference that online (.net maybe?).

For the Windows headers you only need to add unit Windows to get most of them. There are some more units that are like in Delphi (e.g. ShellApi) and even more are provided by the Jedi units (jwa*).

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

leledumbo
Administrator
In reply to this post by Ryan Joseph
> where is a good place to start?
> Are there are any example projects for this

http://delphi.about.com/od/windowsshellapi/l/aa111503a.htm, especially chapter 2
http://www.angelfire.com/hi5/delphizeus/, seems pretty complete
http://www.winprog.org/tutorial/, my reference when I learned win32 API years back, fortunately I'm fluent in C
http://delphi.wikia.com/wiki/Win32_API, for references

> and a place I could reference the Windows headers in Pascal?

MSDN, nowhere else despite they only have documentation for languages they support (C++, C#, VB, perhaps F#).
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Paul Breneman
In reply to this post by Ryan Joseph
On 10/22/2015 12:20 AM, Ryan Joseph wrote:

> I’d like to start doing some basic Windows programming to learn but not use the higher level Lazarus cross-platform library.
>
> Keeping in mind I know literally nothing about Windows programming, where is a good place to start? I installed Lazarus which I think is the preferred IDE for FPC (if not are there others?) and I would like to start with making a simple window programmatically and adding some controls and a menu.
>
> Are there are any example projects for this and a place I could reference the Windows headers in Pascal? I don’t even know what the Windows GUI library is called or where I could reference that online (.net maybe?).
>
> Sorry for being vague but I’m starting from absolute ground zero. ;) Thanks.
>
> Regards,
> Ryan Joseph

Welcome Ryan to Free Pascal!

I have this tutorial started that I'd like to improve (feedback welcome):
   http://www.controlpascal.com/tutorial.htm

Regards,
Paul
www.ControlPascal.com

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Ryan Joseph
In reply to this post by Graeme Geldenhuys-6

> On Oct 22, 2015, at 6:07 PM, Graeme Geldenhuys <[hidden email]> wrote:
>
> On 2015-10-22 05:20, Ryan Joseph wrote:
>> Keeping in mind I know literally nothing about Windows programming,
>> where is a good place to start?
>
> Start reading MSDN and study the Win32 API.

Looks pretty straight forward and simple compared to Cocoa on the Mac.

>
>> I installed Lazarus which I think is the preferred IDE for FPC (if not are there others?)
>
> Yes, MSEide is also very good. Even using a very good text editor like
> EditPad Pro is very nice. Geany IDE also works well with FPC.

Granny IDE looks nice (I’m not a fan of Lazarus’s layout) but how does it work with FPC? Do they have a plugin or something that supports the compiler or does it require some hacking?

>
>
>> Are there are any example projects for this and a place I could
>> reference the Windows headers in Pascal? I don’t even know what the
>> Windows GUI library is called
>
> Wow, you are in for a world of pain. ;-) Plus even writing the most
> basic programs will to magnitudes longer. You should rethink your goal.
> What do you want to accomplish?

In the end I’m going to port a game so I just want the most basic event handling and windows (OpenGL also) but I’d just like to learn for the experience and to understand the platform a little better. Looking at the Win32 API it actually looks easy, like in the old days on the Mac before it got complicated. If it’s a nightmare in the end I’ll rethink things.

Is there a reference to the API for FPC or do I need to open up source files?


Thanks for helping.


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Ryan Joseph
In reply to this post by leledumbo
Thanks, there’s a lot for me to go through here. Should keep me busy. :)

> On Oct 22, 2015, at 7:45 PM, leledumbo <[hidden email]> wrote:
>
>> where is a good place to start?
>> Are there are any example projects for this
>
> http://delphi.about.com/od/windowsshellapi/l/aa111503a.htm, especially
> chapter 2
> http://www.angelfire.com/hi5/delphizeus/, seems pretty complete
> http://www.winprog.org/tutorial/, my reference when I learned win32 API
> years back, fortunately I'm fluent in C
> http://delphi.wikia.com/wiki/Win32_API, for references
>
>> and a place I could reference the Windows headers in Pascal?
>
> MSDN, nowhere else despite they only have documentation for languages they
> support (C++, C#, VB, perhaps F#).

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Ryan Joseph
In reply to this post by Paul Breneman
Thanks Paul. I’ve been using FPC since 2005 now but on the Mac (and UNIX command line) so everything on Windows is new to me.

> On Oct 22, 2015, at 8:02 PM, Paul Breneman <[hidden email]> wrote:
>
> I have this tutorial started that I'd like to improve (feedback welcome):
>  http://www.controlpascal.com/tutorial.htm

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Graeme Geldenhuys-6
In reply to this post by Ryan Joseph
On 2015-10-22 14:49, Ryan Joseph wrote:
> Looks pretty straight forward and simple compared to Cocoa on the
> Mac.

Win32 API is not hard, it is just a lot more effort to write a program
using only the Windows API. eg: fpGUI Toolkit  also uses the Win32 API
to create windows, set border styles, window styles etc. But the API has
lots of options, thus lots of reading on MSDN. fpGUI hides that
complexity from the developer so they can get going much quicker, and
rather concentrate on implementing there application, that fiddling with
the intricacies of the Win32 or XLib API.

But I understand your goal.

> does it work with FPC? Do they have a plugin or something that
> supports the compiler or does it require some hacking?

No "hacking" is required. Geany IDE allows you to specify compiler
commands. You point it to the fpc.exe file, and tell it what compiler
parameters to use.

Fred van Stappen uses Geany with FPC. You can find his contact details
here [https://github.com/fredvs].

Alternatively, google something like "Geany IDE with FPC" and you will
find many links and youtube tutorials.


> Is there a reference to the API for FPC or do I need to open up
> source files?

The Windows and Messages units included with FPC, is what you need to
include in your application. Then reference the MSDN Win32 API
documentation to understand how to use the API calls.

AggPas also includes a very scaled down API requirements to get a Main
form displayed, set a Window Title, draw some text and implement a Event
Queue. Sake a look at AggPas in the
'platform/win/agg_platform_support.pas' unit. You can ignore the AggPas
code, and only pay attention to the Win32 API calls and event queue.
Look at the window_proc() function, DefWindowProc(), CreateWindow(),
MoveWindow(), ShowWindow() etc.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Sven Barth-2
In reply to this post by Ryan Joseph
On 22.10.2015 15:49, Ryan Joseph wrote:
>>
>>> I installed Lazarus which I think is the preferred IDE for FPC (if not are there others?)
>>
>> Yes, MSEide is also very good. Even using a very good text editor like
>> EditPad Pro is very nice. Geany IDE also works well with FPC.
>
> Granny IDE looks nice (I’m not a fan of Lazarus’s layout) but how does it work with FPC? Do they have a plugin or something that supports the compiler or does it require some hacking?

Out of curiosity: in how far aren't you a fan of Lazarus' layout? Many
parts can be configured. Especially the code tools that Lazarus provides
makes navigating/writing code rather easy.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Ryan Joseph

> On Oct 23, 2015, at 2:03 AM, Sven Barth <[hidden email]> wrote:
>
> Out of curiosity: in how far aren't you a fan of Lazarus' layout? Many parts can be configured. Especially the code tools that Lazarus provides makes navigating/writing code rather easy.


I don’t use the RAD tools so those are in the way but the biggest problem is how everything is broken up into separate windows. Could that be changed?

Thanks.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

leledumbo
Administrator
> I don’t use the RAD tools so those are in the way but the biggest problem is how everything is broken up into separate windows. Could that be changed?

According to my installed Lazarus: yes
lazarus-docked.png
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Ralf Quint
In reply to this post by Ryan Joseph
Ryan Joseph wrote:
>> On Oct 23, 2015, at 2:03 AM, Sven Barth <[hidden email]> wrote:
>>
>> Out of curiosity: in how far aren't you a fan of Lazarus' layout? Many parts can be configured. Especially the code tools that Lazarus provides makes navigating/writing code rather easy.
>
> I don’t use the RAD tools so those are in the way but the biggest problem is how everything is broken up into separate windows. Could that be changed?
>
Try using more than one monitor while developing GUI applications and
you will never ask that question again... ;-)

Ralf

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Sven Barth-2
In reply to this post by Ryan Joseph

Am 23.10.2015 03:36 schrieb "Ryan Joseph" <[hidden email]>:
>
>
> > On Oct 23, 2015, at 2:03 AM, Sven Barth <[hidden email]> wrote:
> >
> > Out of curiosity: in how far aren't you a fan of Lazarus' layout? Many parts can be configured. Especially the code tools that Lazarus provides makes navigating/writing code rather easy.
>
>
> I don’t use the RAD tools so those are in the way but the biggest problem is how everything is broken up into separate windows. Could that be changed?

You don't need to use Lazarus as RAD. After all you can use it for example for console applications as well (like the compiler) which definitely aren't RAD. For your purposes you'd just need to start with the correct project template and the IDE would still assist you with its powerful codetools.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Ryan Joseph
Ok, I did some reading and found out there is an anchoring plugin you can install that makes it one window, which is great.

Some questions:

I started a project using the “simple application” template which made a console window I don’t really want. Is there a way to remove that window? I don’t see any code which is creating it.

Can I route STDOUT (does that exist on Windows?) from writeln to the message window in Lazarus? That’s pretty typical for development and I can’t see where it’s going right now.

Do I need to do anything in Lazarus to package application resources (like images, data files) or do I just include them in the same directory as the executable? That’s just a general Windows question I guess but Lazarus seems to have a guy for this.

Thanks.

> On Oct 23, 2015, at 1:04 PM, Sven Barth <[hidden email]> wrote:
>
> You don't need to use Lazarus as RAD. After all you can use it for example for console applications as well (like the compiler) which definitely aren't RAD. For your purposes you'd just need to start with the correct project template and the IDE would still assist you with its powerful codetools.
>
>

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Mattias Gaertner
On Sat, 24 Oct 2015 09:36:25 +0700
Ryan Joseph <[hidden email]> wrote:

>[...]
> I started a project using the “simple application” template which made a console window I don’t really want. Is there a way to remove that window? I don’t see any code which is creating it.
>
> Can I route STDOUT (does that exist on Windows?) from writeln to the message window in Lazarus? That’s pretty typical for development and I can’t see where it’s going right now.

The console window is the STDOUT on Windows. Without it you can't use
writeln.
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Console_output_for_GUI_application

There are various logging systems. For example:
http://wiki.lazarus.freepascal.org/LazLogger

 
> Do I need to do anything in Lazarus to package application resources (like images, data files) or do I just include them in the same directory as the executable? That’s just a general Windows question I guess but Lazarus seems to have a guy for this.

FPC has a cross platform solution for resources:
http://wiki.lazarus.freepascal.org/Lazarus_Resources#FPC_resources

And Lazarus has a GUI for that:
Project / Project Options / Resources

Matias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Graeme Geldenhuys-6
In reply to this post by Ryan Joseph
On 2015-10-24 03:36, Ryan Joseph wrote:
> Can I route STDOUT (does that exist on Windows?) from writeln to the
> message window in Lazarus? That’s pretty typical for development and
> I can’t see where it’s going right now.


I recommend one of the logging systems available. I use the tiLog unit
(and the various tiLogToGUI, tiLogToConsole and tiLogToFile units) from
the tiOPF [http://www.tiopf.com] project. Even though your project is
not tiOPF based, the logging functionality can be used with any project
and works very very well. The logging is thread based and some outputs
have built in cache buffers, so no matter how much logging you throw at
it, it doesn't slow down your application.

Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Basic Windows tutorial

Marco van de Voort
In reply to this post by Ryan Joseph
In our previous episode, Ryan Joseph said:
> I?d like to start doing some basic Windows programming to learn but not
> use the higher level Lazarus cross-platform library.
>
> Keeping in mind I know literally nothing about Windows programming, where
> is a good place to start?  I installed Lazarus which I think is the
> preferred IDE for FPC (if not are there others?) and I would like to start
> with making a simple window programmatically and adding some controls and
> a menu.

That's fine. Lazarus can be used to generate non LCL programs just fine.

Some parts of the "Tomes of Delphi" series are the only decent reference in
Pascal that I know.

However if you can read C, the classic "Programming windows" by Charles
Petzold is best. (though not all editions contain the same amount of core
winapi skills. Later editions seem to compress those chapters to make room
for chapters on newer Windows technologies)

> Are there are any example projects for this and a place I could reference
> the Windows headers in Pascal?  I don?t even know what the Windows GUI
> library is called or where I could reference that online (.net maybe?).

Both books come with examples, though Petzold's are of course in C.

After you wrestled through a course like Petzold, you can usually do with
MSDN and a bit of internet search. But starting in a new big topic directly
with MSDN always makes me feel like I'm chasing my own tail. One big
spaghetti mess that links to eachother.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal