Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ann: lesson 4 in Windows API level GUI programming "Dialogs and resources"

11 views
Skip to first unread message

Alf P. Steinbach

unread,
Dec 27, 2011, 11:36:00 PM12/27/11
to

Leigh Johnston

unread,
Dec 29, 2011, 2:17:52 PM12/29/11
to
On 28/12/2011 04:36, Alf P. Steinbach wrote:
> <url:
> http://learnwinapi.wordpress.com/2011/12/28/lesson-4-dialogs-and-resources/>

Each "lesson" is more off-topic than the last.

/Leigh

RaZiel

unread,
Jan 3, 2012, 5:33:01 PM1/3/12
to
Excuse my ignorance. Why does WindowSpec contain a construtor? Isn't it
a POD?

- RaZ

Leigh Johnston

unread,
Jan 3, 2012, 5:37:19 PM1/3/12
to
Do you think that because 'WindowSpec' is a 'struct'? A 'struct'
doesn't have to be a POD just as a 'class' does not have to be a POD.
The only difference between 'struct' and 'class' are default access
permissions for members and inheritance ('struct' is public, 'class' is
private).

/Leigh

Christopher

unread,
Jan 3, 2012, 8:06:16 PM1/3/12
to
On Dec 27 2011, 10:36 pm, "Alf P. Steinbach" <alf.p.steinbach
+use...@gmail.com> wrote:
> <url:http://learnwinapi.wordpress.com/2011/12/28/lesson-4-dialogs-and-reso...>
>
> Cheers & enjoy,
>
> - Alf

I don't understand these posts anymore. I was under the impression
that Alf usually complained about some short coming of Windows as it
relates to C++ and Leigh would argue back, triggering an argument from
Alf, and etc. etc. Did I get it mixed up and Alf is the Windows
proponent and Leight is not? I need to understand the characters in
this drama.

Alf P. Steinbach

unread,
Jan 3, 2012, 8:18:25 PM1/3/12
to
On 03.01.2012 23:33, RaZiel wrote:
> On 28.12.2011 05:36, Alf P. Steinbach wrote:
>> <url:
>> http://learnwinapi.wordpress.com/2011/12/28/lesson-4-dialogs-and-resources/>
>
> Excuse my ignorance. Why does WindowSpec contain a construtor? Isn't it
> a POD?

Repeating the answer I posted to the same question on the blog:


<quote>
Well, WindowSpec has a constructor just for convenience. By C++98/C++03
rules it�s therefore not a POD. By C++11 rules it is however a standard
layout class.

I am not sure of whether it is POD by the more relaxed C++11 rules. The
C++11 definition of POD is essentially that the class is both trivial
and standard-layout. But the definition of �trivial� is, as I see it,
open for interpretation, at least for pedantically formal folks. :)

Anyway, it�s just a convenience class, and since it relies on
assumptions about memory layout, it is very system-specific (but should
work with any Windows compiler). I started writing that code using a
std::vector<Byte> where I serialized the data, which would have have
yielded code that in principle could be more portable, but then I caught
myself: hey, introducing complexity to get system portable code for
Windows API? It was just reflex coding. So then I intentionally reworked
and simplified that as system-specific code. :-)
</quote>


Cheers & hth.,

- Alf

Leigh Johnston

unread,
Jan 3, 2012, 8:16:59 PM1/3/12
to
On 04/01/2012 01:06, Christopher wrote:
> On Dec 27 2011, 10:36 pm, "Alf P. Steinbach"<alf.p.steinbach
> +use...@gmail.com> wrote:
>> <url:http://learnwinapi.wordpress.com/2011/12/28/lesson-4-dialogs-and-reso...>
>>
>> Cheers& enjoy,
>>
>> - Alf
>
> I don't understand these posts anymore. I was under the impression
> that Alf usually complained about some short coming of Windows as it
> relates to C++ and Leigh would argue back, triggering an argument from
> Alf, and etc. etc. Did I get it mixed up and Alf is the Windows
> proponent and Leight is not? I need to understand the characters in
> this drama.

