|
Your fine. I would have to say that I agree they should probably leave their parsing within the confines of CString also. However, they will need to know how to interface code littered with CString with the Win32 API which can be quite a trick sometimes but Paul DiLascia, Joseph Newcomer, and Michael Dunn have all done superb jobs explaining all that.
The newer versions of CString have a Tokenize method but it treats consecutive delimiters as one which can easily lead to corrupt parsing so I would not recommend it at all.
|
|
|
|
|
your copying up to the size of your szBuffer but your forgetting to add the \0 (null terminator) so when you attempt to printf or output the string your getting everything up to the end of the szBuffer and then some.
|
|
|
|
|
Hongjun Ge wrote: char szData1[5];
char szData2[10];
char szData3[5];
Why are you not using CString for these? You can certainly complete the task without it, but since you are using MFC, you might as well take advantage of what it has to offer.
CTest::CTest( LPCSTR lpszValue )
{
AfxExtractSubString(strData1, lpszValue, 0);
AfxExtractSubString(strData2, lpszValue, 1);
AfxExtractSubString(strData3, lpszValue, 2);
}
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
my program use matrix to get rgb
and then i hope that white transform into black
int main(int argc, char* argv[])
{
FILE *fidr;
FILE *fidg;
FILE *fidb;
fidr = fopen("logr.txt","w");
fidg = fopen("logg.txt","w");
fidb = fopen("logb.txt","w");
GBmp ImgA, ImgB;
int i,j,k;
ImgA.load("a.bmp");
unsigned char *rgb;
rgb = (unsigned char*) malloc( ImgA.w*ImgA.h*3*sizeof(unsigned char) );
rgb = ImgA.rgb;
for(i=ImgA.h-1;i>=0;i--){
for(j=0;j<imga.w;j++){
="" fprintf(fidr,"rgb(%3d,%3d)=",i,j);
for(k=0;k<3;k++){
if (k==0)
{
fprintf(fidr," %4d",*(rgb+i="" *="" imga.w="" 3="" +="" j*3="" k));
="" }
="" }
="" if(j="ImgA.w-1)
" {
="" fprintf(fidr,"\n");
="" for(i="ImgA.h-1;i">=0;i--){
for(j=0;j<imga.w;j++){
="" fprintf(fidg,"rgb(%3d,%3d)=",i,j);
for(k=0;k<3;k++){
if (k==1)
{
fprintf(fidg," %3d="" ",*(rgb+i="" *="" imga.w="" 3="" +="" j*3="" k));
="" }
="" }
="" if(j="ImgA.w-1)
" {
="" fprintf(fidg,"\n");
="" for(i="ImgA.h-1;i">=0;i--){
for(j=0;j
|
|
|
|
|
If you don't say what does not work, no-one is going to give suggestions.
When you post code, please use the "pre" tag (below the signature box) so the indenting is not lost.
|
|
|
|
|
I'm just starting to learn C++, and i met a problem error below when i compound it...pls teach me how to correct these errors. Your kindness will be appreciated....thank you.
#include "matrix.h"
#ifndef _NO_NAMESPACE
using namespace std;
using namespace math;
#define STD std
#else
#define STD
#endif
#ifndef _NO_TEMPLATE
typedef matrix<double> Matrix;
#else
typedef matrix Matrix;
#endif
#ifndef _NO_EXCEPTION
# define TRYBEGIN() try {
# define CATCHERROR() } catch (const STD::exception& e) { \
cerr << "Error: " << e.what() << endl; }
#else
# define TRYBEGIN()
# define CATCHERROR()
#endif
the software tells the error at these location:
line6 : error C2871: 'std' : does not exist or is not a namespace
line7 : error C2871: 'math' : does not exist or is not a namespace
line14 : error C2143: syntax error : missing ';' before '<'
line14 : error C2143: syntax error : missing ';' before '<'
|
|
|
|
|
you need to #include the files that contian those namespaces, otherwise the compiler doesn't know what your "using" statements refer to.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
I'm sure there are hundreds of tools/addins/libraries for detecting memory leaks. Which one do most of you use? What is the best method for detecting the annoyances? is it possible to find the exact function/line?
I'm using Visual Studio VC6 Enterprise if it makes any difference.
|
|
|
|
|
I've tried many and my preferred tool DevPartner Studio from CompuWare. It has its quirks and sometimes goes a while without an update, but I've been especially impressed with the latest version.
It is a little expensive, but has proven its worth for me many times over.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I have a message "An unsupported operation was attempted" in MFC release configuration.
How may I locate error point?
|
|
|
|
|
try to search for this message in MFC Source.
Yout find it where your Developer Studio is installed.
|
|
|
|
|
I would try to find it in a debug buid. If it doesn't occur in the debug build alter the compiler setting (for the debug configuration) to include the "/GZ" switch and try again - It's much easier to find bugs in a debug build.
Steve
|
|
|
|
|
How can I tell if my arrival to OnBnClickedOk() came from a mouse click or from a keyboard entry of Enter?
The reason this is important is that I have a multi line edit box and if the user hits Enter while in this edit box I don’t want the system to act as if he clicked on OK.
I already tried removing the Default Button Status from the OK button, but that makes no difference. I can see that if I click on the edit box, the added black line on the OK button remains, as if it has the focus, which of course it doesn’t. Even if I tab to this control the added black line on the OK button remains, showing that Enter will activate it.
Clearly, if I could know in my event handler for the OK button if the event came from a mouse click or from a keyboard Enter, there would be no problem dealing with it.
Any suggestions would be appreciated. Thanks,
Ilan
|
|
|
|
|
I'm not quite sure how to do this in MFC, but in win32, you need to change the way the messages are handled.
This code is inserted into the winMain and it checks for messages being sent to the dialog.
while( GetMessage( &msg, NULL, 0, 0 ) )
{
if(!IsDialogMessage(dlgHwnd, &msg)) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
return msg.wParam;
|
|
|
|
|
You're going about it the wrong way, really. Take a look at the ES_WANTRETURN style for the edit box - setting that will probably give you the result you're after.
|
|
|
|
|
Thanks Graham. This gives me EXACTLY the result I wanted. Since I never used it, I didn't know it existed.
Thanks again,
Ilan
|
|
|
|
|
Hi Ilan,
Well, my suggestion is that you declare two time stamps and use them to keep the latest time of left mouse click and Enter key click. In OnOk functions, you may compare the current time with both time stamps and this may give you some idea about which is the source of the action.
regards,
chris
|
|
|
|
|
Oops, I didn't see other replys just now. Obviously, my suggestion is the worst one. hehe, ignor it.
Regards,
Chris
|
|
|
|
|
I want to make a modal class in the visual c++,but when I want to make it ,the system told me that I can't make this class,how should I solove this problem.thank you!waiting for your answer.
Always do you best,what you plant you will harvest
later!
|
|
|
|
|
Do you mean a modal 'dialog' ?
If so there are two methods for creating a dialog
DialogBox() // creates a modal dialog
CreateDialog() // creates a modeless dialog
Have a look on MSDN for how to use these functions.
|
|
|
|
|
|
Harry,
What are you staring with, a Dialog based application?
Do you want to create another Dialog that you can po
up from the intial one?
Bt the way, it will help you a lot, a lot, a lot,
if you give a subject in you post that is indeed the
subject you are inquiring about.
If you just put "help" then it possible that many people
who could help you will just pass over you post.
Read Chris's points also. They are the first post in this
forum.
|
|
|
|
|
Anyone knows what function to use to get the value of a radio button in a dialog box??
I have done the following but it has no effect on my program:
g_water.RippleIntensity= GetDlgItemInt( hWnd, IDC_RIPPLE_INTENSITY, NULL, true );<br />
<br />
iRenderCheck = GetDlgItemInt( hWnd, IDC_WATER_YES, NULL, true );<br />
<br />
if (iRenderCheck == 1)<br />
{<br />
g_water.m_bWaterCheck = true;<br />
}<br />
else if (iRenderCheck == 0)<br />
{<br />
g_water.m_bWaterCheck = false;<br />
}
Cheers!!
|
|
|
|
|
Not sure i understand what you mean but have you looked at CheckRadioButton[^]
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
CButton::GetCheck()
--
Pictures[^] from my Japan trip.
-- modified at 4:24 Sunday 19th March, 2006
|
|
|
|