Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-10

Basic Windows tutorial

18 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Graeme Geldenhuys
to Ryan Joseph
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
Sven Barth
to Ryan Joseph: I’d like to start doing some basic Windows programming to learn but not use the higher…
"Ryan Joseph" wrote
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

leledumbo
to Ryan Joseph: I’d like to start doing some basic Windows programming to learn but not use the higher…
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#).

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Basic-Windows-tutorial-tp5722943p5722950.html Sent from the Free Pascal - General mailing list .
Paul Breneman
to Ryan Joseph: I’d like to start doing some basic Windows programming to learn but not use the higher…
Ryan Joseph wrote 10 lines
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

Ryan Joseph
to Graeme Geldenhuys: Start reading MSDN and study the Win32 API. Yes, MSEide is also very good. Even using a…
Show quoted text 7 lines
On Oct 22, 2015, at 6:07 PM, Graeme Geldenhuys 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.

Show quoted text 5 lines
> 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?

Show quoted text 9 lines
> 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

Ryan Joseph
to leledumbo: http://delphi.about.com/od/windowsshellapi/l/aa111503a.htm, especially chapter 2…

Thanks, there’s a lot for me to go through here. Should keep me busy. :)

Show quoted text 16 lines
On Oct 22, 2015, at 7:45 PM, leledumbo 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

Graeme Geldenhuys
to Ryan Joseph: Looks pretty straight forward and simple compared to Cocoa on the Mac. Granny IDE looks…
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
Sven Barth
to Ryan Joseph: Looks pretty straight forward and simple compared to Cocoa on the Mac. Granny IDE looks…
Ryan Joseph wrote 7 lines
> >> 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

Ryan Joseph
to Sven Barth
On Oct 23, 2015, at 2:03 AM, Sven Barth 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

leledumbo
to Ryan Joseph
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
<http://free-pascal-general.1045716.n5.nabble.com/file/n5722959/lazarus-docked.png>

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Basic-Windows-tutorial-tp5722943p5722959.html Sent from the Free Pascal - General mailing list .
Ralf Quint
to Ryan Joseph: I don’t use the RAD tools so those are in the way but the biggest problem is how…
Ryan Joseph wrote 6 lines
> On Oct 23, 2015, at 2:03 AM, Sven Barth 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

Sven Barth
to Ryan Joseph: I don’t use the RAD tools so those are in the way but the biggest problem is how…
"Ryan Joseph" wrote
> On Oct 23, 2015, at 2:03 AM, Sven Barth
> > 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

Ryan Joseph
to Sven Barth

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.

Show quoted text 5 lines
On Oct 23, 2015, at 1:04 PM, Sven Barth 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

Mattias Gaertner
to Ryan Joseph
[...] 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

Graeme Geldenhuys
to Ryan Joseph: Ok, I did some reading and found out there is an anchoring plugin you can install that…
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
Marco van de Voort
to Ryan Joseph: I’d like to start doing some basic Windows programming to learn but not use the higher…

In our previous episode, Ryan Joseph said:

Show quoted text 8 lines
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.