|
I'm creating a map editor for a game engine i've been working on. I'm hoping to create the interface in a similar fashion to photoshop. Basically, I have my MDI setup... and i'm creating and displaying small WS_EX_TOOLWINDOW'd dialogs, which will contain information and interaction tools for level editing. But, I'm having a couple problems.
Main Question:
In photoshop, when you click one of the palette windows, focus is not taken from the document. How can I do the same thing? As soon as I click on of my tool windows, no CDocument is active.
Secondary Question:
Also, I can get the small windows to show on top of the application (TOPMOST), and when the app is minimized, i hide the tool windows. But, if I put my app behind others, the tool windows are on top of EVERY window. I only want them on top of MY application, not every running window of every app.
Extra Question:
Also, is there a graceful way to detect when the active document has changed? An event handler, perhaps?
|
|
|
|
|
I keep getting the following error upon linking:
"error LNK2001: unresolved external symbol "public: class CString __thiscall CMyDoc::FKeyReset(int)"
This happens when I try to instantiate a function template. The code snippets are below. Does any one spot an obvious problem in it? Thanks,
Ralf.
MyDoc.h:
template<class t=""> CString FKeyReset(T RecSet);
MyDoc.cpp
template<class t=""> CString FKeyReset(T RecSet) {
CString str;
if(T > 0)
str.Format("message 1");
else
str.Format("message 2");
return str;
}
Elsewhere outside MyDoc:
CMyDoc *pMyDoc = (CFisheriesDoc *) //pointer to MyDoc
((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument();
CString szAstr;
int i = 2;
szAstr = pMyDoc ->FKeyReset(i); //offending line
ralf.riedel@usm.edu
|
|
|
|
|
|
I'm creating one of the biggest project I have undertaken N I'm a newbie, so I need lots of help. Because it's so big, I break it down into multiple parts (multiple projects, 1 DSP for 1 DSW), which I call utilities.
Now I want to use a "Utility", eg MyCustomStringCls, in another project. I have compiled N tested the "utility" so I have the OBJ file already.
Now here are my Q:
1. When I want to use an utility (eg MyCustomStringCls), in VC++, do I need to "Add To Project > Files" the MyCustomStringCls.h and the .CPP?
2. I want to call include with Angle bracket instead of DoubleQuote, do I just need to "Settings > C/C++ tab > Preprocessor" and add the path to "Additional Include directories" ?
I have done this, but everytime I add new method, which returns MyCustomStringCls object, in my new class, VC++ always add new #include with double quote. I'm fighting with it by manually delete that new include.
eg. For the new class, I want to have:
#include <mycustomstringcls.h>
BUT, VC++ always add this:
#include "..\Prj_MyCustomStringCls\MyCustomStringCls.h"
3. Every time I compile my new Project, it creates the MyCustomStringCls.OBJ and puts it in my new project folder. How do I tell VC++ compiler to skip creating OBJ for particular .H .CPP? And how do I tell linker to use the OBJ from MyCustomStringCls project folder?
Hope I don't confuse anybody. Please Help.
cheers,
Jo
|
|
|
|
|
consider creating LIB files for stuff you want to reuse.
A "lib" (library) is just a single file that contains one or more OBJ files. They are packaged into a single lib file, the linker can selectively pull obj files that are needed into your other projects....
To link this lib into other projects -- you'll need to update the settings on your project to generate a lib for a set of files. And also you'll need to create one or more H files to include in those other projects....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Peter,
I have never made LIB file. I'm reading the VC++ help on creating LIB, but I'm kinda of lost. Can you give me more pointer on how to do it, please?
cheers,
Jo
|
|
|
|
|
The only way I ever do it, is in the new project wizard. You'll have to do it that way. The process is mostly: compile c/cpp files to .objs, and the "librarian" combines those into a lib file.
Start at File|NewProject and look for a ".lib" type thingy in there.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
When you do VC++ DLL project.
The outcome will be a *.dll and a *.lib. The VC++ will automatically do it for you. If you are using Borland C++. You could specify to create a LIB project.
Basically, to use you lib. You just link it using you project configuration or do it in the code. And also, to include your *.h file (your header file)
hope this helps.
|
|
|
|
|
Thanx guys,
Following you guys' suggestion, I have successfully created .LIB(use VC++ Static DLL Project) and used it in my other project.
After understanding the procedure, it's actually extremely simple.
Jo
|
|
|
|
|
Hi all,
i am using MFC, i've created a Tree ctrl with the check boxes style.
how do i disable the checkboxes from the root item (the rest item should have it , but root should not)???
can any1 help?
thanks
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
For each node(Tree item) u need to set the style !
|
|
|
|
|
what do u mean? can u give an example?
|
|
|
|
|
Hello all
I want to write an application in which I would like to include context sensitive tooltip help messages. If I drag question mark symbol on a particular area, it has showup some tooltip help message.
If anyone knows how to do it, please help me.
Thanks for your help
Hari.
|
|
|
|
|
Hi
I’m trying to write a program that connects to AutoCAD 2002. I know that automation works with VARIANT data types. Also I found two nice MFC classes ‘COleVariant’ and ‘COleSafeArray’ to work with variants, but I could not find any class with an ‘operator []’ function that can access to elements of a variable of VARINAT type that has VT_ARRAY flag.
However if you have written some codes with VBA, you know that in VBA, with some simple codes like this you can access to elements of VARIANT:
Dim var As VARIANT
set var = MyAutoCADFunction ( … )
var(0) = 1
var(1) = 5
Do you know any predefined class in C++ to access this magic data type?
Thanks for your help
Babak Z.
|
|
|
|
|
Well, its not that bad yet, but its getting close.
Anyone ever make a SDI app with a Word.Document object as the Single Document and then try to open a new or existing doc in that same Document/View? It keeps telling me the document is already opened and locked for editing then I get an exception in malloc.c. If I open the document initially, its fine. Only when I try to open one the second time do I have problems.
Does anyone have any example code? I've gotten a lot of the code from the XOffice article here on CP, but its an MDI app.
I haven't worked with the Doc/View framework much either. Know where I can find more info on working with Documents in Doc/View?
Thanks!
Jason Henderson I bleed orange.
|
|
|
|
|
Hi,
Can I change the color of a single line in a list box ?
I have a list box that display a short list of lines and I want to color one of them in red, how do I do it ?
Shay
|
|
|
|
|
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 !
|
|
|
|