Re: [Dev-C++] Offtopic: Advice on GUI to learn
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Michael C U. <mu...@cb...> - 2004-01-16 09:10:22
|
On Fri, 16 Jan 2004, Daniel Glenfield wrote: > You can create a window in 5 lines, but won't that be very high level? With > the windows API you have other things to set up. Or is there a more detailed > version that takes 30 lines of code? With the Windows API, you have to set up a lot of things manually that the toolkit's class will set up for you automatically. Example, if you want to load an image in a window and be able to scroll that image, the toolkit has a class that will automatically set up the scrollbars for you. With the Windows API, the scrollbars have to be manually programmed to determine how far their range should be, how far it should move with each click, how far it should move the image with each click, where the image ends so that it doesn't scroll past the end, etc. You also have to manually program the scrollbar movement and set its position. And that won't even give you the ability to use the arrow keys, the page up/page down keys, or the scroll wheel. If you want those, it's more manual programming. The result is that it can literally take 80 or 90 lines of code just to get a decent scrollbar using the Windows API. Using a high level toolkit, you can probably do it in less than 10. In Java Swing, I just did it with 3 lines of code. Literally, it took me 3 lines of code to do what takes about 90 lines of code to do using the Windows API. So yes, you are working at a much higher level with a toolkit. But generally, that is a good thing. It lets you concentrate on what you want to do (display a scrollable image), rather than how to do what you want to do (implement a bunch of math formulas and such to determine how far the image should scroll with each mouse click on a scroll arrow, how far the scrollbar should move in response, etc.) Mike |