Subj : Re: Windows Procedural Programming To : comp.programming From : Joe Butler Date : Mon Jul 25 2005 03:36 am "Alf P. Steinbach" wrote in message news:42e43108.415468250@news.individual.net... > * Joe Butler: > > [top-posting, corrected] > > Please don't top-post. > > > * Joe Butler: > > > > * Snooze: > > > I want to begin developing Windows applications, but I don't have any > > > experience with OOP or Windows programming; only procedural programming. > > > Is it possible to develop Windows applications using only a procedural > > > programming language such as C or Pascal rather than an OOP language? > > > > Yes. You can create (complex) windows programs (including DirectX > > applications) using just C. > > Right, although not advisable. A matter of personal taste if you don't have any other restrictions. There isn't ANYTHING that requires C++ in Windows that I know of. Perhaps you can correct me on this issue. Assuming there is not, it then is a matter of how to best implement your various layers of code (i.e. not including the GUI/Windows API, etc. what does one prefer to use to solve the problem at hand. If the answer is C, then that's fine - also writing the Windows code in pure C might add a bit of time to the development, but I think I'd rather spend take this time, personally. It's all amortised over the life of a couple of projects, since you can reuse modules such as window creation with a single function call, custom dialogs, etc. - each App one writes results in more and more library helpers that are taylored to the types of things you do. > > > > I think Phlip is exagerating the complexity of a Windows SDK program (pure > > C). > > No, not really. "But Win32 SDK is primitive and generic, so you must call _zillions_ of functions to build this OO system." [Phlip] By 'primitive', I'd read: 'fundamental', for 'generic', I'd read, 'fundamental'. For _zillions_, well, I've just counted how many calls need to be made to get a window up - 7 API calls. Then it's a matter of how complex your Window behaviour is. If it's just gonna put some text on the screen, well, that's a 3 API calls - and 2 of those are just the markers for the beginning and end of the graphics drawing handler. This is nothing like the zillions mentioned. > However, I think he's exaggerating the benefits from using > an OO language. Those benefits are there 100% if you write a program that > is not Windows-specific, but in that case you're not writing a Windows > application; the Windows-specific stuff requires dealing with things that > object oriented abstraction doesn't make simple, although it helps much. > > > > A pure Windows SDK program has the following structure. > > > > WinMain() - instead of main() > > Sorry, that's incorrect. > > First because it's a languagecentric view (C or C++), second because > 'WinMain' is Microsoft-specific language extension, third because even with > Microsoft tools 'WinMain' has a special meaning (setting tool default > options) that's not "Windows SDK program" but "GUI subsystem program", > fourth because there are several such special functions, e.g. 'wWinMain', > and fifth but absolutely not least because _there is no need_ to use > 'WinMain' or the like: you can & should just use standard C/C++ 'main'. > Sorry, but that's not going to mean much to a Windows beginner, is it? OK, I'm being Developer Studio-centric, I know that main is called somewhere else, but as far as I'm concerned, for GUI stuff, my initial entry point is WinMain (I'd like to know where the advice says that one SHOULD use main for a GUI program). > > [snip] > > For SDK programming you could start with Programming Windows by Charles > > Petzold. > > Good advice. > > > > One of the things that can be difficult to get right is handling printing > > support (there is no built in Print Preview functionality). Also, loading > > things like bitmaps you have to supply the code yourself - althought I think > > with a new thing called GDI+ that can load bitmaps and jpegs with a single > > function call > > Sorry, that's incorrect. You could always use e.g. OleLoadPicturePath. > However, in one practical sense it's correct unless all you want to do is > display a photograph, for the units used for width and height are not pixel > based and are display-dependent, so that accuracy is thrown out the Windows. So, it is correct, afterall? I didn't know about OleLoadPicturePath (I see now that it's part of IE3 - So, I wonder how much baggage comes along with that). I shall look into it though. A. Signatures that are non-sequiturs. Q. What's the most annoying thing on usenet? > > -- > A: Because it messes up the order in which people normally read text. > Q: Why is it such a bad thing? > A: Top-posting. > Q: What is the most annoying thing on usenet and in e-mail? .