Re: Windows Procedural Programming
- From: "Joe Butler" <ffffh.no.spam@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 25 Jul 2005 00:38:17 +0100
Yes. You can create (complex) windows programs (including DirectX
applications) using just C.
I think Phlip is exagerating the complexity of a Windows SDK program (pure
C).
A pure Windows SDK program has the following structure.
WinMain() - instead of main()
WinMain(){
WindowClassStructure myWindowType.
myWindowType.type= "myCustomWindowType" (or "button" or "scrollbar",
etc)
myWindowType.style= borderless or normal window, etc.
myWindowType.eventhandler= myWindowEventHandlerFunction.
myWindowType.curor= normal arrow, or whatever you want.
myWindowType.other stuff.
myWindow1= CreateWindow(size, "myCustomWindowType", other stuff).
myWindow2= CreateWindow(size, "myCustomWindowType", other stuff).
while(not quiting){
wait for a window event.
dispatch event to window handler.
}
// program ends up here when user clicks the 'X' or otherwise quits the
program.
}
ALL of the windows of type "myCustomWindowType" that you create will
generated calls to this function when an event occurs inside the window
myWindowEventHandlerFunction.(event, parameter){
switch(event){
case create:
create other 'child' windows if you want alogn with anything
else you want to do
when a myCustomWindowType gets created.
break;
case mousemoved:
handle mouse movement, if you want.
return;
case area inside window needs to be drawn:
draw your graphics or text or whatever.
return;
loads more things that you might want to respond to
e.g. key presses, system is being powered down, etc.
}
WindowsBuiltInEventHandler(event, parameter);
}
Now, you are going to hit a load of things that just don't work the first
way you try it, but in the end, this gives you a VERY lightweight, dependent
on no other components not found on a fresh Win95 (XP look and feel if you
ship a 'manifest' file with your app).
So, the answer is, 'yes', you can do things in C only and it is not really
such a big issue that others would have you believe. But, this method is my
personal preference.
For SDK programming you could start with Programming Windows by Charles
Petzold.
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. If you intend for your app to print, you should look at how
this works before designing your main screen drawing code - this will allow
you to use the same code for screen as well as printer (or pretty much so).
What sort of app(s) are you intending to develop - that fact alone might
mean that using MFC (a bolt on C++ class library that wraps up all/most of
the Windows OS API and also provides a basic framework for a variety of
applications for you to modify. And then, of course, there's all this
'managed' .Net C# stuff...
"Snooze" <snooze386@xxxxxxxxx> wrote in message
news:qYTEe.158226$go.54415@xxxxxxxxxxxxx
> 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?
>
> Thanks
.
- Follow-Ups:
- Re: Windows Procedural Programming
- From: Alf P. Steinbach
- Re: Windows Procedural Programming
- References:
- Windows Procedural Programming
- From: Snooze
- Windows Procedural Programming
- Prev by Date: Re: How to write code which minimizes page faults?
- Next by Date: Re: Academic grades should be USELESS
- Previous by thread: Re: Windows Procedural Programming
- Next by thread: Re: Windows Procedural Programming
- Index(es):