Me?

I think Windows is a fine OS but Microsoft's Windows C++ support not so
much; I didn't used to mind MFC but I have recently decided that it
really is a bag of shite and as a result of this and for other reasons I
am creating my own cross-platform C++ GUI lib which you can check out at
http://neogfx.org if interested (work in progress, hopefully out in 2012).

/Leigh

Ian Collins

unread,
Jan 3, 2012, 9:20:38 PM1/3/12
to
Another one? Aren't there enough already?

--
Ian Collins

Leigh Johnston

unread,
Jan 3, 2012, 9:58:54 PM1/3/12
to
There will never be enough.

/Leigh

Miles Bader

unread,
Jan 3, 2012, 10:36:41 PM1/3/12
to
Leigh Johnston <le...@i42.co.uk> writes:
>>> I am creating my own cross-platform C++ GUI lib which you can check
>>> out at http://neogfx.org if interested.
>>
>> Another one? Aren't there enough already?
>
> There will never be enough.

Maybe one of these days, somebody will finally get it right...

-miles

--
History, n. An account mostly false, of events mostly unimportant, which are
brought about by rulers mostly knaves, and soldiers mostly fools.

Paavo Helde

unread,
Jan 4, 2012, 2:45:33 AM1/4/12
to
Christopher <cp...@austin.rr.com> wrote in
news:12fef322-66b8-4152...@n6g2000vbz.googlegroups.com:
I think there is no drama, this is not an OS advocacy group. In a
technical group, Windows is a tool for getting something done, not
something to love or hate. The discussion is about how to use this tool
better.

Alf wants to be able to write robust and portable style Windows GUI code
without resorting to any "black magic" usually associated with Windows
GUI programming (generated code using obscure macros, wysiwyg dialog
editors, hidden message loops etc.). Leigh wants to get all rules
followed by 100%, which is good for technical details, but does not work
so well with people. At least for technical parts their goals have some
overlap as far as I can see.

Ulrich Eckhardt

unread,
Jan 4, 2012, 9:32:14 AM1/4/12
to
Am 04.01.2012 02:18, schrieb Alf P. Steinbach:
> On 03.01.2012 23:33, RaZiel wrote:
>> On 28.12.2011 05:36, Alf P. Steinbach wrote:
>>> <url:
>>> http://learnwinapi.wordpress.com/2011/12/28/lesson-4-dialogs-and-resources/>
>>>
>>
>> Excuse my ignorance. Why does WindowSpec contain a construtor? Isn't it
>> a POD?
>
> Repeating the answer I posted to the same question on the blog:
>
>
> <quote>
> Well, WindowSpec has a constructor just for convenience. [...]
> </quote>

I think factory function are a good alternative, especially if you want
to keep the compiler-generated default constructor and
by-any-C++-standard POD-ness.

That said, what I find unclear is the point of single-wchar_t fields in
that struct. I have an idea what this hack does and how it works, but
putting that into public members seems like a bad idea to me.

Another thing I noticed on cursory reading was that you explicitly use
wchar_t but neither MESSAGEBOXPARAMSW nor MessageBoxIndirectW().

Cheers and thank you anyway!

Uli

Alf P. Steinbach

unread,
Jan 4, 2012, 10:40:48 AM1/4/12
to
On 04.01.2012 15:32, Ulrich Eckhardt wrote:
> Am 04.01.2012 02:18, schrieb Alf P. Steinbach:
>> On 03.01.2012 23:33, RaZiel wrote:
>>> On 28.12.2011 05:36, Alf P. Steinbach wrote:
>>>> <url:
>>>> http://learnwinapi.wordpress.com/2011/12/28/lesson-4-dialogs-and-resources/>
>>>>
>>>>
>>>
>>> Excuse my ignorance. Why does WindowSpec contain a construtor? Isn't it
>>> a POD?
>>
>> Repeating the answer I posted to the same question on the blog:
>>
>>
>> <quote>
>> Well, WindowSpec has a constructor just for convenience. [...]
>> </quote>
>
> I think factory function are a good alternative, especially if you want
> to keep the compiler-generated default constructor and
> by-any-C++-standard POD-ness.

