Solved

Control IDs ?

Posted on 1998-12-29
3
173 Views
Last Modified: 2010-04-02
I am creating a listview with the following statement

m_pListView->Create( WS_VISIBLE |  LVS_SINGLESEL | LVS_NOSORTHEADER | LVS_SHOWSELALWAYS | LVS_REPORT, rect, this, ID_LISTVIEW );

This code comes from an example in a book. The problem is that no explanation is given as to where to declare ID_LISTVIEW and what number to make it. If I just use 120 it works but I would like to be a bit more certain about what is going on. All help will be greatly appreciated.
0
Comment
Question by:agrillage
  • 2
3 Comments
 

Accepted Solution

by:
koskia earned 20 total points
ID: 1181218
hello agrillage,
every control in MFC must have a uniqe UINT (32 bit value)
number, which Identifies it.
many calls uses this ID as a parameter,
you can't use 120!
there may be a resource or another control with the same ID
if you want to create a unique id, use a #define statement
there is a constant named 'WM_USER' which is set to a number not use by the system.
you can define your controls from this const and on:
#define ID_MYLISTVIEW1   WM_USER + 1
#define ID_MYLISTVIEW2   WM_USER + 2

and so on.




























0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1181219
what's with all the '\n'?
0
 

Expert Comment

by:koskia
ID: 1181220
just a fluke
my Enter key was pressed down, and probably when you reach a certain size it sends the answer automatically
:))
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question