Re: WIN32LIB
- Posted by David Cuny <dcuny at LANSET.COM> Aug 12, 2000
- 515 views
Bernie wrote: > I think that you are going to run in to problems trying to explain > basic concepts of windows programming using win32lib. > win32lib whole idea and concept is to hide the details of windows > programming and make window programming easier. I agree. I think that, to a large extent, the best way to learn Win32Lib is to go through the examples, starting with EX01 and continuing. It attempts to introduce the concepts one at a time. EX01 creates an empty window; EX02 creates a window with a button; EX03 attaches code to the window, and so on. On the other hand, it really helps to understand what's going on (and to grasp the code in the library) if you know something about how Windows works. I think there are (roughly) three different classes of users: 1. The 'newbie' who wants to write a Windows application, and doesn't care how Windows works. They need a tutorial on how to use the library; and that library has already been written. There's also a brief explanation of most of the functions buried in the middle of Win32Lib.doc. 2. The 'power' Win32Lib user, who wants to access some of the 'advanced' features in Win32Lib (flags, etc.). This requires that they work directly with the Win32 API. This isn't a difficult thing to do, but you have to understand how the Windows event loop works, how to hook things into Win32Lib, how to read C documentation, and how to convert that into Win32Lib terms. Not impossible, but it requires a fairly good knowledge of Windows programming. 3. The Win32Lib library writer, who wants to add to the functionality of Win32Lib. There's a bit of a writeup at the end of Win32Lib.doc, but it's way out of date. Since Win32Lib development is moving away from me, I should probably spend most of my documentation efforts of #3, explaining how Win32Lib works 'under the hood', to make it easier for coders to go in and add new features, track bugs, and so on. As for #1, I think the sad truth is that you just have to go in and play with the library, and decide what parts of it you need. There's no magical wand; you just have to find out what objects and routines are there, and play with them. Some things, like double buffering, sprites, and so on, could be written up much better than they are. But it's not really that hard to get Win32Lib up and running, even for a newbie. To get to #2 or #3, you need a some Windows specific knowledge. There are a lot of good tutorials and books out there, and I think they explain things better than I could. Just be sure to stay away from those that work with C++ or MFC, and you'll be fine. Once you understand how Windows works, it's not that hard to figure out how to apply certain function flags, and so on. Win32Lib is fairly transparent; most of the routines you can just look at, consult the Win32.hlp file, and figure out what is going on. Internally, the code is well documented as to what it's doing, and why. Exending Win32Lib, once you know the basics of Windows coding, it not really that hard - just tedious! For example, take Judith's request to extend getPrinter to include paper orientation (landscape/portrait). If you take a look at the routine, you can see that it allocates a PRINTDLG structure, fills in some values, and calls the Win32 API function PrintDlg. Popping open Win32.hlp and looking up PrintDlg, you can see that none of the options include paper orientation. But the link to the DEVMODE structure shows that there is a dmOrientation field, which probably controls the paper orientation. From there, it's all grunt work. The real trick is figuring out how to incorporate the changes so that they work sensibly with Win32Lib, and not cause the application to eventually bloat and become a maze of function calls. -- David Cuny