Re: newbie question: Can I modify MFC source code?
- From: "Alan Carre" <alan@xxxxxxxxxxxxxxxxx>
- Date: Wed, 3 Sep 2008 00:31:24 +0700
"BobF" <nothanks@xxxxxxxxxxxxxx> wrote in message
news:OiO4E2HDJHA.2476@xxxxxxxxxxxxxxxxxxxxxxx
Ajay - Thanks for top posting. It saves those of us with intact memory
facilities avoid unnecessary scrolling. I really appreciate the
alternatives you suggest as well.
Sarcasm noted.
Now do the following...
Without scrolling down unnecessarily (which you detest) try to guess the
topic of the thread corrsponding to this post:
----------------------------------------------------------------------
[BEGIN POST]
ON_COMMAND_RANGE. All edit controls were in the same range, all combo boxes
were in
another range, etc. When the command finally got to my window (which was
the active
view), it then looked up the command in its own table of controls and set
the value in the
internal representation; if the window was visible, it then set the value in
the window.
This handled "unsolicited" inputs from the controllers. Alarm inputs would
create
notifications appropriately so the user could go see what was wrong (and
that's moving
into proprietary stuff, which I can't discuss here...the alarm notification
was quite
clever, and that's all I can say)
Since under no sane conditions would I ever consider UpdateData as a viable
solution to
the problem of updating controls, I never needed "a variable". The data was
held in my
own internal structure, and if I wanted to set it, I would do SetWindowText,
SetCheck,
SetCurSel, CheckRadioButton, etc. as appropriate (there was a very
interesting use of
classes and virtual methods to handle this, for example, Show() always did
the right thing
and the subclass worried about what the implementation of Show() meant)
joe
On Mon, 1 Sep 2008 01:43:00 -0700, Electronic75
<Electronic75@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
By the way joe I forgot to ask how you handle messages in your approach. I
mean for example the command needs a combo box along with an edit box to be
created to get user inputs then how you capture CBN_SELCHANGE for a combo
that was not present before dynamic creation or how you assign a variable
to edit box in run time?
cheers,
"Joseph M. Newcomer" wrote:
See below...
On Sun, 31 Aug 2008 09:57:00 -0700, Electronic75
<Electronic75@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Thanks a lot joe and tom for your positive and informative inputs.****
I generally do not use global variable much but in this case
I like to define a series of constant commands for program. the program
talks to different embedded devices and user at the beginning selects a
device that is connected to via USB. Now for talking I need a big set
of commands for each device these commands not only include their
command codes but many parameters, priorities, conversion algorithm
codes,...,
Now it is a big chunk of information for each command, so I need many
files for different devices e.g. file1 has instruction set of device1,
file 2 has instruction set of device2,...
I have read somewhere that it is an unwritten convention that a C file
should never go beyond 1000 lines except in very rare occasions to ease
debug and future manipulation.
I find principles like this rather silly. For example, I have C files
that contain one
line. I have C files that contain 8000 lines. File size rarely has any
value in dealing
with debugging, and editing a 10,000 line file is not that much harder
than editing 1,000
lines. ****
so in my case I tried to store these information in cons variables. you****
may ak why I do not use structs for this, well I may do that in light of
what I've learned here but my original problem was to store those const
variables in const classes so I can also benefit from functionality of
classes to do sum calculations on some parameters of these const
commands.
But const tables that are based on CArray of a struct are not const and
can't be.
I can't even parse much of the last description. I do exactly this for
an embedded system; the company has files that describe each
command, each option, etc. for each class of embedded device, and I
simply read these in
and create descriptions (a set of nested tabbed dialogs, in fact, that
contain scrollable
sets of controls which include edit controls, combo boxes, radio buttons,
etc.). It is
done as an MDI application, where each "document" is an embedded
controller. At no point did I need a global variable. The commands are
part of the CDocument-derived
class. Compared to the complexity of the user interface, the cost of the
data structures
is irrelevant (a given controller may require 5,000 controls; I
dynamically create them
when the page has focus and destroy them when the page loses focus, so at
no time does a
controller require more than perhaps 100 windows at any given instant).
So it isn't clear
how you use a global variable here, since you would need to have one
variable per
controller type.
At no point can these be const, because const is a compile-time
declaration that says
"this can never change", which means you cannot ever load them from a
file.
joe
****
joe
****
thank you all :)
"Tom Serface" wrote:
Just an opinion...
I would not make this a global variable. Instead I would probably add
it to the main app class or perhaps, a class that contains other
variables like this that is, itself, hosted in the main app class.
That way you could access it with code like:
theApp.m_InfoArray.Add()
Which lets you know where it is hosted and also you could easily clean
it up when exiting the application instance. This is also very easy
to debug.
I try very hard not to use global variables these days and I've found
it makes debugging and cleaning up much easier.
Tom
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[FULL STOP]
Below is the original question. If you are reading this BobF, then you've
done a lot of unnecessary scrolling then haven't you?
The question was about const global class members.
The response below it is a *non-top post*... So the text below the following
was written AFTER the initial question, but BEFORE the text at the top of
the post. Did you notice any other time displacements in this post? Do you
know what the questions and responses correspond-to when it's going back and
forth in time?
No, I dodn't think so
[/FULL STOP]
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Joseph M. Newcomer [MVP]Joseph M. Newcomer [MVP]"Electronic75" <Electronic75@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:420537CC-30E0-4A6A-B24B-A54AC08B8AC2@xxxxxxxxxxxxxxxx
Hello :), I'm trying to define a global const class varibles in a
MFC
application. This class holds an array of variables that I like to
assign at
the beginning and I will use this variable and its stored const
values in my
program in different classes. Now what I'm doing is to add a blank
cpp file
to my project and then I define this class variable there.
#include "MyInfoArrayClass.h"
const CMyInfoArrayClass g_Info;
g_Info.Add(data1);
g_Info.Add(data2);
...
but compiler dose not see the definition and intellisense shows the
type of
g_Info as int and returns SYNTAX error and redefinition of basic
type. Even
when I place class definition in a header file and include header
file in the
source file compiler returns same errors.
I have done this with a char type or int type, I mean I have defined
a
global char or int variable, and I had no problem but when I want to
define a
class type variable I encounter trouble.
Where I made a mistake?
thanks :)
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
[/END POST]
.
- Follow-Ups:
- Evils of Top-Posting (Was: newbie question: Can I modify MFC source code?)
- From: Daniel James
- Re: newbie question: Can I modify MFC source code?
- From: BobF
- Evils of Top-Posting (Was: newbie question: Can I modify MFC source code?)
- References:
- Re: newbie question: Can I modify MFC source code?
- From: Alan Carre
- Re: newbie question: Can I modify MFC source code?
- Prev by Date: Re: modeless menus
- Next by Date: Re: newbie question: Can I modify MFC source code?
- Previous by thread: Re: newbie question: Can I modify MFC source code?
- Next by thread: Re: newbie question: Can I modify MFC source code?
- Index(es):
Relevant Pages
|