Re: Windows Procedural Programming



Joe Butler wrote:

> One minute [Alf is] saying that a Windows program does not have a WinMain
> instead of a main, and the next you are saying that main is a requirement
of
> the standard and that it must be used?
>
> You seem to be confused.
>
> For GUI apps, I've always used WinMain.
> for CUI app, I've always used main.

It's a gross simplification to say WinMain is for GUIs and main is for CUIs.
(I'm aware you are not saying that. Alf is saying the simplification is
gross.)

> Simple as that.

Not really. In Release mode, I prefer my Win32 GUI programs to divorce from
the command line, so I link them with /subsystem:WINDOWS. This, in turn,
makes the linker look for one of the precursors for WinMain. Then when I
compile in Debug mode, I prefer 'cout' for trace statements, so I link with
/subsystem:CONSOLE. The linker then looks for the wrong kind of main, and I
must supply another one.

This is incredibly simpler than the systems that link with
/subsystem:WINDOWS, then when they need a console for trace statements they
bend over backwards to reconstruct one from scratch, and then either ignore
<iostreams> or construct an alternate 'cout' from scratch.

And sometimes I write a normal main(), and then generate windows within it,
in between console operations. They work. And because I use a good library,
not MFC, I can treat windows as objects without MFC eating my main() and
limiting my options.

Either way, main() and WinMain() are only parts of the system that fit
together to make a program consular or windular.

Then there's the question which of these situations is C++ Standard
compliant. That's only a question: You get the correct opcodes either way.
C++ programmers must at least understand the Standard, to continuously track
their program's compliance, so they know when they are pushing its envelop.
This is a point of pride among C++ programmers.

> You're not actually trying to be helpful, are you. You're just trying to
be
> smart. I've had the misfortune of working with people like you in the
past.
> Sorry.

Joe, this is Alf. Alf, Joe.

> I understand what you are saying. I'll get around to looking at this ruby
> thing you keep pushing - on a virtual machine. Does it hook into Windows,
> or is it self-contained in one's installation?

What are you saying? Ruby.exe is a dumb program that eats text files and
follows their instructions. No sandbox, virtual machine, or other fru-fru
involved.

But one can substitute "Python", "PHP", "TCL", or other light but OO
scripting languages for any of my Ruby rantings.

> Are there any non-trivial apps that you can point to as demonstrations of
> it's usefulness?

No. Only trivial ones.

<a beat>

;-)

> Afterall, in my experience of, say MFC (which MFC'ers
> swear by), anything that you want to do that's 'outside of the box' can
> become a right royal pain trying to work around MFC's internals. So, I
> wonder if it's the same with Ruby.

This is apples-and-oranges. Ruby is a language. MFC is a library. Ruby, like
other scripting languages, supports several GUI toolkits, each with
strengths and weaknesses. I think that Ruby/Tk lets you drill down to an
HWND and run raw window commands on it. You can also call raw Win32
directly.

> Looks good to managers cos you can go:
> click, click, clickety click. And there's the basis of our app. "Bloody
> hell! This will save us tons of development effort.", thinks manager.
> Hmmm... first mistake has been made on that project.

That's wizard-oriented programming. Per all my other posts, I prefer unit
tests, even for GUIs. They help a project _sustain_ a project as it grows,
so you can follow your demo up with results.

> Also, you might like to know that with quite a small class (or module in
C),
> about 60 lines of non-trivial code, I can create a window with 1 line line
> of code in my main app and add controls to it with 1 line of code too
> (dynamically) - there really is NO magic involved.

Uh, except someone else wrote Tk for you, and a huge community supports it.
Same for FOX, Qt, FLTK, etc.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand


.



Relevant Pages

  • Re: Connecting to the Internet
    ... > APIs was a lot easier than learning Registry APIs.) ... be installed in all versions of Windows that you choose to support. ... I hope you don't mind me saying you have "missed the boat". ... Vague questions such as that are often ignored in Microsoft newsgroups ...
    (microsoft.public.vb.winapi)
  • RE: [Full-Disclosure] lame bitching about xpsp2
    ... truly think you are saying something that can help. ... *nix way) you still would whine because they are also working on extending ... are concerned that you will have to learn Windows, ... I recall nimda and I don't recall my Windows machines getting infected even ...
    (Full-Disclosure)
  • Re: Executable enty points incorrectly documented
    ... You wrote that WinMain is not a starting function in CRT, but an user-defined entry point for a Windows application. ... I believe that the fact that this function is called by the C/C++ runtime clearly backs my opinion that WinMain has nothing to do with the operating system. ... Even if WinMain documentation remains in Windows SDK it would be wise to explicitly state that support for this entry point is provided by the C/C++ runtime rather than Windows itself. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Activating Windows XP Home
    ... Don't let them talk you into giving *any* other information besides that and don't let them coherce you into registering or validating Windows. ... I formatted my computer a couple of days ago and installed a fresh copy of XP Home and after installation, an automated message appeared on my computer saying something like, my hardware had changed and that I needed to verify and activate my copy of XP. ... I got a message say something like, according to Microsoft, you have exceeded the number of times that you can activate with the key and that I would need to call Microsoft. ... It is the opinion of many people that it is by design and intended to coherce unsuspecting/uninformed customers into buying another license and there are recent reports here of even the MS activation reps trying to get legitimate users to buy another license needlessly. ...
    (microsoft.public.windowsxp.general)
  • Re: Activating Windows XP Home
    ... I have a query with reference to how many times we can activate our copy of XP before we need to call Microsoft. ... I formatted my computer a couple of days ago and installed a fresh copy of XP Home and after installation, an automated message appeared on my computer saying something like, my hardware had changed and that I needed to verify and activate my copy of XP. ... I fully realise that making major hardware changes would probably need me to reactivate XP so I clicked on the link in the system tray and activated Windows online, ... coherce unsuspecting/uninformed customers into buying another license and there are recent reports here of even the MS activation reps trying to get legitimate users to buy another license needlessly. ...
    (microsoft.public.windowsxp.general)