|
i want to, like, anulate the key, not just get the state, and don't know how i should do
|
|
|
|
|
Can you explain a little clearer ? I really, cant understand, what you are trying to say.
|
|
|
|
|
the mouse4 works together with the mouse1
like, mouse4 will be hold, but i dont want that windows detect the mouse4 being hold, i just want mouse1 clicks, you know? thanks
|
|
|
|
|
Can you elobarate , what this mouse1 and mouse4 are ?
|
|
|
|
|
mouse1 = Left Click
mouse4 = xbutton1
|
|
|
|
|
Hi,
I need to know how to detect monitor resolution changes in my MFC application,
is there a WM_MONITORRESOLUTIONCHANGE message or similar that I can use to
check for this.
Many thanks.
|
|
|
|
|
Is WM_DISPLAYCHANGE helpfuls
|
|
|
|
|
Just what I was looking for, Thanks.
|
|
|
|
|
how to change the background color and text itemname in tabControl of mfc
|
|
|
|
|
|
i need some basic tutorials for TabControls in MFC. i need to know its creation and inserting items to the tab. anyone can help me
|
|
|
|
|
Here[^] we go.
Let us not listen to those who think we ought to be angry with our enemies, and who believe this to be great and manly. Nothing is so praiseworthy, nothing so clearly shows a great and noble soul, as clemency and readiness to forgive.
- Marcus Tullius Cicero
|
|
|
|
|
hi all,
I have got a problem with gluUnproject function. it works fine when there is no rotation. When i am giving rotation to my objects , it is giving me wrong coordinates( actually if i did rotation in X->Y->Z , it give me Z->Y->X).
i am using glReadPixels to read depth bits.
Anyone have any ideaaa???
Thanks in advance
Krishnan
If u can Dream... U can do it
|
|
|
|
|
hi i am having three radio buttons. if i click one button a dialog named IDD_NETWORKCONFIG have vto be opened. is there any function to do this
|
|
|
|
|
See this[^] tutorial.
/ravi
|
|
|
|
|
|
Hi
i have a function that gets a parameter of type (char **ptr)
i want to reallocate the space for this pointer (reduce or increase)
i have the followig code that raise an error when realloc change the original pointer
(*ptr)=(char *)realloc(*ptr,(originalLength+shift) * sizeof(char));
what is the problem in this line
note : its work fine when realloc returns the same pointer ?
thanks
|
|
|
|
|
I have a idea.
Are you sure ptr is not null (0) before you call realloc.
Because if ptr is NULL (0) then when you call *ptr is wrong.
you can add a code to report that ptr is null like this:
if(!ptr) MessageBox(0,"ptr is null","error",0);<br />
|
|
|
|
|
no its not null because when i debug the code
*ptr contains a string .
and kindly note the the realloc code that i added is used in many calls before for the same array
and its work fine when the array size is in smaller size but if i added some characters to it
then the allocation failed and i get the error (if i added one character !!)
i think this happen when realloc moves the array to another place and returns a new pointer ?
|
|
|
|
|
yeh, so how you add character to this pointer.
If possible, you can copy your code and paste here.
It is hard to explain if you only talk without code.
Ah, I think maybe you allocated memory before for *ptr by another function like *ptr = new char[]. Don't you do that. If it's, it's wrong.
-- modified at 3:41 Sunday 4th March, 2007
|
|
|
|
|
the array is created by adding characters using the following function
void Append(char **buffer,int size,char c)<br />
{<br />
<br />
(*buffer)=(char *)realloc(*buffer,(size+1) * sizeof(char));<br />
(*buffer)[size-1]=c;<br />
(*buffer)[size]='\0';<br />
}
after the array is created i am running the function that raise the error several times and its work fine and i increase and decrease its content using the following function :
void replaceStr(char **replaceIn,char *replaceWith,int fromIndx,int toIndx)<br />
{<br />
<br />
char *ptr=(*replaceIn)+fromIndx;<br />
int replaceWithLen=(replaceWith==NULL)?0:strlen(replaceWith);<br />
int replacedStrLen=toIndx-fromIndx;<br />
int originalStrLen=strlen(*replaceIn);<br />
int shift=replaceWithLen-replacedStrLen;<br />
int bytesToMove=strlen(ptr)+1;<br />
int originalLength;<br />
<br />
printf("%s\n",*replaceIn);<br />
if(replaceWithLen==0)<br />
{<br />
memmove(ptr-1,ptr+replacedStrLen,bytesToMove);<br />
<br />
}<br />
else<br />
{<br />
if(replaceWithLen>replacedStrLen)<br />
{<br />
originalLength=strlen(*replaceIn);<br />
<big>(*replaceIn)=(char *)realloc(*replaceIn,(originalLength+shift+1) * sizeof(char));</big><br />
if(*replaceIn==NULL)<br />
printf("Error while allocating memory");<br />
*((*replaceIn)+originalStrLen)='\0';<br />
ptr=(*replaceIn)+fromIndx;<br />
memmove(ptr+replaceWithLen,ptr+replacedStrLen,bytesToMove);<br />
}<br />
else<br />
memmove(ptr+replaceWithLen,ptr+replacedStrLen,bytesToMove);<br />
<br />
}<br />
<br />
memcpy(ptr,replaceWith,replaceWithLen);<br />
<br />
}
the error happen at some point in the line in bold !
-- modified at 4:21 Sunday 4th March, 2007
|
|
|
|
|
you have to give me an example that raises error.
I try your code with my example:
int main(){
char *lpstr1 = 0,*lpstr2 = 0;
lpstr1 = (char *)malloc(10);
lpstr2 = (char *)malloc(20);
strcpy(lpstr2,"damnit");
strcpy(lpstr1,"kha");
replaceStr(&lpstr1,lpstr2,2,10);
cout<<"str1 "<<lpstr1<<endl;
cout<<"str2: "<<lpstr2<<endl;
return 0;
};
there is no problem.
I think your code is hard to read.
I do not understand, what do you want when replaceWithLen = 0, i think you dont have to do any think. The logic is complex.
I think you need a new version.
I write this code, I hope it matchs your will. Please try it.
<code>
void myreplaceStr(char **replaceIn,char *replaceWith,int fromIndx,int toIndx){
if((replaceWith==0)||(replaceIn==0)){
printf("%s","nothing to do here\n");
return;
}
if(*replaceIn == 0){
printf("%s","nothing will modified here\n");
return;
}
if(fromIndx > strlen(*replaceIn)){
printf("%s","index outside of string, commonly we dont want this happen\n");
}
DWORD minSize = (strlen(replaceWith) > toIndx - fromIndx) ? (toIndx-fromIndx+1): strlen(replaceWith);
if(strlen(replaceWith+fromIndx) < minSize){
*replaceIn = (char *)realloc(*replaceIn,strlen(*replaceIn + fromIndx) + minSize);
}
memcpy(*replaceIn + fromIndx,replaceWith,strlen(replaceWith));
};
</code>
-- modified at 6:21 Sunday 4th March, 2007
|
|
|
|
|
Can you show how this memory is previously allocated, and used (code)? Possibly, its getting corrupted due to using it wrong way.
|
|
|
|
|
the array is created by adding characters using the following function
void Append(char **buffer,int size,char c)<br />
{<br />
<br />
(*buffer)=(char *)realloc(*buffer,(size+1) * sizeof(char));<br />
(*buffer)[size-1]=c;<br />
(*buffer)[size]='\0';<br />
}
after the array is created i am running the function that raise the error several times and its work fine and i increase and decrease its content using the following function :
void replaceStr(char **replaceIn,char *replaceWith,int fromIndx,int toIndx)<br />
{<br />
<br />
char *ptr=(*replaceIn)+fromIndx;<br />
int replaceWithLen=(replaceWith==NULL)?0:strlen(replaceWith);<br />
int replacedStrLen=toIndx-fromIndx;<br />
int originalStrLen=strlen(*replaceIn);<br />
int shift=replaceWithLen-replacedStrLen;<br />
int bytesToMove=strlen(ptr)+1;<br />
int originalLength;<br />
<br />
printf("%s\n",*replaceIn);<br />
if(replaceWithLen==0)<br />
{<br />
memmove(ptr-1,ptr+replacedStrLen,bytesToMove);<br />
<br />
}<br />
else<br />
{<br />
if(replaceWithLen>replacedStrLen)<br />
{<br />
originalLength=strlen(*replaceIn);<br />
<big>(*replaceIn)=(char *)realloc(*replaceIn,(originalLength+shift+1) * sizeof(char));</big><br />
if(*replaceIn==NULL)<br />
printf("Error while allocating memory");<br />
*((*replaceIn)+originalStrLen)='\0';<br />
ptr=(*replaceIn)+fromIndx;<br />
memmove(ptr+replaceWithLen,ptr+replacedStrLen,bytesToMove);<br />
}<br />
else<br />
memmove(ptr+replaceWithLen,ptr+replacedStrLen,bytesToMove);<br />
<br />
}<br />
<br />
memcpy(ptr,replaceWith,replaceWithLen);<br />
<br />
}
the error happen at some point in the line in bold !
|
|
|
|
|
Im doing a calculator project for my c++ class but my operations dont compute properly and i cant quite figure out whats wrong any input would be greatly appreciated.
<br />
<br />
<br />
<br />
<br />
#include <iostream><br />
#include <string><br />
#include <cmath><br />
using namespace std;<br />
string upconv(string instring);<br />
void help();<br />
<br />
int main () {<br />
double memory;
double display;
double number;
string strInput;
char firstChar;
char secondChar;
int inputLength;
<br />
cout << "Enter ? for help" << endl;<br />
while(true) {<br />
cin >> strInput;<br />
strInput = upconv(strInput);<br />
firstChar = strInput[0];<br />
inputLength = strInput.length();<br />
if(inputLength==1) {<br />
switch(firstChar) {<br />
case '+':<br />
cin >> number;<br />
display = display + number;<br />
break;<br />
case '-':<br />
break;<br />
case '*':<br />
break;<br />
case '/':<br />
break;<br />
case '=':<br />
break;<br />
case '?':<br />
help();<br />
break;<br />
case 'I':<br />
break;<br />
case 'N':<br />
display = display * -1;<br />
break;<br />
case 'E':<br />
break;<br />
default:<br />
cout <<"Error invalid command" <<endl;<br />
}
}
else {
if(firstChar == 'M') {
secondChar = strInput[1];<br />
switch(secondChar) {<br />
case 'S':<br />
memory = display;<br />
break;<br />
case 'R':<br />
display = memory;<br />
cout << "Memory equals " << endl;<br />
break;<br />
case '+':<br />
display = memory + display;<br />
break;<br />
case 'C':<br />
break;<br />
default:<br />
cout << "Invalid memory command"<<endl;<br />
}
}
else {<br />
}<br />
}
cout << display << endl;<br />
}
<br />
return 0;<br />
}
<br />
<br />
<br />
string upconv(string instring) {<br />
string newstring=instring;<br />
int len = instring.length();<br />
for(int i=0; i<len; i++) {<br />
newstring[i]= toupper(instring[i]);<br />
}
return newstring;<br />
}
<br />
void help() {<br />
cout << "HELP" << endl;<br />
}<br />
Charles Covington
|
|
|
|
|