|
I need to ensure that the jumps in the inline assembly code I'm writing will always be relative, since the code will be self modyfying, so the same code may be excecuted from muliple memory locations. According to the manual I found, it should be something like this:
jmp SHORT (signed jump bytes)
However, this just gives me a bunch of syntax errors, so does anyone know the correct way?
|
|
|
|
|
Can you tell me please how to pass strings as parameters of a function so we can use them for different purposes?Please help me !!!!
|
|
|
|
|
void foo1( LPCTSTR lpszName )
{
}
or
void foo2( CString &strName )
{
}
...
foo1("My name is...");
CString str("Bob");
foo2(str);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
you forgot:
<code>include <string>
using std::string
void foo3( string s)
{
}</code>
not to mention char *. Is LPCTSTR a macro that converts to narrow and wide strings ? Then there's BSTR and bstr_t......
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I guess it's better to replace
using std::string;
by
using namespace std;
or else the class 'string' will not be available (it's 'std::string', not 'std::string::string').
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)
|
|
|
|
|
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
|
|
|
|