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

How to create listbox in native C++ w/o dialog box and w/o MFC?

1 view
Skip to first unread message

Siegfried Heintze

unread,
Sep 18, 2008, 1:33:27 PM9/18/08
to
Can someone point me to some sample code that creates a listbox without a
dialog box and without MFC?

I tried calling CreateWindow with a lisbox class but I could not figure out
to populate it and I was not sure which callbacks I had to implement in the
winproc.

Thanks!
Siegfried


Christian Kaiser

unread,
Sep 19, 2008, 3:26:30 AM9/19/08
to
Look at the LB_xxxx messages (or ListBox_Xxxxx macros).

If you want raw Win32 API (which I also do - I don't use MFC or ATL, I
have my own classes), you should have a book like the old Petzold
(which was my favorite decades ago).

Christian

"Siegfried Heintze" <sieg...@heintze.com> wrote in message
news:uBmqrSbG...@TK2MSFTNGP04.phx.gbl...

Alex Blekhman

unread,
Sep 19, 2008, 8:15:27 AM9/19/08
to
"Siegfried Heintze" wrote:
> Can someone point me to some sample code that creates a listbox
> without a dialog box and without MFC?

MFC is just a C++ library over the Win32 API. Everything you do
with MFC can be done with plain API calls. It is just much more
spadework to get something done.

Now about a list box. List box control cannot be created as a
standalone window. It is ment to be a child window of other
window. So you will need some top-level window to host controls
like list box and others.

> I tried calling CreateWindow with a lisbox class but I could not
> figure out to populate it and I was not sure which callbacks I
> had to implement in the winproc.

Here's the section n MSDN library that contains info about UI
controls:

"Windows Controls"
http://msdn.microsoft.com/en-us/library/bb773173(VS.85).aspx

Specific section for list boxes:

"List Box"
http://msdn.microsoft.com/en-us/library/bb775146(VS.85).aspx

For each UI control you will find three subsections in the left
pane: About, Using and Reference. Read at least two first sections
to understand how a control works and how to manipulate it. Use
the Reference section to find full list of messages, styles and
constants that relate to the control.

Also, consider Control Spy tool. It is helpful when you need to
discover control's styles and appearance.

"Control Spy v2.0"
http://msdn.microsoft.com/en-us/library/bb773165(VS.85).aspx


HTH
Alex


r_z_...@pen_fact.com

unread,
Sep 19, 2008, 1:34:55 PM9/19/08
to
On Thu, 18 Sep 2008 10:33:27 -0700, "Siegfried Heintze"
<sieg...@heintze.com> wrote:

>Can someone point me to some sample code that creates a listbox without a
>dialog box and without MFC?

We all have access to most of the source code for MFC, so even those
of us who avoid using MFC in our programs can find its source code
useful as a library. Reading the source code can be challenging, but
often enough you can quickly get enough info to get started on your
own code. Also, MFC is real code that is used in many real programs,
so you can be pretty sure it works (not necessarily efficiently or
safely).


>
>I tried calling CreateWindow with a lisbox class but I could not figure out
>to populate it and I was not sure which callbacks I had to implement in the
>winproc.
>
>Thanks!
>Siegfried
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 400
Boston, MA 02116
www.penfact.com

Dan Miller

unread,
Oct 15, 2008, 3:20:16 PM10/15/08
to
Check out the ZetCode example:
http://www.zetcode.com/tutorials/winapi/advancedcontrols/
About halfway down the page. He has a clear, simple example which compiles
with MinGW.

Dan Miller

"Siegfried Heintze" <sieg...@heintze.com> wrote in

news:uBmqrSbG...@TK2MSFTNGP04.phx.gbl:

0 new messages