|
there are some good aricles about "UserDraw" ListControls here.
|
|
|
|
|
Yes but this is for list control, I have a listbox.
Any idea.
|
|
|
|
|
goto "MFC Controls" -> "Combo & ListBoxes"
Control Subclassing
By Eric Sanchez
is good!
|
|
|
|
|
I have two classes Class A (a.cpp, a.h) and Class B(b.cpp,b.h)
I am having some confusion about a static variable I want to share.
the variable is int globalCount;
1. By declaring this variable in a.cpp I am unable to use it in b.cpp
a.cpp ---> static int globalCount=0;
b.cpp ---> extern int globalCount;
I get a Linker error .
2. can I declare globalCount in a.h and still use it in b.cpp the same way ? If no what changes do I need .
Please help
|
|
|
|
|
1) in a.h add: "extern int globalCount"
2) in a.cpp, declare: "int globalCount = 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
I need to declare in Class A and use it in Class B (.cpp)
|
|
|
|
|
Let's get some terminology straight here:
1) "global" implies that a data item lives in the global address space. Accessible from everywhere. An integer declared on it's own, outside of a class declaration is "global".
2) "static" carries 2 different meanings. Something declared as static within a class declaration, makes the item shared amongst all instances of that class. "static" on a data item (outside of a class declaration) makes it private to that file (not exportable).
3) extern is used to declare a data item as shareable among files. It's a good idea to place "extern" statements in headers.
You had mentioned that you wanted a global variable. I assumed that this was outside of a class definition.
How's about this -- post a sample piece of code, so that we can understand the problem that you face.
-p
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Does B.CPP include A.H?
I would assume that it does. You probably don't need to "extern" anything. You need to declare storage for the static (shared) var.
I bet your problem is this:
-----
A.H
-----
class A
{
public:
static int X;
};
-----
A.CPP
-----
int A::X; // <- I bet you don't have one of these to formally declare memory for the static var?
-----
B.CPP
-----
#incude "a.h"
int function()
{
printf( "X=%d", A::X );
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
yes that works. Guess i was mixing the static and extern keywords .So all I need to do is declare the static ,include a.h and use it in B.cpp.
or
declare it in a.cpp as
int globalCount=0;
and reference it in b.cpp using extern .
extern is hence implied as static !
|
|
|
|
|
I guess, you should leave the "static" word out.
MSDN on the static keyword:
<br />
static int i;
in the a.cpp:
int nImAmGlobal=0;
and in b.cpp
extern nImAmGlobal;
|
|
|
|
|
Why don't you create a public function that returns the content of that variable?
This would be more OOP standard, wouldn't it?
|
|
|
|
|
I'm part of a group that has produced lots of projects in Visual C++ using STLPORT. In Developer's Studio, we've used the Tools/Options/Directories menu, and set the top line under Include and Library files to STLPORT.
Now I'm writing a GUI for all these projects, using MFC, which wants to use the MS version of STL, not STLPORT. How do I get projects that use different versions of STL to compile and link within a single workspace?
Thanks,
Dale Russell
|
|
|
|
|
MFC does not use stl at all so I would use the STLPORT version there too, unless your boss wants you to do otherwise. I use STLPORT with all my MFC projects.
John
|
|
|
|
|
Hi there !
If any one could please prototype/describe "WlxDisconnectNotify" and "WlxReconnectNotify"? These 2 are new to XP. Also I would like to know if there are additonal export functions in msgina for Win2003.
Thanks in advance...
Lex
|
|
|
|
|
I am writing a small utility to run as a system tray app. My app will detect when a digital camera or a removable drive (such as CompactFlash readers, etc.) is attached to the computer. I am able to do this by listening to the WM_DEVICECHANGE event broadcast by Windows. However, once I got the event, I don't know how to detemine if the connected device is one the hardware types that I am waiting for. Right now, Windows fires this event whenever there's a hardware change, including CD insert and removals. Is there anyway I can determine if the connected device is a digital camera or a removable mass storage device? Any sample code of how to obtain this information would be helpfull. Thanks.
|
|
|
|
|
My current project (a VC++/MFC program) needs to do a very lenghty
computation. I want to use multiple PCs running together to shorten the processing time.
Here is the detailed idea:
There are not many interdependant calculations. Actually, i need to generate a very large 2D matrix. And each element in this matrix is computed by the same algorithm.
The problem is the data source is very large (millions of images). So what I am thinking is to seperate the data source and put subsets of the data onto different PCs. So each PC can run the program at the same time to generate a small part of the big matrix. After all the small matrixes complete, the program will combine them together.
Is it a feasible way? Could anyone please give me some idea on how to write this program? What kind of technique I need to use, and what computer structure should I use (peer to peer, or client server)? Thanks!
|
|
|
|
|
aurorahe explained the basics of distributed computing without knowing about it...
aurorahe wrote:
Is it a feasible way?
Indeed. This is the way much computational work is partitioned.
Could anyone please give me some idea on how to write this program?
I'm sorry, but don't you even have a clue of how to transmit the data between the computers, or is it just you don't know how to partition it? If the former you indeed have to read up on TCP/IP communications etc. If the latter I suggest you go with a gut feeling: Honestly - if you have a gut feeling about something, chances are it's right.
The structure you should use depend entirely on what you have at hand - if you have a Beowulf cluster it's pretty obvious. If you have a "master" machine and a lot of "slaves" it's equally obvious. If you have a grid... well, if you had a grid I'd expect you to know how to at least balance it why I can't give any advice.
Perhaps you should tell us what kind of hardware you have (and how it's connected) before we even can guess of what you need and/or want?
|
|
|
|
|
Maybe I need to use DCOM or gSOAP?
The hardware I have is a couple of PCs (running XP or 2000) networked together (Microsoft Windows Netwrok). Any hint? Thanks!
|
|
|
|
|
I have to do something similar (but not with images) in two weeks... so if you have a solution maybe you write an article?!
|
|
|
|
|
|
You could look at MsgConnect http://www.msgconnect.com[^] It looks interesting, but I haven't actually used it. I'd be interested in any feedback you may have if you do use it.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Probably a bit of a late response, but you could look at doing a web search for 'grid computing', where I beleive this is what they were doing ..
'G'
|
|
|
|
|
grid computing is way too advanced i guess.
|
|
|
|
|
sure its advanced - but using the MsgConnect tool & similar idea you could scale it down a bit - its a great concept
'G'
|
|
|
|
|
sorry for this simple question, but how can I get my color printer to print in the same color as my VC++ 6.0 IDE display? - yes, I do have colour selected.
I have comments in Green, keywords in Blue, ... I would like my printed pages to display the same colours.
Thanks for helping me with this.
Johnny
|
|
|
|