|
Try this :
RecalcLayout();
CRect rect;
m_wndToolBar.GetWindowRect(&rect);
rect.left++;
DockControlBar(&m_wndToolBar2,AFX_IDW_DOCKBAR_TOP,rect);
|
|
|
|
|
Thanks, Nishant, for the help. However, the rect parameter is apparently ignored. This always docks the 2nd toolbar under the first one against the left frame border.
|
|
|
|
|
I'm just learning threading and have a question about the safety of calling functions from threads. This is more of a C question rather than C++ but here goes...
What would happen to this function if it was called from thread 01 with arguement 100, then 5 seconds later thread 02 calls it with arguement 101?
Would each thread get back the value it passed or would gremlins creep in and mess everything up?
int myFunction(int myInt)<br />
{<br />
int a = myInt;<br />
Sleep(10000);<br />
return a;<br />
}<br />
BTW... Yes i can try this myself and it seems to work for trivial examples... However is there any reason why it would/should/could not work.
Many thanks,
Daniel
-- modified at 18:40 Sunday 27th November, 2005
|
|
|
|
|
of course it works! Thread safety refers in general to sections of code accesing the same data. So in your case the data int a is internal to the function, thus, each instance of the function (each thread) will be operating on internal data. Your example wouldn't be thread safe if it were accessing let's say a variable int globalA defined outside the function such as:
<code>
int globalA;
int unsafeMyFunction(int myInt)
{
globalA = myInt;
Sleep(10000);
return globalA;
}
</code>
The example above is a quite simple one and you can find more information on the web about concurrency and race conditions and the ways to handle these situations and of course, the issues that arise from trying to avoid them.
|
|
|
|
|
I have a class and i when it comes to certan error, i want my class to close entire process. Can anybody help. I am using VS2005.
|
|
|
|
|
#include <stdlib.h>
if(errHasOccured){exit(0);}
|
|
|
|
|
#include "stdlib.h" //this should be in triangle brakets
if(errHasOccured){exit(0);} //or substitute your error code where the zero is
|
|
|
|
|
I have tryied that and it doesn't work. I am asking for on MC++ forum, so i expect to get managed anser. i have also try using ExitProcess command, but when i include windows.h my compiler complains abaut a lot of errors, so this option is out.
ps: you coud just modify your post and click "Ignore HTML tags in this message (good for code snippets)"
|
|
|
|
|
Is this a console app or a GUI app? In a console app, you could just return from main, while in a GUI app, you could just close the main Form.
|
|
|
|
|
Also look at System::Environment::Exit
|
|
|
|
|
Thanks That worked. If yu must to know my app is GUI based and my class is outside of any Form.
|
|
|
|
|
Saksida Bojan wrote: Thanks That worked. If yu must to know my app is GUI based and my class is outside of any Form.
For Windows Forms apps, Application::Exit would be a better option.
|
|
|
|
|
That one was without any effect.
|
|
|
|
|
hey folks,
I'm trying to build my project and I get the following error message:
Error 4 error C3149: 'System::String' : cannot use this type here without a top-level '^' c:\documents and settings\john\my documents\visual studio 2005\projects\rtdispatch\rtdispatch\DBConnection.h 11
Here is the entire file:
<br />
#include "StdAfx.h"<br />
#include "DBConnection.h"<br />
<br />
using namespace System;<br />
<br />
DBConnection::DBConnection(void){}<br />
<br />
static void DBConnectToDataSource(String connectString){}
static void DBDisconnectFromDataSource(void){}<br />
Whenever I attempt to use a String, I get this error message.
Do I need to instantiate an a String object or something. If so this is not what I'm looking for. I'm trying to simpl declare and define a C style char *
Any info would be great.
Thanks,
John
|
|
|
|
|
System::String does not support stack semantics, so you need to use a String^ instead of a String.
|
|
|
|
|
Thanks so much Nish, works perfectly now, I appreciate it
Thanks,
John
|
|
|
|
|
I just upgraded to VS2005.
Look This Sample:
namespace CoreSetting
{
public __gc class CoreSetting
{
public: bool bFirstRun;
public: XmlDocument ^ docXml;
public: CoreSetting()
{
}
};
}
and it gives me error:
Error 1 error C4980: '__gc' : use of this keyword
and if i remove __gc then there it teels me:
Error 1 error C3265: cannot declare a managed 'docXml' in an unmanaged 'CoreSetting::CoreSetting'
ps: i dont want to use /clr:oldSyntax
|
|
|
|
|
|
Thank you, now i can program with new sysntax style
|
|
|
|
|
Can anybody point me to any good tutorial for .NET framework 2.0 on C++.
-- modified at 10:42 Friday 25th November, 2005
|
|
|
|
|
Saksida Bojan wrote: Can anybody point me to any good tutorial for .NET framework 2.0 on C++.
You need to study the C++/CLI syntax and semantics. Once you do that, using .NET 2 features should be a natural side effect.
|
|
|
|
|
Hi,
Im looking for the source code of the Eliza (The a.i program written by Joseph Weizenbaum) program, written in c++. Would be great if someone would reply with the source code......... Thanks a Bunch
Kiddo
|
|
|
|
|
Sorry, but have you ever heard of Google? BASIC Source
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi all
I've been teaching C++ for about 10 years (unmanaged using Borland Compilers), and for the first time this year I am teaching managed C++ using MS Visual Studio .NET. The first part of the course concentrates on procedural programming in a console environment, and one of the topics is writing / reading to text files (which is OK), and printing data to a printer (local LPT1 printer). In unmanaged code, I would write is as follows :
#include
void main(void)
{
char data[80];
ifstream infile;
ofstream printer;
infile.open("TEST.TXT", ios::in);
printer.open("PRN");
while (infile)
{
infile.getline(data,80);
if (infile)
{
printer << data << "\n";
}
}
};
However, I cant find a simple way to set up a stream to the local printer in a console based environment using managed code. The file handling part is fine, and would look as follows :
// Filein1.cpp
#include "stdafx.h"
#using
using namespace System;
using namespace System::IO;
int _tmain()
{
String *record;
StreamReader * fileIn = File::OpenText(S"Test.txt");
// Need to set up stream to printer here
while ((record = fileIn->ReadLine()) != 0)
{
Console::WriteLine(S"{0}",record); // need to replace with output to printer stream
}
Console::ReadLine();
fileIn->Close();
return 0;
}
Can anyone help me fill in the gaps ?
Many thanks
Simon Cornish
Simon Cornish
|
|
|
|
|
HELLLLOOOOOOOOOOOOOOOOOOOOOO!!!!! PLEASE........!!!!!!!
|
|
|
|