Factory functions are nice for some things, but in general and in this
case it's just more to write than simply defining a constructor.

In other words, there was no particular reason to use a factory function.



> That said, what I find unclear is the point of single-wchar_t fields in
> that struct. I have an idea what this hack does and how it works, but
> putting that into public members seems like a bad idea to me.

They represent the terminating nulls of null-terminated strings.


> Another thing I noticed on cursory reading was that you explicitly use
> wchar_t but neither MESSAGEBOXPARAMSW nor MessageBoxIndirectW().

[windows.h] does not IMHO define any better, more readable name for
`wchar_t`.

However, [windows.h] does define e.g. MSGBOXPARAMS as a more readable
alternative for MSGBOXPARAMSW, and it is not only more readable but also
more easy to look up in the documentation (e.g., right-click and google).

In modern Windows programming there is no practical reason to reserve
that name for places where it might work to instead have it defined as
MSGBOXPARAMSA, since (one just ensures that) it will never be defined as
anything but MSGBOXPARAMSW.


> Cheers and thank you anyway!
>
> Uli

Cheers,

- ALf

Paul

unread,
Jan 4, 2012, 12:49:31 PM1/4/12
to

"Leigh Johnston" <le...@i42.co.uk> wrote in message
news:v8CdnTN_s7wUNZ7S...@giganews.com...
That xml is horrible.Don't use attributes for data.


I notice you don't give a proper example of source code with instructions of
how to compile/link. What is that code some kind of mixed XML and C++



--- Posted via news://freenews.netfront.net/ - Complaints to ne...@netfront.net ---

Leigh Johnston

unread,
Jan 4, 2012, 1:23:04 PM1/4/12
to
On 04/01/2012 17:49, Paul <pchrist wrote:
> "Leigh Johnston"<le...@i42.co.uk> wrote in message
> news:v8CdnTN_s7wUNZ7S...@giganews.com...
>> On 04/01/2012 01:06, Christopher wrote:
>>> On Dec 27 2011, 10:36 pm, "Alf P. Steinbach"<alf.p.steinbach
>>> +use...@gmail.com> wrote:
>>>> <url:http://learnwinapi.wordpress.com/2011/12/28/lesson-4-dialogs-and-reso...>
>>>>
>>>> Cheers& enjoy,
>>>>
>>>> - Alf
>>>
>>> I don't understand these posts anymore. I was under the impression
>>> that Alf usually complained about some short coming of Windows as it
>>> relates to C++ and Leigh would argue back, triggering an argument from
>>> Alf, and etc. etc. Did I get it mixed up and Alf is the Windows
>>> proponent and Leight is not? I need to understand the characters in
>>> this drama.
>>
>> Me?
>>
>> I think Windows is a fine OS but Microsoft's Windows C++ support not so
>> much; I didn't used to mind MFC but I have recently decided that it really
>> is a bag of shite and as a result of this and for other reasons I am
>> creating my own cross-platform C++ GUI lib which you can check out at
>> http://neogfx.org if interested (work in progress, hopefully out in 2012).
>>
>
> That xml is horrible.Don't use attributes for data.

Don't use XML attributes for data? Are you crazy?

> I notice you don't give a proper example of source code with instructions of
> how to compile/link. What is that code some kind of mixed XML and C++

Instructions on how to use the library are not yet available as the
library is still in development.

No it is not mixed XML and C++; the XML is in a resource file which is
compiled separately to the C++ by my resource compiler.

/Leigh

Paul

unread,
Jan 4, 2012, 1:48:32 PM1/4/12
to

"Leigh Johnston" <le...@i42.co.uk> wrote in message
news:CdmdnfjMJYObBJnS...@giganews.com...
The comment was related to your xml coding style. Its not right nor wrong
its just a matter of taste as expalined here:
http://www.w3schools.com/xml/xml_attributes.asp

