|
Cool! Thanks for saving me the time
Cheers!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Mark Salsbery wrote: String ^MyText = "Blah"
Hi, What this "^" cap symbol represents? where it is useful?
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Its a handle. Used like a pointer for pointing to managed objects on the managed heap. Its pretty fundamental to writing managed code with C++/CLI.
|
|
|
|
|
Hello,
I have never programmed before and I am trying to teach myself C during downtimes at work. The first program that I did is the Hello World program. I am using the Compiler Dev C++ and when I run the program it closes immediately and I don't the chance to see it. Can Anyone help me. This is what I have for code:
#include <iostream>
using namespace std;
int main (void)
{
cout << "Hello World!";
return 0;
}
Steve Vondras
Red Lake Nation
MIS Tech
svondras@redlakenation.org
|
|
|
|
|
I am going to go out on a limb here and say that you mean that a console window displays then immediately closes. I believe that you need a getch() before the return.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
Thanks for the quick reply, it worked right away. I have seen the code for this hello world in several different places, but I have never seen the getch(). Why is that?
Steve Vondras
Red Lake Nation
MIS Tech
svondras@redlakenation.org
|
|
|
|
|
The code as you wrote in your original message did a cout and then returned. It did that. Returning meaning that the program was finished so that the window closed. Getch() simply waits for keyboard input before the program continues.
If you were to run your program from a command prompt, you would not need the getch().
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
Like Wes said, it closes right after running if it is a console app. If you run it from a Dos box, it'll stay there with the Dos prompt when done.
Good luck on learning C++. Dev C++ is nice, have you looked at the Express Editions of C++/C#?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
If you mean Visual Express, yes I have. I am thinking of getting a version of it if the price is right. Thanks for the response.
Steve Vondras
Red Lake Nation
MIS Tech
svondras@redlakenation.org
|
|
|
|
|
Red Lake wrote: I am thinking of getting a version of it if the price is right.
You should. I think it is still FREE
There was a way to get Visual Studio Standard Edition for "free" ( just pay the shipping and handling ) from Microsoft by watching two of their labcasts. I think it expired at the end of June. I'd keep an eye out for that.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I need some help...
I have a dialog based app and I want to register the (window) class. So many question have I.
1) where do I put my code for registering the class?
2) do I use RegisterClass, RegisterClassEX, AfxRegisterClass, AfxRegisterClassEx?
3) REASON: interprocess communication using Windows Messaging
I have some legacy code that i'm looking at for an example, but it is a Doc-View type and it appears easier as it has the registeration inside the PreCreateWindow( ) function - see below
Thanks,
Johnny
<br />
#define MYAPPWINDOW_CLASSNAME _T("MyOwnWindow") //window class name<br />
<br />
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)<br />
<br />
WNDCLASS wndcls;<br />
HINSTANCE hInst = AfxGetInstanceHandle();<br />
<br />
if( !(::GetClassInfo(hInst, MYAPPWINDOW_CLASSNAME, &wndcls)) )<br />
{<br />
if( ::GetClassInfo( hInst, cs.lpszClass, &wndcls ))<br />
{<br />
wndcls.lpszClassName = MYAPPWINDOW_CLASSNAME;<br />
wndcls.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDR_MAINFRAME));<br />
if( !AfxRegisterClass(&wndcls) )<br />
{<br />
AfxThrowResourceException();<br />
return FALSE;<br />
}<br />
}<br />
else<br />
{<br />
AfxThrowResourceException();<br />
return FALSE;<br />
}<br />
}<br />
<br />
cs.lpszClass = MYAPPWINDOW_CLASSNAME;<br />
|
|
|
|
|
As a general rule, use the Afx functions in an MFC app and use the API functions in a Win32 app.
You can put the call anywhere as long as it gets called before attempting to create a window of
the registered class. PreCreateWindow() is fine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
I am still lost and now frustrated (with MSDN documentation on the matter.)
What I have is a dialog based app and inside my OnInitDialog(), I have put what is the beginnings of registering my window class..
When I do this, i get the runtime "warning" that "A required resource was unavailable." (i trace this to the second call to ::GetClassInfo() as I don't know how to properly supply the 2nd parameter.)
<code>BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
WNDCLASS wndcls;
HINSTANCE hInst = AfxGetInstanceHandle();
if( !(::GetClassInfo(hInst, MYOWNAPP_CLASSNAME, &wndcls)) )
{
if( ::GetClassInfo( hInst, NULL, &wndcls ))
{
wndcls.lpszClassName = MYOWNAPP_CLASSNAME;
if( !AfxRegisterClass(&wndcls) )
{
AfxThrowResourceException();
return FALSE;
}
}
else
{
AfxThrowResourceException();
return FALSE;
}
}
return TRUE;
}
</code>
|
|
|
|
|
I don't think you need the second call. Even if you did, using NULL as the second param isn't
documented.
If the first call fails, go ahead and register the class.
Actually, you can just call AfxRegisterClass(). MFC will check if it's already registered
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. I have a file with the following format:
DEVICE : TK65603
WAFER : 08
LOT : 006X
52 NULL 20 NULL 31 NULL <carriage return="">
52 NULL 18 NULL 26 NULL <carriage return="">...for 1000 records.
I am trying to set up a FileStream to read the data from this file for processing.
FileStream^ fileStream = gcnew FileStream(strFilePath, FileMode::Open);
StreamReader^ streamReader = gcnew StreamReader(fileStream);
The following reads the first threee lines just fine.
strDeviceName = streamReader->ReadLine();
strWaferNumber = streamReader->ReadLine();
strLotNumber = streamReader->ReadLine();
But then if I try to read the next line the command terminates at the NULL character and all I have in my variable is the first of the three fields (52). I have tried some variations of BiaryReader also. What approach would anyone recommend to work around this issue?
Buck
|
|
|
|
|
Are you still having trouble with this?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
No, I'm just reading the file one character at a time and checking for nulls. Seems to be working fine.
Thanks.
Buck
|
|
|
|
|
Sounds like you have it right now. Any problems let me know
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
hello,
how to declare a globale variable for 2 or all methodes ?
|
|
|
|
|
Is there a good reason you need to use global variables in a C++/CLI application?
If so, you can simply define a variable in any CPP file, outside of any function or class
declaration:
// Global int
int MyGlobalInt = 0;
To access the global variable from another CPP module, use "extern":
// MyGlobalInt exists in another module
extern int MyGlobalInt;
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Hi, everyone,
Postfix p;
char *postfix = p.convertToPostfix(infix);
//p.convertToPostfix(infix) returns a pointer
I would like to write a method in Postfix class to overload the "=" operator so that the left pointer gets a deep copy of the right pointer(returns from a method in the class).
How do I write it?
Thanks.
|
|
|
|
|
Here's one way (you'll have to do the actual deep copy yourself since I don't know the details of
your class - my sample implementation just demonstrates a possible deep copy scenario):
class Postfix
{
protected:
someclass *pSomeClass;
public;
Postfix* operator=(const Postfix *Src);
};
Postfix *Postfix::operator=(const Postfix *Src)
{
if (this->pSomeClass)
delete this->pSomeClass;
this->pSomeClass = new someclass(...);
... copy Src->pSomeClass to this->pSomeClass ...
return this;
}
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
hi;
i would add in listView, for this i need to declare an array of string:
String *subItems[] = new String*[10];<br />
subItems[4]="1";<br />
subItems[2]="2";<br />
subItems[3]="3";<br />
subItems[1]="4";<br />
subItems[5]="5";<br />
<br />
<br />
ListViewItem* itm = new ListViewItem(subItems);<br />
listView1->Items->Add(itm);
but it didn't work,
i try for :
<br />
cli::array<String ^, 1> ^ tabChaine = gcnew cli::array<String ^>(3);<br />
tabChaine[0] = "Element 1";<br />
tabChaine[1] = "Element 2";<br />
tabChaine[2] = "Element 3";<br />
<br />
this->listView1->Items->Add(tabChaine);
=> there are error :Error cannot convert parameter 1 from 'cli::array<type,dimension> ^' to 'System::String ^'
Thank you verry mutch
|
|
|
|
|
You need to use the .NET framework classes documentation.
There's no ListView.ListViewItemCollection.Add() overload that takes an array of Strings as a
parameter.
You could add one string at a time:
listView1->Items->Add("Element 1");
listView1->Items->Add("Element 2");
listView1->Items->Add("Element 3");
or maybe use ListView.ListViewItemCollection.AddRange().
Mark
-- modified at 16:07 Sunday 15th July, 2007
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
By the way, your code is wrong as far as creating an array of strings! It should be:
<br />
array<String^>^ tabChaine = gcnew array<String^>(3);<br />
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|