Forum > LCL

Maximize WinApi usage

(1/2) > >>

flasher86:
Hi. I am new at Lazarus programming, but I need to learn how to program in it FAST.

I am old Delphi programmer, but now I must take LEGAL way of creating programs.

So, what I noticed so far, is that programs created in Lazarus very rarely use WinApi natively, which concerns me.

For example, when I use MessageBox, it looks and behaves differently from Delphi version (different button look and no error sound in MB_ICONERROR option).

I assume, that it's taken care by it's own library which acts like native MessageBox winapi function but it's different.

Also I assume, that if my application is supposed to work only in WIN32 then, it will be the best to use as much WinApi functions as possible (performance). Am I right?

So is there any way to maximize usage of Winapi NATIVELY? I can link my MessageBox to winapi manually but I don't want to do this with every little thing.

Please help.

EDIT: oh and btw, why I get sometimes error when I quit from my application?
I get external SIGSEGV error, but it's visible only in debugging mode. If I run the exe manually nothing appears. But It's disturbing.

Marc:

--- Quote from: flasher86 on August 29, 2010, 05:32:43 pm ---Hi. I am new at Lazarus programming, but I need to learn how to program in it FAST.

I am old Delphi programmer, but now I must take LEGAL way of creating programs.

So, what I noticed so far, is that programs created in Lazarus very rarely use WinApi natively, which concerns me.

--- End quote ---

why worries ? Being crossplatform, the LCL doesn't use the winapi directly. The win32 widgetset however does.
If you need the portable version of winapi, the use lclintf. This is a crossplatform  replacement for the most used winapi calls.


--- Quote ---For example, when I use MessageBox, it looks and behaves differently from Delphi version (different button look and no error sound in MB_ICONERROR option).

I assume, that it's taken care by it's own library which acts like native MessageBox winapi function but it's different.

--- End quote ---

Under the hood on win32 the same function is used. However keep in mind that all functions are tested till XP. Not all new features are yet passed through.


--- Quote ---Also I assume, that if my application is supposed to work only in WIN32 then, it will be the best to use as much WinApi functions as possible (performance). Am I right?

--- End quote ---

Depends on your app. Most times the winapi is not the bottleneck. If there is a minimal chance that you will run your app on linux, osx or wince (or port your app to 64bit), I would stay far away from using winapi



--- Quote ---So is there any way to maximize usage of Winapi NATIVELY? I can link my MessageBox to winapi manually but I don't want to do this with every little thing.

--- End quote ---

Don't use Messagebox, but use the dialog unit. IIRC MessageDlg is the one you're looking for.


--- Quote ---Please help.

EDIT: oh and btw, why I get sometimes error when I quit from my application?
I get external SIGSEGV error, but it's visible only in debugging mode. If I run the exe manually nothing appears. But It's disturbing.

--- End quote ---

I don't know your app, but maybe you're doing somthing wrong when you close your app.


flasher86:
Thanks for reply

I've just started this program, and I have only IdHTTP and 2 buttons on the form. And a couple of functions regarding XML decoding.

No events corresponding to the form (onclose, onqueryclose... nothing).

But still, I got the raise exception.

My application will be running in a medium-size company. All of the computers have Windows distributions.
All of the computers have WinXP or Win98 - yeah its ancient history but their software for accessing bills and company stuff is a dos based program. (that's quite bizarre that most of such company programs are dos-based - at least in Poland where I live)

In the company I am the only one who is advanced in managing computers therefore I really can't ask them to use Linux or any other operating system. They know how to handle Windows at the beginner and necessary level only.

If only I had Delphi7 license I would with no hesitation stick to it, but I don't have and can't afford such an amount of money.

My program will be managing database of the products, and in hidden mode logging into other's companies database to play the best price in comparison with their prices. At the end I am planning to make the bill system so they will be able to migrate from old damn Windows 98.

BTW. I assume that logging into other's companies database by my own software and using it (simulating http browser) is illegal, so in case of inspection they won't find anything weird in my binaries?

AND THE MOST IMPORTANT QUESTION:
Will sticking to the WINAPI increase the performance of the whole software? I need to know that, as I tend to create insufficiently slow programs - at least this would boost it.

marcov:

--- Quote from: flasher86 on August 29, 2010, 08:39:13 pm ---
AND THE MOST IMPORTANT QUESTION:
Will sticking to the WINAPI increase the performance of the whole software? I need to know that, as I tend to create insufficiently slow programs - at least this would boost it.

--- End quote ---

Then don't worry, the answer is no. On Windows the LCL layer is fairly thin, and nearly free. This is because the LCL mimics the VCL which was designed to run on top of winapi.  The overhead is so low it is probably not even measurable (because the average windows message used in the GUI is already slower)

krexon:

--- Quote from: flasher86 on August 29, 2010, 05:32:43 pm ---I get external SIGSEGV error, but it's visible only in debugging mode. If I run the exe manually nothing appears. But It's disturbing.

--- End quote ---

I have the same problem :) I have not found explanation for this.

Navigation

[0] Message Index

[#] Next page

Go to full version