Your XML resembles the "Don't end up like this" example shown under the
heading "Avoid XML Attributes.
Like I said it's horrible XML.

>
>> I notice you don't give a proper example of source code with instructions
>> of
>> how to compile/link. What is that code some kind of mixed XML and C++
>
> Instructions on how to use the library are not yet available as the
> library is still in development.
>
> No it is not mixed XML and C++; the XML is in a resource file which is
> compiled separately to the C++ by my resource compiler.
>

So if I write a windows program which usually has the entry point winMain
function, your GUI library would replace the whole program entry point
function with a main fucntion?
And your GUI library also controls the msgLoop?

Leigh Johnston

unread,
Jan 4, 2012, 2:01:42 PM1/4/12
to
You do not know what you are talking about irrespective of what some
random website says; there is nothing wrong with the XML. I am well
aware of when to use attributes and when to use elements.

>
>>
>>> I notice you don't give a proper example of source code with instructions
>>> of
>>> how to compile/link. What is that code some kind of mixed XML and C++
>>
>> Instructions on how to use the library are not yet available as the
>> library is still in development.
>>
>> No it is not mixed XML and C++; the XML is in a resource file which is
>> compiled separately to the C++ by my resource compiler.
>>
>
> So if I write a windows program which usually has the entry point winMain
> function, your GUI library would replace the whole program entry point
> function with a main fucntion?

Yes as the example illustrates except you wouldn't be writing a "Windows
program" you would be writing a "neogfx program".

> And your GUI library also controls the msgLoop?

The Windows version of neogfx provides the message loop yes.

/Leigh

Paul

unread,
Jan 4, 2012, 3:56:25 PM1/4/12
to

"Leigh Johnston" <le...@i42.co.uk> wrote in message
news:PJCdnfZfeuqJP5nS...@giganews.com...
Ok if you say so.
>>
>>>
>>>> I notice you don't give a proper example of source code with
>>>> instructions
>>>> of
>>>> how to compile/link. What is that code some kind of mixed XML and C++
>>>
>>> Instructions on how to use the library are not yet available as the
>>> library is still in development.
>>>
>>> No it is not mixed XML and C++; the XML is in a resource file which is
>>> compiled separately to the C++ by my resource compiler.
>>>
>>
>> So if I write a windows program which usually has the entry point winMain
>> function, your GUI library would replace the whole program entry point
>> function with a main fucntion?
>
> Yes as the example illustrates except you wouldn't be writing a "Windows
> program" you would be writing a "neogfx program".
>
>> And your GUI library also controls the msgLoop?
>
> The Windows version of neogfx provides the message loop yes.
>
So if someone wanted to use a windows service, such as a timer for
example, and accept incoming events from it. Would this be possible from
within your neogfx program?

Leigh Johnston

unread,
Jan 4, 2012, 4:04:13 PM1/4/12
to
On 04/01/2012 20:56, Paul <pchrist wrote:
> "Leigh Johnston"<le...@i42.co.uk> wrote in message
> news:PJCdnfZfeuqJP5nS...@giganews.com...
>> On 04/01/2012 18:48, Paul<pchrist wrote:
[snip]
>>> And your GUI library also controls the msgLoop?
>>
>> The Windows version of neogfx provides the message loop yes.
>>
> So if someone wanted to use a windows service, such as a timer for
> example, and accept incoming events from it. Would this be possible from
> within your neogfx program?

My library provides its own timers. The goal is to provide a library
that allows the programmer to write as little platform specific code as
possible. The Windows specific message loop is hidden from the programmer.

/Leigh

Paul

unread,
Jan 4, 2012, 5:04:42 PM1/4/12
to

"Leigh Johnston" <le...@i42.co.uk> wrote in message
news:9fednQV0w5JWI5nS...@giganews.com...
Well err good luck with that.
0 new messages