|
DaFrawg wrote:
I guess it's better to replace
using std::string;
by
using namespace std;
Nope, that's rubbish. That scopes all of namespace std unnecessarily, if std::string is all that is wanted.
DaFrawg wrote:
or else the class 'string' will not be available (it's 'std::string', not 'std::string::string').
You're completely wrong here. I don't even know how you ended up with this theory.
DaFrawg wrote:
LPCTSTR is not really a macro:
#define LPCTSTR const char*
(or something like that, I probably forgot the As and Ws for ANSI and Unicode)
That is, by definition, a macro, just a parameterless one.
Thanks for playing tho.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
Nope, that's rubbish. That scopes all of namespace std unnecessarily, if std::string is all that is wanted.
Sorry, I didn't know that there was something like "using Declaration".
MSDN: "The using declaration introduces a name into the declarative region in which the using declaration appears."
Christian Graus wrote:
That is, by definition, a macro, just a parameterless one.
Tell that the people who claim they are called "symbolic identifiers".
|
|
|
|
|
DaFrawg wrote:
Sorry, I didn't know that there was something like "using Declaration".
NP. Glad to help you learn somethng new. The using declaration is better because you control what gets pulled into global scope. Otherwise, you have no real idea.
DaFrawg wrote:
Tell that the people who claim they are called "symbolic identifiers".
They just say that because macros are evil, but a rose by any other name....
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
you forgot:
Technically speaking, yes. Since STL and Unicode are not part of my normal development paradigm, I don't often think of them.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
*grin* To be honest, Unicode has never figured highly in my thoughts either. But I was always an STL junkie
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I am new to C++ I have created a member function and I am trying to access a control in the function.
The function:
void CDialog1Dlg::PutCh()
{
char X;
while ((X=GetDataOut()) != 0)
{
m_Edit1= m_Edit1 + X;
UpdateData(FALSE);
}
}
I am tring to call this function from the same class.
This gives me an error:
static void DataRead(void)
{
char a;
BOOL fWaitingOnRead = FALSE;
while (1)
{
a=0;
Status = ReadFile (hnd, &a, 1,&rCount, NULL);
if (Status && rCount > 0)
{
if (a)
{
if (a == 13)
{
PutDataIn('\r');
PutDataIn('\n');
}
else
PutDataIn(a);
}
}
CDialog1Dlg::PutCh() <------- I get an error here
Sleep(1);
}
}
Without adding the CDialog1Dlg::PutCh() line to the function the code compiles fine. My question is how do I call this member function from another function inside the class. I would just like to be able to access m_Edit1 control.
Thanks,
|
|
|
|
|
It's best practice to tell people the error you are getting. In this case, you're trying to call a method that is not static, and therefore requires an instance of your class. If you make your other method static, you should be fine ( assuming GetDataOut is static ). Otherwise you need to create a new instance of the class, and use that to call the method.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
You have defined PutCh() as a class member function and you're calling it from a function not related to that class.
PutCh() only makes sense in context of some object that you created from your class. You can't just call PutCh() from anywhere because what will the variable m_Edit1 represent? You may have 10 objects each with its own copy of m_Edit1, which one will PutCh() modify?
So you need to specify the object name when you're calling that function
MyObject.PutCh();
|
|
|
|
|
Does DataRead need to be static? If not remove the static and the program should compile fine.
John
|
|
|
|
|
I have a main class Dialog1.cpp:
That instantiats the diolog class:
CDialog1Dlg dlg;
dlgptr = &dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
I then have a dialog class called Dialog1Dlg.cpp. This class has the functions I wish to call.
I have removed the static from the read data function.
I have these functions:
char GetDataOut()
{
char Data;
if (Start == End)
return 0;
Data = strData[Start];
if (++Start >= Max)Start = 0;
return Data;
}
void PutDataIn(char X)
{
int TEnd = End;
if(++TEnd >= Max) TEnd = 0;
if(TEnd != Start)
strData[End] = X;
End = TEnd;
}
void DataRead(void)
{
char a;
while (1)
{
a=0;
Status = ReadFile (hnd, &a, 1,&rCount, NULL);
if (Status && rCount > 0)
{
if (a)
{
if (a == 13)
{
PutDataIn('\r');
PutDataIn('\n');
}
else
PutDataIn(a);
dlg.PutCh(); <--- this is undefined
}
}
Sleep(1);
}
}
DataRead is a thread that I spawn at init.
I have tried to create a new object of the same type but UpdatData(FALSE) gives me a runtime error.
I know I am not doing something, I just do not know what.
Any ideas?
Thanks,
|
|
|
|
|
dlg.PutCh() is undefined because dlg is not defined in DataRead(). I did not know you were using threads.
There is an easy solution. Post your code that creates the thread and I will give you some help. Part of the solution is returning DataRead back to a static member function but with passing a pointer to the class.
In your header file for CDialog1Dlg add this to the CDialog1Dlg class:
static unsigned DataRead(LPVOID lParam);
Now in your CPP file:
unsigned CDialog1Dlg::DataRead(LPVOID lParam)<br>
{
CDialog1Dlg* pThis = reinterpret_cast<CDialog1Dlg*>(lParam);
pThis->PutCh();
return 0;
}
John
|
|
|
|
|
void CDialog1Dlg::PutCh()
{
char X;
while ((X=GetDataOut()) != 0)
{
m_Edit1 = X; <-------------Error when I get here (see below)
UpdateData(FALSE);
}
}
First-chance exception in Dialog1.exe (MFC42D.DLL): 0xC0000005: Access Violation.
Did not get this before.
|
|
|
|
|
Hello,
I have a SDI project, where from a menu selection I create many modeless dialog Windows. I dont have focus on any particular user dialog box, but if I happen to press the Enter key, the Window closes...but the program thinks it is still open. I have code already that allows me to close each Window, but that is not causing this problem. I am not sure where in the code I am where I click the Enter key.
Does anyone know how I might cure/find this problem??
Thanks,
Jerry
|
|
|
|
|
Does this help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
I asked this question in the C# forum because it's something I'm doing in C#, but I'm just wondering if any C++ afficionados have already done this one. Through C# I'm using the SendMessage API to be able to have subitem images. But I don't want images in the first column of the listview. the subitem images show up fine, but there's an empty gap for an image in the first column of the listview for an image that I don't plan on putting there. Does anyone know how to get around this? Thanks in advance.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
BlackDice wrote:
But I don't want images in the first column of the listview.
You're out of luck with that one. The only way I know of to prevent that is to make the list owner-drawn and draw it all yourself.
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
I'm programming a universal audio tagger for windows. I'm looking for an easy to understand code example for writing Ogg Vorbis comments in C++.
I've already implemented LibVorbis 1.0.1 and I'm using OggVorbis_File to Read the comments. (No problem there) Unfortunately I was unable to find a good code example of how to use the LibVorbis library to Write Vorbis comments. I think I have to use something like vorbis_comment_add(...), but I have no clue how to do it.
Any help is very welcome!
|
|
|
|
|
|
Unfortunately I had a very good look at the documentation and spent a whole day searching with google, but was still unable to find a good C++ example for implementing Write-Functions with LibVorbis!
Any more help would be great!
Thanks
|
|
|
|
|
Ask on a Ogg specific mailing lists. You are more likely to find someone who knows what how to do this there.
Show them what you have tried, so they can point out what you are doing wrong. Your first question looks like someone who didn't read the book, and that will make them mad. Your second question makes it clear that you read the book (the right one?), so the book needs to be fixed.
Before doing that though, try it. Write a somple C program, and try calling that function with all the options you can think of to see what happens. Then look at the results elsewhere to see what really happened.
|
|
|
|
|
Hi all,
Are there any sample code for implementing a HTTPS server on window platform ? Since my application will be deployed on Window9x and Window XP home edition, so IIS is not available.
Thanks
|
|
|
|
|
I don't know of any HTTPS server source code, but this site has HTTP server source code, mabye you could modify it to work for HTTPS.
http://www.vijaymukhi.com/vmis/vmchap4.htm
Mabye www.sourceforge.net might something HTTPS also
wWw.KruncherInc.cOm
|
|
|
|
|
On top of the previous message, have a look at the OpenSSL[^] project. The source is a bitch to wade through, and I'm not sure if it runs on Windows, but have a go. HTTPS is basically just encrypted HTTP with authentication through a different port (443 usually).
Of course, the other possibility is to distribute something like Apache, which is free, supports SSL and is available on any Windows platform.
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,
In one of my VC++6 projects I need to save image into BMP file. I have window’s handle (HWND hwnd), device context handle (HDC hDC) and bitmap handle (HBITMAP hbit). What API function do I need to call to save image from this form into ‘filename.bmp’ file?
Thanks for help,
Regards,
Leonid
|
|
|
|