|
How else to easily share code between projects? Right now I have MSVC create project subfolders of the c:\devel directory and I have a bunch of .cpp and .h files for common functions in a c:\classes directory. Whenever I need a frequently used class I just 'add files to project' from c:\classes and then #include "c:\classes\foo.h".
I've never worked on projects with other people before, but I can see that I should find another way to do it in case I have the opportunity to collaborate in the future.
|
|
|
|
|
Always use #include with relative path for example #include "..\classes\foo.h" , in this way you will be able to move the project with out any problems.
|
|
|
|
|
First, it's a good idea for everyone to have the same directory structure (if for no other reason that to serve as a common frame of reference). For instance, I have the following directory structure for ne of my projects:
\Johns Projects\ --- CommonFiles
--- DeMONS2\ --- D2CommonFiles
--- D2Config
--- D2Launcher
--- D2Scrub
With the directory structure described above, any project in the johns projects root can get to any header file in CommonFiles or D2CommonFiles, even if "Johns Projects" has another name or is copied (in its entirety) to another drive altogether
In your project settings dialog...
1) Click Project | Settings... in the Visual Studio menu.
2) On the left side of the dialog, you'll see a combo box labeled "Settings for:". Select "All Configurations".
3) On the right side of the dialog, select the "C++" tab, and in the combo box labeled "Category:", click the "Preprocessor" item (last one in the list).
4) In the edit field lebaleled "Additional Include Directories:", and your relative path. Using the directory structure example above, for all of the projects in the DeMONS2 folder (D2Launcher, D2Config, and D2Scrub), I used "..\..\CommonFiles,..\D2CommonFiles".
At this point, all you have to do is #include the filename itself without worrying about the path at all.
In order to share a project, everyone will find it much simpler to just have identical directory structures.
|
|
|
|
|
Hi,
I have a graphical MDI application, it displays Bitmaps, draws points, lines,...
All the data is in my CView class.
Can I use serialization from CView? if yes.. How??
thanks
Ehsan Behboudi
|
|
|
|
|
I've been trying to do this for longer than I care to admit and every implimentation I try reactivates the last window that was active, even if my mouse is a long way away from it, over another view entirely.
Please help, or alternatively please send me a nice long piece of rope, and instructions on how to tie a noose.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Try this:
1) Create a base view class that all ytour other views derive from.
2) Create a member variable of type CRect (we'll call it m_windowRect)
2) Override OnSize()
3) In the OnSize() function, insert the following code:
GetWindowRect(&m_windowRect);
ClientToScreen(&m_windowRect);
4) Override the OnMouseMove() function
5) In the OnMouseMove() function, insert the following code:
if (GetFocus() != this)
{
ClientToScreen(&point);
if (m_windowRect.PtInRect(point)
{
SetFocus();
}
}
I havn't tried any of this myself, but it should work with minimal tweaking.
|
|
|
|
|
Thanks, but I've tried it and apart from keeping the rect as a member variable, it's pretty much where I started out, and the same problem is evident - the last view highlighted activates instead of the one the mouse is over. I've gone so far as to iterate through all my views and grab their positions, but no matter what I do, the last view highlighted gets activated...
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Have you tried using WindowFromPoint() ?
Neville Franks, Author of ED for Windows
http://www.getsoft.com
|
|
|
|
|
I love you, and I want to bear your children.....
I spent half a day searching the MSDN for this API function - thanks, I'll give it a try.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
OK.. I am drawing a graph in my view and then want to save the point array in my document. Problem arises when i serialise.. During run, when I try to save it, he save window comes up fine.. but the graph is erased when my view is redrawn after closing the save dialog box. I did put invalidateRect in my OnDraw function .. but didn't work!!
I also added a call to UpdateAllWindows in the overriden Serialize function for my CDocument.. but still does not work!!!
also, anyone knows how to obtain a pointer to the current view from CDocument??
It is what we choose to be that makes us what we are, far more than our abilities.
-J.K. Rowling
|
|
|
|
|
To get a pointer to the View from your document:
CFrameWnd *pFrameWnd = (CFrameWnd *)AfxGetMainWnd();
ASSERT (pFrameWnd != NULL && pFrameWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd)));
pFrameWnd = ((CMDIFrameWnd *)pFrameWnd)->GetActiveFrame();
CMyView * pView = (CMyView*)pFrameWnd->GetActiveView();
This is a generic method - it works from anywhere, but only works if your document is attached to the active view.
Your other problem is a mystery to me. Could you post some code to show what you're doing ?
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
How can I in get MX Records from DNS when I know only hostname or ip of main server?
Please Reply to my email:piopawlu@interia.pl
Piotr Pawluczuk
|
|
|
|
|
Does anyone know how to use DeviceIoControl()??? I read the document from microsoft and MSDN...but still don't know how to use it.....can anyone give me a small tutorial about this function?
Thanks
|
|
|
|
|
Hi All,
I'm beginner in VC++ and I have VC++ 6.0. I have this problem now.
How I create user items in system menu of my applications ?
Thanks,
Libor
Libor Matejka
|
|
|
|
|
Please explain ? If you want to add items to the menus, use the resource editor to create items and then Class Wizard to create functions linked to the item ID's. If that is not what you mean, please re-state the question.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Thank you for your answer, but I mean SYSTEM menu. This is menu under Application icon in caption bar of application.
Libor Matejka
|
|
|
|
|
Create a sample Dialog based application, then look at the implementation of the OnInitDialog member function. In here you will see how the About Box menu option is added to the System Menu. From this you should be able to add almost anything you like to the System Menu.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Thank you,
this is very simle and fast
Libor Matejka
|
|
|
|
|
I send when I click on a static text (CLabel) a message to my main app that I intercept with the OnNotify() routine.
(I don't have the listing right now this explain the aproximate syntax sorry bout this)
But I noticed annoying long delay (1 second) before I can re click on the static
should I return 0; once I get the message ?
For now I alway return to the normal OnNotify procedure
Onnotify( wparam, lparam ...)
{
switch(proc)
{
case:
some code;
return 0; <---For now I just have a "BREAK;" here
}
return Onnotify();
}
Many thanks
|
|
|
|
|
I have declared a function called solve like this :
double Solve(double (pFn) (double), double pX);
Now I don't know how to use this function with for example pFn = 2*X-1...
the following code doesn't work :
lSoluce = Solve( (2*X-1) (X), X) ????
Thank in advance for your help.
Leo
|
|
|
|
|
Hi !
if pFn - is a pointer to a function that date a double and returns double your code should be change into:
iSoluce = Solve(pFn, X);
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
|
|
|
|
|
2*X-1 is a statement not a function. A function would be something like sqrt(). The documentation for qsort() usually has a good example of function passing.
|
|
|
|
|
Hi,
I wrote a DLL with an exported class containing a template method.
When using this DLL, I got a linker error on this method.
How to correct this in VC++ ?
Thanks a lot
Nicolas
|
|
|
|
|
I am trying to generate a continuous tone at a desired frequency. I cannot use Beep() because once the tone begins, I need to do other processing. I need it to continue until I stop it from elsewhere in my code or send another frequency. Beep() does not return until the specified duration has elapsed. Any suggestions? I have looked at PlaySound and Direct Sound, but these appear to be much more complicated solutions than should be required to play one tone.
Thanks.
|
|
|
|
|
Windows has no APIs for generating a continuous tone.
If you only need one frequency, or at most a small set of frequencies, you should probably create .wav files and use PlaySound to play the specific file you need, with looping turned on. If you need arbitrary frequencies, you're getting into hairier territory.
|
|
|
|