|
Did you read the exe file through binary?
if(no)
{
try it;
}
hope it helps!
|
|
|
|
|
i used the CreateFile API. In that what flags shud i set.
thanks
kunal
|
|
|
|
|
Hi,
I have created MFC SDI application. It is working except "Edit" part of the menu. Do I need to modify any code to make it work? I am not able to cut, copy or paste using it.
Thanks,
Harsha
|
|
|
|
|
harsha1305 wrote: I am not able to cut, copy or paste using it.
What are you trying to copy/cut from, or paste into?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Those Cut/Copy/Paste are not active. Those look deactivated. I am not able to click on it. I have an edit box in the application, where I have typed text. I am not able to copy it using this control.
If you have any suggestion, please let me know.
Thanks,
Harsha
|
|
|
|
|
harsha1305 wrote: Those Cut/Copy/Paste are not active. Those look deactivated.
You need to provide handlers for them. Use ClassWizard (Ctrl+W) for this.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How to use copy and paste and whats your code for copy and paste
whitesky
|
|
|
|
|
Hi,
I have derived a class from CProgressCtrl. In OnPaint() I do my painting of the current progress which works fine. But there is a problem when the application uses XP themes: There is no border drawn around the control. I can draw the border myself, but then I got problems with win2000 (-> 2 borders). Does anyone know how to enable the border for a ownerdraw progress control ?
thanks
|
|
|
|
|
You use DrawThemeBackground() to paint a themed control. For a progress bar, call it with the PP_BAR part to draw the border/background, then call it with the PP_CHUNK part to draw the progress indicator.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
VB > soccer
|
|
|
|
|
Hi,
thank you for your fast reply.
I think DrawThemeBackground with PP_BAR will draw the "theme'd" border with round edges. What I want to do is a progress control that looks like a sunken static. The control should just look like a non themed control.
|
|
|
|
|
|
Yes, ok that's what I want to do. But 1.) Win2000 and 2.) Win XP with DEACTIVATED themes draw the border alone. I can't prevent this.
And 3.) Windows XP with themes ACTIVATED doesn't draw the border. So if I put some code in the OnPait Proc. to draw a border, the control looks fine in condition 3.). But in condition 1.) + 2.) I got two borders: The one that I draw myself and the one that the OS draw.
So I don't know how to solve this...
|
|
|
|
|
Oh, sorry, I didn't finish my thought in my earlier post. It would probably be easier to draw the entire thing yourself (that's where I was going with the "so it looks the same on all OSes"). Use some other control like a button that has an owner-draw style, and then do all the drawing in response to the WM_DRAWITEM message sent by the control.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
VB > soccer
|
|
|
|
|
I've tried this:
CString str = "0x1";
char *ps;
ps = str.GetBuffer(4);
str.ReleaseBuffer();
// Check if the string starts with a '0x'
if(nStringSize > 2 && ('0' == string[0]) && (('x' == string[1]) || ('X' == string[1])))
{
for(i = 2; i < nStringSize; i++)
{
cReturn = cReturn*16;
// Decode ASCII
if((string[i] >= '0') && (string[i] <= '9'))
cReturn += string[i] - '0';
else if((string[i] >= 'A') && (string[i] <= 'F'))
cReturn += string[i] - 'A' + 0xa;
else if((string[i] >= 'a') && (string[i] <= 'f'))
cReturn += string[i] - 'a' + 0xa;
else
// Incorrect character
return 0;
}
return cReturn;
}
else return atol(string);
I get the following error:
error C2440: '=' cannot convert 'wchar_t*' to 'char*'
I've also tried many other ways to convert CString to char* but I still get errors...
Kitty5
|
|
|
|
|
|
okey yes i did that but now i'm getting a corruption problem.
I did this:
sscanf( userIn, "%s %s %s %s", device.GetBuffer(25), cmd.GetBuffer(25), input1.GetBuffer(25), input2.GetBuffer(25) );
I know that:
input1 has been assigned 0x1 b/c I do an AfxMessageBox(input1)
then when I do:
char *str = input1.GetBuffer();
AfxMessageBox(input1); //to check to see if input1 is still ok.
input1.ReleaseBuffer();
I find that input1 has been corrupted:
input1 is not equal to garbage.
how do I assign the value of the CString input1 to a char*?
Kitty5
|
|
|
|
|
kitty5 wrote: sscanf( userIn, "%s %s %s %s", device.GetBuffer(25), cmd.GetBuffer(25), input1.GetBuffer(25),
Don't use sscanf for string parameters; you will always get unexpected behaviors.
kitty5 wrote: char *str = input1.GetBuffer();
AfxMessageBox(input1); //to check to see if input1 is still ok.
input1.ReleaseBuffer();
When you call GetBuffer, you cannot do ANYTHING with the CString object until you call ReleaseBuffer. In the above case, you should just be calling AfxMessageBox(input1); without the GetBuffer/ReleaseBuffer calls.
CString has an explicit conversion operator to LPCTSTR (which is a const TCHAR* -- which equates to const char* in non-UNICODE builds).
To simply your code, write a split function that takes a delimiter (which would be a space in this case) and parses a given CString and places the split CStrings into a CString Array. You will make your life much easier.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: To simply your code, write a split function that takes a delimiter (which would be a space in this case) and parses a given CString...
Why not just use AfxExtractSubString() ?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
AfxExtractSubString is too clumbsy.
Something like this works well for splitting multiple values:
void Split(CString strText, CString strSeparators, CStringArray& strArray)<br />
{<br />
int start = 0;<br />
while (start >=0 && start < strText.GetLength())<br />
{<br />
int stop = strText.Find(strSeparators, start);<br />
if (stop < 0 || stop > strText.GetLength())<br />
stop = strText.GetLength();<br />
strArray.Add(strText.Mid(start, stop - start));<br />
start = stop + 1;<br />
}<br />
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: AfxExtractSubString is too clumbsy.
How so?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
To get the desired result from it for this problem, you would have to make several subsequent calls to it while keeping track of where you are in the original string. Since the problem involves splitting a string by spaces, it is very simple to use the split method I gave to put each substring in the array as it is found and return the array.
The method is also reusable for future parsing of delimited strings (where using AfxExtractSubString would require either using it in another implementation of Split, or changing to code each time you want to use a different delimiter).
Finally, it is very easy to change the CString objects to std::string objects (and CStringArray to std::vector< std::string > ) to make the Split method portable outside of just MFC (or even Windows altogether).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: ...while keeping track of where you are in the original string.
Are you sure?
Since the goal was to simply split the user input into four pieces, what's wrong with replacing:
sscanf( userIn, "%s %s %s %s", device.GetBuffer(25), cmd.GetBuffer(25), input1.GetBuffer(25), input2.GetBuffer(25) ); with:
AfxExtractSubString(device, userIn, 0, ' ');
AfxExtractSubString(cmd, userIn, 1, ' ');
AfxExtractSubString(input1, userIn, 2, ' ');
AfxExtractSubString(input2, userIn, 3, ' '); All of the array stuff was not part of the original problem.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Sorry, you are correct. I forgot about the index argument. However, my portability argument still holds.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: kitty5 wrote:
char *str = input1.GetBuffer();
AfxMessageBox(input1); //to check to see if input1 is still ok.
input1.ReleaseBuffer();
When you call GetBuffer, you cannot do ANYTHING with the CString object until you call ReleaseBuffer. In the above case, you should just be calling AfxMessageBox(input1); without the GetBuffer/ReleaseBuffer calls.
do you have to release the buffer right after getBuffer?
i.e.:
char *str = input1.GetBuffer();
input1.ReleaseBuffer();
AfxMessageBox(input1); //to check to see if input1 is still ok.
Kitty5
|
|
|
|
|
kitty5 wrote: do you have to release the buffer right after getBuffer?
You release it as soon as you are done with it. However, since you are not modifying the CString object in your example, there's no need to call either method.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|