From: Puckdropper on
I have a dialog box that consists of edit controls, where there are several
edit controls in a row, and the row is repeated over and over again. This
was created with Visual Studio's resource editor, and all the controls have
names such as IDC_ACCOUNTDESCRIPTION1, IDC_ACCOUNTNAME1,
IDC_ACCOUNTDESCRIPTION2, IDC_ACCOUNTNAME2, etc.

Is there something like an array I can use to make reading these dialog
boxes easier? I'd like to read one row at a time, based on an ID the
program passes in.

I'm new to Win32, but not programming in general.

Thanks!

Puckdropper
--
If you're quiet, your teeth never touch your ankles.

To email me directly, send a message to puckdropper (at) fastmail.fm
From: Bob Masta on
On 22 Jul 2008 07:35:03 GMT, Puckdropper
<puckdropper(at)yahoo(dot)com> wrote:

>I have a dialog box that consists of edit controls, where there are several
>edit controls in a row, and the row is repeated over and over again. This
>was created with Visual Studio's resource editor, and all the controls have
>names such as IDC_ACCOUNTDESCRIPTION1, IDC_ACCOUNTNAME1,
>IDC_ACCOUNTDESCRIPTION2, IDC_ACCOUNTNAME2, etc.
>
>Is there something like an array I can use to make reading these dialog
>boxes easier? I'd like to read one row at a time, based on an ID the
>program passes in.

You could assign the IDs according to a structure. In your example, a
row only has 2 fields, so there would be 2 items per structure. To
find any field in any row, you multiply the row number times the
number of fields per row, then add the field number, then add the ID
of the first entry in the entire set (IDC_ACCOUNTDESCRIPTION1, in your
example). Just like dealing with normal variable arrays, actually.

Since I don't work with Visual Studio, I can't say how to make it
assign the IDs in a desired way. But it's cetainly easy to do within
the resource (.RC) file itself.

Best regards,


Bob Masta

DAQARTA v4.00
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
FREE Signal Generator
Science with your sound card!
From: Jugoslav Dujic on
Puckdropper wrote:
| I have a dialog box that consists of edit controls, where there are several
| edit controls in a row, and the row is repeated over and over again. This
| was created with Visual Studio's resource editor, and all the controls have
| names such as IDC_ACCOUNTDESCRIPTION1, IDC_ACCOUNTNAME1,
| IDC_ACCOUNTDESCRIPTION2, IDC_ACCOUNTNAME2, etc.
|
| Is there something like an array I can use to make reading these dialog
| boxes easier? I'd like to read one row at a time, based on an ID the
| program passes in.
|
| I'm new to Win32, but not programming in general.

You can edit your resource.h file manually and ensure that the IDs are
consecutive (e.g. IDC_ACCOUNTNAME1 = 1331, ... IDC_ACCOUNTNAME7 = 1337).
Just take care to also adjust AFX_NEXT_*VALUE macros at the end of the
file as well, if necessary. That will significantly simplify the code,
on the expense that the dependency is hidden in the .rc file and not
obvious to the maintainer (who might get the task to add a couple more
of those one day and get surprised).

Alternatively, with some more typing, you can declare constant arrays
in your code (wndproc or a header file):

const int MAX_ACCNAME = 7;
const UINT idAccName[MAX_ACCNAME] =
{IDC_ACCOUNTNAME1, ... IDC_ACCOUNTNAME7};
and refer to idAccName thereafter. However, you will also have to
re-type the entire thing occasionally, e.g. in switch() statements

Alternatively still , you can use listview control in
report mode, a grid control, or similar, as a more appopriate tool
for the job.

--
Jugoslav
___________
www.xeffort.com

Please reply to the newsgroup.
You can find my real e-mail on my home page above.
From: Puckdropper on
"Jugoslav Dujic" <jdujic(a)yahoo.com> wrote in
news:6em6mqF7rfgtU1(a)mid.individual.net:


> You can edit your resource.h file manually and ensure that the IDs are
> consecutive (e.g. IDC_ACCOUNTNAME1 = 1331, ... IDC_ACCOUNTNAME7 =
> 1337). Just take care to also adjust AFX_NEXT_*VALUE macros at the end
> of the file as well, if necessary. That will significantly simplify
> the code, on the expense that the dependency is hidden in the .rc file
> and not obvious to the maintainer (who might get the task to add a
> couple more of those one day and get surprised).
>
> Alternatively, with some more typing, you can declare constant arrays
> in your code (wndproc or a header file):
>
> const int MAX_ACCNAME = 7;
> const UINT idAccName[MAX_ACCNAME] =
> {IDC_ACCOUNTNAME1, ... IDC_ACCOUNTNAME7};
> and refer to idAccName thereafter. However, you will also have to
> re-type the entire thing occasionally, e.g. in switch() statements
>
> Alternatively still , you can use listview control in
> report mode, a grid control, or similar, as a more appopriate tool
> for the job.
>

Thanks, I'll look in to the alternatives you mentioned. The grid control
might be really what I need.

Puckdropper
--
If you're quiet, your teeth never touch your ankles.

To email me directly, send a message to puckdropper (at) fastmail.fm
From: Puckdropper on
NoSpam(a)daqarta.com (Bob Masta) wrote in
news:4885c6bc.638970(a)news.sysmatrix.net:

> On 22 Jul 2008 07:35:03 GMT, Puckdropper
> <puckdropper(at)yahoo(dot)com> wrote:
>
>>I have a dialog box that consists of edit controls, where there are
>>several edit controls in a row, and the row is repeated over and over
>>again. This was created with Visual Studio's resource editor, and all
>>the controls have names such as IDC_ACCOUNTDESCRIPTION1,
>>IDC_ACCOUNTNAME1, IDC_ACCOUNTDESCRIPTION2, IDC_ACCOUNTNAME2, etc.
>>
>>Is there something like an array I can use to make reading these
>>dialog boxes easier? I'd like to read one row at a time, based on an
>>ID the program passes in.
>
> You could assign the IDs according to a structure. In your example, a
> row only has 2 fields, so there would be 2 items per structure. To
> find any field in any row, you multiply the row number times the
> number of fields per row, then add the field number, then add the ID
> of the first entry in the entire set (IDC_ACCOUNTDESCRIPTION1, in your
> example). Just like dealing with normal variable arrays, actually.
>
> Since I don't work with Visual Studio, I can't say how to make it
> assign the IDs in a desired way. But it's cetainly easy to do within
> the resource (.RC) file itself.
>
> Best regards,
>
>
> Bob Masta

Thanks for the suggestion, I might go this route if others don't work
out.

Puckdropper
--
If you're quiet, your teeth never touch your ankles.

To email me directly, send a message to puckdropper (at) fastmail.fm