|
I have tried this with my VC++ 6.0 compiler and it works just fine!
I see no difference between the two secnarios! In each case you're using the copy constructor to instatiate the objects, even in your GlobalPrint function, the object is being passed by value and this implies that a new object is being constructed using the copy ctor. And the Copy Ctor is the default provided by the compiler!
Check your code... maybe you have something else that is causing the problem!
|
|
|
|
|
Does anybody know how to fix this error in Visual C++? I'm getting it on one of my functions in the class view. The function implementation exists and is in the header obviously. I tried rebuilding the class wizard file in hopes it would reassociate but it didn't work. It was working for a while then just stopped. Thanks for the help.
Jamie
|
|
|
|
|
There r two problem due to which I faced the same issues. First is that the Visual C++ compiler sometimes deletes the CPP file from the back.
Another is that in the funcion above there can be an extra closing bracket which causes the Wizard not to get the function.
Third problem can occur due to the type of parameters. That I can hopefully tell if I see the code.
|
|
|
|
|
I often play the game "Quake3". When I looked at the game-files I saw that there were also normal *.c files
here a piece of code from one of these files:
[code]
//===========================================================================
#include "game.h"
#include "match.h"
//entered the game message
MTCONTEXT_ENTERGAME
{
//enter game message
NETNAME, " entered the game" = (MSG_ENTERGAME, 0);
} //end MTCONTEXT_ENTERGAME
//initial team command chat messages
MTCONTEXT_INITIALTEAMCHAT
{
//help someone (and meet at the rendezvous point)
"(", NETNAME, ")", PLACE, ": help "|" meet ", TEAMMATE, " near "|" at ", "the "|"checkpoint "|"waypoint "|"", ITEM = (MSG_HELP, ST_NEARITEM);
[/code]
these files seem to be loaded at runtime by quake3.
Now my question?
How is it possible to load source-files at runtime and execute their code?
thanks in advance
|
|
|
|
|
To do this would require that the destination machine has a C++ compiler available to it. This Quake file looks to me like a data file, which is a different kettle of fish entirely.
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.
|
|
|
|
|
Carmack (the creator of Quake3) took LCC (a free open source C compiler) and used it as the base of an interpreter. The game code is loaded at startup and runs interpreted inside of a virtual machine inside of Quake3. It's a lot like Java but using C as the starting point. I think Carmack said it incurrs about a 10% performance hit which is acceptable and allows Quake3 to be ported easily to multiple platforms. Since the game logic is portable you can write a mod for the PC version and it will work automatically on Mac and Linux. This also allows him to exclude a lot of stuff from the language like access to local files on your PC. The game code runs in a sort of sand box with limited system interaction. You can also take the game logic code and compile it nativly on each system. For the PC you'd end up with a .DLL that's loaded at run time. You can get back your 10% speed drop this way but of course the DLL isn't portable to other platforms.
If you hunt down his .plan files you can read all about it.
|
|
|
|
|
Thanks for the detailed answer.
does it mean that these files are being compiled during gameplay with lcc?
Where can I find the .plan-files you mentioned?
How difficult do you think is it to realize something comparable in my own apps?
thanks
|
|
|
|
|
MFC code (or Win32 code that works in MFC) that checks if there is a CD-ROM installed!
/*
BETA
*/
|
|
|
|
|
Move through all drives and call the win32 function GetDriveType(DRIVE_CDROM) on each drive.
This should work.
Gero Gerber
|
|
|
|
|
DWORD dwDriveMask = GetLogicalDrives();
char szDir[4];
szDir[1] = TEXT(':');
szDir[2] = TEXT('\\');
szDir[3] = 0;
/* enumerate all logical, fixed drives */
for(int i=0; i<max_drives; dwdrivemask="">>= 1, i++)
{
// if logical drive exists
if (dwDriveMask & 0x01)
{
szDir[0] = TEXT('A') + i;
if (GetDriveType(szDir) == DRIVE_CDROM)
{
//do whatever you like to do
}
}
}
|
|
|
|
|
I have my program in the system tray or invisible from anything.
I want to press eg. F12 then for eg. a message box appears!
I know code for this when the app is in FOCUS! but when it's invisible... may be you
wrtiting in Word, and then you want to press F12 and TADA (Something happens!)!
MFC CODE!!
/*
BETA
*/
|
|
|
|
|
Try SetWindowsHookEx.
Afaik no MFC code to do this.
|
|
|
|
|
I am writing a program to customize your desktop using the Windows Plus! Settings. The only way I could find to do so is to change the registry settings manually and then do a ChangeDisplaySettings with CDS_UPDATEREGISTRY as a flag.
This 'tricks' the settings into being active. There's got to be a better way to do this! Anyone know how to change these settings more efficiently? Does there exist an API that allows you to refresh your display without making a "ChangeDisplaySettings" type change?
OS: Windows NT
Thanks!
|
|
|
|
|
I'm attempting to use a bitmap of a grey shaded sphere as sort of a stamp. I would like to draw to a CDC and PatBlt it to get a shaded sphere of the desired color. I'm running into problems with the number of colors displayed (about 20). I've played around with the CDC's palette but can't get any different results. Any suggestions?
|
|
|
|
|
Is it possible to insert a normal menu in a dialog window ??
I only got it working for an SDI or MDI application.
Thanx for any help,
Wolfgang
|
|
|
|
|
I had the exact same question. Someone sent me some of their code when they had to do the same thing. I never used it because I found a better way to make my app, but if you give me your e-mail, I can forward the code to you.
- John
- johnu@emersonprocess.com
|
|
|
|
|
I don't know exactly what you mean, but perhaps this helps:
Open the properties of your dialog and there select a menu-resource
which the dialog shall use. hth.
|
|
|
|
|
In the resourceView tab, Only select in the properties of the dialog, in the tab General, in the combo Menu, the menu that you want in your dialog.
Cheers
Carlos Antollini.
|
|
|
|
|
Thanks to everybody for helping me
Wolfgang
|
|
|
|
|
You know how if one selects multiple files in Explorer and then begins to drag them, an onscreen representation of those files is visible? I want to do something similar to that (not using a common control) an am trying to figure out the best method. I don't believe CreateCurosr will do, because one is limited to the system metrics for cursor size. Does anyone have an idea as to how the drag images larger than the 'standard' size are created in Explorer?
TW
|
|
|
|
|
Check CListCtrl::CreateDragImage or LVM_CREATEDRAGIMAGE if you play directly with API.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks for your input, but as I mentioned in the original post, I am not using a common control such as the List View. I know I'll have to use the API directly, I'm just looking for some non-MFC, non-Common Control ideas of where to start.
TW
|
|
|
|
|
Oops, sorry for the listview reference. Anyway, the easiest way is to follow the listview. It uses imagelist for drag'n'drop. You can 'manually' use imagelists, the functionality is exposed at the API level:
ImageList_SetDragCursorImage
ImageList_BeginDrag
ImageList_DragMove
ImageList_DragLeave
ImageList_EndDrag
ImageList_GetDragImage
Look at the 'Dragging Images' section in the 'Image Lists' at MSDN.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi,
Thanks for all of your reply about my question before. THANK YOU VERY MUCH!!!!
I try to keep posting my question, so that someone new can see this question and tell me how to fix it....
My major problem is: I have a program that was implemented in NT before and now want to transfer to Win9x. Everything is fine in NT, but in Win9x after the program has run for awhile, the output font change...include the system message box ( i know it because there is a message box ask me to terminate the program..haha..)......but it takes awhile to see the problem........when i do drawing....the problem happened immediately.....( not just draw a line......but a heavy drawing....).....cannot display colour....etc...
I posted this question in codeproject.....and many people told me it would be a GDI resource leak....but i don't know how to fix it....
Oh...give you more backgrounds......it is a program using MFC...........and has a CDC global pointer to let other files to do drawing too...(not in view.cpp only....).....I'm just used some liked CPen or CBrush...then selectobject.....then something liked LineTo or MoveTo.....
Thanks for your help.....
Richard
|
|
|
|
|
I posted this advice before, and I repeat it: you should get rid of the global DC. Just pass the CDC pointer from OnDraw to functions defined in other .cpp files.
Your GDI leaks are (most probably) caused by the fact that pens, brushes and other GDI objects can't be freed when selected into any device context.
void Leak(CDC *pDC)
{
CPen pen(...);
pDC->SelectObject(&pen);
}
CPen's destructor will call ::DeleteObject for you, but it will fail - your pen is still selected. You should re-select before exiting the function:
void TheRightStuff(CDC *pDC)
{
CPen pen(...);
CPen *oldPen = pDC->SelectObject(&pen);
pDC->SelectObject(oldPen);
}
Tomasz Sowinski -- http://www.shooltz.com.plC
|
|
|
|