|
You could just call the menu handler directly - OnFileNew() . The other way (as you suggest) is to send a WM_COMMAND message with the ID_FILE_NEW command ID to your main window (not to the document directly).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello!
What are there differences between Win32 and MFC project in Visual C++ project types?
(other than we can use existing MFC classes in MFC project)
is it better that I create my project with Win32, for more security? or,
are they the same security?
please help me.
Zo.Naderi-Iran
|
|
|
|
|
zoncpp25 wrote: (other than we can use existing MFC classes in MFC project)
erm... well, the main difference with an MFC project would be that it supports MFC, obviously.
zoncpp25 wrote: is it better that I create my project with Win32, for more security? or,
are they the same security?
An MFC project is a Win32 project wrapped in a class structure that makes it easier to use. I don't see how there can be any security risk in using a framework that generates Win32 code at the end of the day. What sort of security are you worried about ? For what reason ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
security for debug and trace in an exe file that created with vc++
Zo.Naderi-Iran
|
|
|
|
|
That sounds like you have no need of security at all, unless you mean security in the sense of making your program uncrackable ( if it has some sort of licencing scheme ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I have an application(MDI) that starts out with all child window closed. Therefore, on start up, I will see the default IDR_MAINFRAME menu bar.
In CMDIApp::InitInstance, i have also created my own DocTemplate and added. This template is meant to be opened through an option I have created in IDR_MAINFRAME.
I tried to open the new view through the menu by usign CreateNewFrame of CDocTemplate, but my compiler is telling me that theApp is an undeclared identifier.
Can anyone tell me I can call my new view through IDR_MAINFRAME, or point me to where I can get a solution? Thanks!!!
|
|
|
|
|
I recently wrote a simulator for a card game, and I wanted people to have the ability to extend the default AI by writing their own. I set it up so that people could write a DLL and the simulator would look for it. However, when I run the simulator using the DLL, it crashes at the start of the 2nd hand. The wierd part is that if I copy/paste the code from the DLL to the actual simulator, it runs fine.
The problem occurs when I try to access (not dereference) a pointer which is passed to the DLL's function.
This is the code I'm using to access the dll:
string dllName = "BotAI.dll";<br />
const char* functionName = "?getBotDecision@@YA?AVAction@@AAVHandHistory@@PAVStatsDB@@_N@Z";<br />
HMODULE module = LoadLibrary(dllName.c_str());<br />
Action (*theDllFunc)( HandHistory&,StatsDB*,bool) = 0;<br />
<br />
if (!module)<br />
{<br />
cout << dllName << " not found or load failed.\n" << endl;<br />
Sleep( 10000 );<br />
exit(1);<br />
}<br />
<br />
theDllFunc = (Action (*)(HandHistory&,StatsDB*,bool))GetProcAddress(module, functionName);<br />
Action result(ACTION_Fold);
if (!theDllFunc)<br />
{<br />
cout << functionName << " not found inside " << dllName << " or load failed.\n" << endl;<br />
Sleep(10000);<br />
}<br />
else<br />
{
result = theDllFunc(hand, stats, verbose );<br />
}<br />
if (!FreeLibrary(module))<br />
cout << "error releasing the module loaded from " << dllName << endl; <br />
return result;
The strange part as I said is that it runs fine for 1 hand using the DLL for all 10 players, then hand #2 starts and it crashes while accessing a function call to StatsDB. However if I put all the code into the actual simulator and comment out all the above code, it works fine.
Note that I'm compiling the DLL with the same compiler as the simulator, and am using the same static library for the DLL as for the simulator. Also, it accesses the DLL fine for the first hand, and only crashes on the 2nd hand. Each player accesses the DLL only once per hand, so I am inclined to think it is something to do with accessing the DLL twice from the same player...or something along those lines. As I've said, it works for the entire simulation if I just copy/paste the code from the dll to the simulator, and I've done a lot of simulator testing, so that's not what's wrong. Any ideas?
|
|
|
|
|
I can't see any obvious mistakes. Can you include more details of the crash? ie. The exact line it crashes, the exception type and a stack trace of the crash is a bare minimum.
Steve
|
|
|
|
|
Hi Steve,
I just spent a long while debugging, and it seems that the app is crashing when I call clear() on an stl map which is a member variable of an object which is a member variable of StatsDB. Not sure at all why that it's happening here.
The message I get while debugging is: Unhandled exception at 0x1007619d (BotAI.dll) in Simulator.exe: 0xC0000005: Access violation reading location 0xcdcdce06.
The actual line it dies is:
void _Erase(_Nodeptr _Rootnode)<br />
{
for (_Nodeptr _Pnode = _Rootnode; !_Isnil(_Pnode); _Rootnode = _Pnode)<br />
{
_Erase(_Right(_Pnode));<br />
_Pnode = _Left(_Pnode);<br />
this->_Alnod.destroy(_Rootnode);
this->_Alnod.deallocate(_Rootnode, 1);<br />
}<br />
}Line 3 of the above pasted segment.
|
|
|
|
|
I can't see a call to clear . I not sure if the problem can be diagnosed from the code you’ve provided. Perhaps if you show the code which calls clear someone will notice a problem.
Steve
|
|
|
|
|
is BotAI your dll? if yes, that that is not the way to export and use a function from a DLL.
That name you are using i.e ?getBotDecision@@YA?AVAction@@AAVHandHistory@@PAVStatsDB@@_N@Z is a result of namemangling done by the C++ compiler and it may change if you change the compiler or change the function signature.
Best way is to use dllimport dllexport directivies so that the compiler does not do any name mangling to the function.
Read more on how to import/export functions from the dll.
-Prakash
|
|
|
|
|
|
thanks,
but its not me who wants it
-Prakash
|
|
|
|
|
Laxman9 wrote: FAILURE is the first step towards SUCCESS
FAILURE is the last step towards the PINK SLIP
Jesus Loves <marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" style="background:#99ccff;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Defeat is temporary but surrender is permanent
--Jesus is Lord
|
|
|
|
|
here is the sample..code for DLL
//header file dllexportsclass.h//
#ifdef DLLEXPORTSCLASS_EXPORTS
#define DLLEXPORTSCLASS_API __declspec(dllexport)
#else
#define DLLEXPORTSCLASS_API __declspec(dllimport)
#endif
/ This class is exported from the DllExportsClass.dll
class DLLEXPORTSCLASS_API CDllExportsClass {
public:
void show();
CDllExportsClass(void);
// TODO: add your methods here.
};
extern DLLEXPORTSCLASS_API int nDllExportsClass;
DLLEXPORTSCLASS_API int fnDllExportsClass(void);
//c++ file//
include the above header file
/ This is an example of an exported variable
DLLEXPORTSCLASS_API int nDllExportsClass=0;
// This is an example of an exported function.
DLLEXPORTSCLASS_API int fnDllExportsClass(void)
{
::MessageBox(NULL,"function","",0);
return 42;
}
// This is the constructor of a class that has been exported.
CDllExportsClass::CDllExportsClass()
{
return;
}
void CDllExportsClass::show()
{
::MessageBox(NULL,"Hello Dll","CDllExportsClass",0);
}
and include the header file into the project where u want to use the DLL.
Thanks and Regards
Laxman
FAILURE is the first step towards SUCCESS
-- modified at 0:30 Monday 30th January, 2006
Thanks and Regards
Laxman
FAILURE is the first step towards SUCCESS
|
|
|
|
|
In versions of VC++ gone by, if you clicked on a Windows identifier, e.g. WM_PAINT, and pressed the F1 button then the relevant Windows API help would be displayed.
I'm now using Visual Studio .NET 7.1, and pressing F1 on any Windows identifier always displays help for MFC instead.
If I'm using MFC then that's fine, but most of the time I'm not, so it's rather annoying. Does anyone know how to get the old-style behaviour back?
Cheers
|
|
|
|
|
|
OK, I set the filter to no filter in the help index window and... it made absolutely no difference. Do I need to set the filter somewhere else?
|
|
|
|
|
|
> Can you be more specific about what's happening.
1. Open a .CPP file in Visual Studio .NET 2003.
2. Type WM_PAINT.
3. Click once on the word WM_PAINT.
4. Press the F1 button on your keyboard.
5. Observe as the help for CWnd::OnPaint is displayed. In previous versions of VC++ the help for the WM_PAINT message would appear, which is the behaviour that I want.
|
|
|
|
|
Uakari wrote: Observe as the help for CWnd::OnPaint is displayed. In previous versions of VC++ the help for the WM_PAINT message would appear, which is the behaviour that I want.
If you go scroll down you will have a link for WM_PAINT .
Or
You can set the filter to Platform SDK .
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#99ccff;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Defeat is temporary but surrender is permanent
--Jesus is Lord
|
|
|
|
|
> If you go scroll down you will have a link for WM_PAINT
I'm aware of that. You can also select the various subjects that the word links to in the Dynamic Help window. But that's not as good as going straight to the help I want, which is what VC++ 6 did.
> You can set the filter to Platform SDK
The filters make absolutely no difference to the F1 help for me.
What version of Visual Studio are you using?
I've come across http://msdn2.microsoft.com/en-us/library/f88ctah3.aspx[^].
If there's a more direct route to filtering the F1 help then I'd like to know about it, otherwise I'll have a go at that later.
|
|
|
|
|
Uakari wrote: What version of Visual Studio are you using?
I am using VS2003
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#99ccff;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Defeat is temporary but surrender is permanent
--Jesus is Lord
|
|
|
|
|
Hi,
I need to write an application that converts a Borland Interbase Database to an Access/SQL Server database.
My question is - after I have the source and destination database paths, what steps does my application have to take in order to actually convert the data?
I am using Visual C++ 2003.
|
|
|
|
|
open, read the source with source database syntax then open, write to the destination with its own format.
i guess you wanna copy from one to another right? where do you "convert" something here?
VuNic
|
|
|
|