|
i am using CRichEditCtrl, and sending to the control the EM_AUTOURLDETECT message.
problem is the rich edit decides the text color of the hyper link
how to change it?
thanks in advanced
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Hi,
Currently im working on MFC Dialog Based application, the design of the dialog is to let user key in the word, then my picture control will render the sign language using the OpenGL. So I would like to link up the capture words that user key in the dialog and pass it to another function in order to display the animation. The problem now is Im unable to pass the variable from dialog.cpp to OpenGL.cpp
the dialog.cpp indicate that the dialog based that i have created while the OpenGL.cpp indicare that the program that I wrote to render the model.
I had declared the global variable as extern int NumOfWords and extern CString Word[20].
the NumOfWords is to capture how many words that user had keyed in and the CString Word[20] is to store the word by word into array.
How am I going to make these two variable at OpenGL.cpp? Hope to hear from you all soon. thank you.
regards,
sn00pi
|
|
|
|
|
sn00pi wrote: How to declare global variable in MFC dialog based application?
Like in any other C++ application (see [^]).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
After declare the global Variable, how come the variable cannot be passing down to other .cpp? global variable should be able to passing down the variable right?
After I entered the word, the system able to capture the word. but then the word that store in the array unable to pass to the OpenGL.cpp is there any solution to solve this problem? thank you.
regards,
sn00pi
|
|
|
|
|
I think you should post the relevant pieces of code (stating the header or source file each snippet belongs to) and the detailed error messages you get (if any).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi,
here is it the oglMFCDialog.cpp code which is the dialog, when the user enter word, after click on button, the button function as below:
m_sText2 = m_sText;
m_sText = " ";
CString str = m_sText2;
int NumOfWords=0;
CString Word[20];
int c=0;
CString word;
int curPos= 0;
word = str.Tokenize(",.?% #",curPos);
while (word != "")
{
Word[NumOfWords]= word;
NumOfWords = NumOfWords + 1;
word = str.Tokenize(",.?% #",curPos);
}
COpenGLControl::COpenGLControl();
here is OpeGLControl.cpp file for OpenGL rendering,
COpenGLControl::COpenGLControl()
{
int NumOfWords;
CString Word;
static int t=0;
for(int a=0;a<NumOfWords; a++)
{
for(int c=0;c<NumOfFramesLoad;c++)
{
if(c == NumOfFramesLoad - 1)
{
g_3DModel[t] = g_3DModel[0];
}
else
{
string ObjFile[100];
char g ='0'+ c;
ObjFile[t] = Word[a] + g + ".obj";
........
........
The global variable i define in the OpenGLControl.h
extern int NumOfWords;
extern CString Words[20];
Those i need to used this 2 variables .cpp file i have declare them. Hope to hear from you soon. thank you.
regards,
sn00pi
|
|
|
|
|
sn00pi wrote: COpenGLControl::COpenGLControl()
{
int NumOfWords;
This local variable declaration hides the global one in the contex. remove it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am new to C++
Consider the following
int number = 5;
int *numptr = &number;
Herecan say, numptr is a pointer to an integer and it has the address of the location where 5 is stored
char * number = "five is number";
However here is it right to say that the 'number' is a pointer to a char and stores the address of the first character in the string(f). If it is, then why does the statement,
cout<<number;
gives the string itself as the output and not the address where the character 'f' is stored.Also what does '&number' mean when 'number' is a pointer.
|
|
|
|
|
Because the '<<' operator in the ostream class has many implementations.
Which one of the implementations is called depends on the arguments in call.
Functions like this are referred to as homonymous, if I recall correctly.
This means that if you call the operator and provide an integer as argument the value will be sent to the stream. If you provide a char* it is assumed to point to a zero-terminated string and will send all characters beginning with the address pointed to and stopping when a NULL char is detected.
Read more about the ostream::operator<<() here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
rahulcrjk wrote: gives the string itself as the output and not the address where the character 'f' is stored
Because the << operator was overloaded for the char* type and it is implemented to display the string itself. STL provided overloads for a lot of different types and they implemented the way they like (here, it makes much more sense to output the string and not its address).
rahulcrjk wrote: Also what does '&number' mean when 'number' is a pointer.
I don't really understand what you mean but I guess you are asking what &numptr means (if I use the code you provided earlier) ? In that case it simply means that it is the address of the pointer (remember that pointers are variables too, so they also have an address, which can be stored in another variable, and so on ad infinitum ).
|
|
|
|
|
rahulcrjk wrote: Herecan say, numptr is a pointer to an integer and it has the address of the location where 5 is stored
good.
rahulcrjk wrote: char * number = "five is number";
However here is it right to say that the 'number' is a pointer to a char and stores the address of the first character in the string(f). If it is, then why does the statement,
cout<<number;
gives the string itself as the output and not the address where the character 'f' is stored.
Because:
(1) the string layout in memory is
ADDRESS VALUE
number 'f'
number + 1 'i'
number + 2 'v'
number + 3 'e'
number + 4 ' '
number + 5 'i'
number + 6 's'
number + 7 ' '
number + 8 'a'
number + 9 ' '
number + 10 'n'
number + 11 'u'
number + 12 'm'
number + 13 'b'
number + 14 'e'
number + 15 'r'
number + 16 '\0'
(2) the extraction operator << knows about (1).
rahulcrjk wrote: Also what does '&number' mean when 'number' is a pointer.
is the address of the variable who holds the pointer. For instance
int i;
int * p;
int * * pp;
int k;
i = 5;
p = &i;
pp = &p;
k = **pp + 2;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hoo ho, i get your question right, and you have no idea how i struggled with c++ before i coluds understand pointers, thats why they even made java, to eliminate the whole thing about pointers, but the minute you understand the, thats it..
Just know that pointers yes have 2 major refences or usage in c++.
It all depends on how you use them, but fact is , they do point to an address in memory, not the actual data.
Your question goes like this,
if i say
int my_number = 5;
int* my_pointer = #
the output ;
cout << my_pointer ; displays an address, sth like 45542945;
if i output ;
cout << *my_pointer; then i get the number 5;
this is to say, my_pointer, is a memory (RAM) address, and the value in *my_pointer is the value 5;
if when used with a character / string, the pointer will refence the address of the first character, then when i say
char* my_ptr = "this is a string";
cout <<my_ptr.
my pointer being an address of the 1st character, then i shoudl see the address output, not the whole string.
but thats not the case, why??? was that the question.
okay, one point you have right, the other point you are missing is that, a pointer when used to refence an array, it points to the first element of the array.
why do you think this is correct;
int nums[3] = {11,21,31};
int* nums_ptr = nums;
cout<< nums_ptr[0] ;
because when you do point an array (a string is a also an array), you can copy the whole array into a pointer one time.
and yuo know that an array is placed in (contigous) continuous memory locations, i.e. if 11 is in addres x, then 21 is in x+1, and 31.
so for integers if you want the third element of the array in that has been copied to an pointer, if you say nums_ptr[2], you wont get the address of the 3rd element, you'll get the value.
but again for integers if you say
cout<<nums_ptr;
you wont get all the elements of the array displayed on the screen like 112131, no, you get the address.
thats the only differents with characters since, an array of characters is treated like a string..
displaying the pointer wont display the adress of the fisrt character but the whole string.
try play with pointers, that's the weak and stronghold with c++, in that learning is abit confusing but once learnt it gives some crazy flexibility you wont get from any of it's neighbors..
|
|
|
|
|
1. I am using a std::map to store some values of keys
2. On startup of my function i am loading values to my map
3. I am storing values to my map by a http call which is returning the key and values from a file.
4. Now i have changed my configuration file and i want to reload the config map without restarting my process
5. lots of places i am already accessing this map
How safely i can reload my configurations?
Please need some idea and help
Regards,
Samba
|
|
|
|
|
Soumyadipta wrote: 4. Now i have changed my configuration file and i want to reload the config map without restarting my process
5. lots of places i am already accessing this map
How safely i can reload my configurations?
With the limited information you've given at least I can only give a general answer...
You have to trigger the "reloading" procedure in some way.
If you by "accessing the map" mean that you're using the map from different threads, you also need to provide thread synchronization using a critical section or mutex.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi
I wrote a program with vc6 which when clicked on a file;
the full path of it returns to output (Like CString m_bitmap = "E:\\Documents\\1.bmp"),
So I want to do this to return the directory of file,
Does anyone know how can I do that and in which class I could return directory?
I don't need to return the current directory of my project and the type of variable is CString;
Please mail me the answer,
My mail is: mhghaeminia@yahoo.com
Thanks
|
|
|
|
|
David Crow already answered [^].
Anyway with MFC , using CPath will make your life simpler (you've to include atlpath.h ):
void CMyClass::GetDirectory( CString & szPath )
{
CPath path( szPath );
path.RemoveFileSpec();
szPath = (PCTSTR)path;
}
void CMyClass::OnBnClicked()
{
CString szBmpPath = _T("E:\\Documents\\1.bmp");
CString szBmpFolder = szBmpPath;
GetDirectory(szBmpFolder);
AfxMessageBox(szBmpFolder);
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am in charge of a large number of dll's written in MFC. I have made a decision to convert them to COM interfaces. I studied the subject and decided ATL is the best answer. Problem is:
I cannot call the old dll methods without getting a LNK2019 error.
The IDE is VS2003. I read something about there being a issue with VS2003 with the 'attribute' keyword.
A nudge in the right direction would be highly appreciated.
|
|
|
|
|
Member 3480232 wrote: I cannot call the old dll methods without getting a LNK2019 error.
Which means that you're doing implicit linking, i.e. you're not calling ::LoadLibrary() and ::GetProcAddress() to make use of your libraries.
This also means that you need to link with the .lib file generated in the build process of the library you're trying to use.
Now to the obvious question....: have you added the .lib file to the "additional libraries" in your project settings?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Right on all counts. The original job was done by myself, so everything is as I hoped it should be. I also include the old job.h file with the cplusplus override added.
Its obvious I am doing something wrong!
As an afterthought, part of the decision to do this had to do with the schlepp of using LoadLibrary, GetProcAdress or DllImport and possibly speed of linking as well.
|
|
|
|
|
|
Pearson_Bee wrote: assume that the length of pBuffer-BUFFERSIZE is bigger than or equals the length of
the buffer of socket,Is there possible that data in the buffer of socket is not
retrieved clearly after calling recv() one time?
Assume I've understood properly your question: the answer is no.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
sorry I made you misunderstood,
would you like to detail this sentence from MSDN?
---"For connection-oriented sockets (type SOCK_STREAM for example),
calling recv will return as much information as is currently
available—up to the size of the buffer supplied."
is it mean every bytes of data will be retrived after recv() at one time? as long as the size of the buffer supplied is big enough?
thanks in advanced.
|
|
|
|
|
Pearson_Bee wrote: is it mean every bytes of data will be retrived after recv() at one time? as long as the size of the buffer supplied is big enough?
The statement
as much information as is currently available, up to the size of the buffer supplied
looks to me clear, accurate and in contrast with your interpretation.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Pearson_Bee wrote: is it mean every bytes of data will be retrived after recv() at one time? as long as the size of the buffer supplied is big enough?
No!
It means that recv() will return as many bytes as it has available,
up to the number of bytes you've requested (indicated by the number
you pass as the "len" parameter). This could be one byte, all the bytes
you've requested, or any number of bytes in between.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It's VERY bad etiquette to delete your question after you get an answer
|
|
|
|