Nov 23, 2009 at 2:31pm UTC
I have a test2.h file to save CString b;
my purpose is write the value get from the edit control to String b
void Cdlg001::OnBnClickedButton1()
{
CString value;
seat2.GetWindowText(value);
MessageBox(_T("11111"));
((Ctest2App *)AfxGetApp())->b= "0000";
if( ((Ctest2App *)AfxGetApp())->b == "0000")
MessageBox(_T("00000"));
// TODO: Add your control notification handler code here
}
I can compile the program but the program stops at((Ctest2App *)AfxGetApp())->b= "0000";
I would like to know why the program stops at
((Ctest2App *)AfxGetApp())->b= "0000";
million thanks!
How can I make it work again?
Last edited on Nov 23, 2009 at 2:35pm UTC
Nov 23, 2009 at 3:59pm UTC
1. Can you use the code formatting tag to format your code.
2. Can you post your CWinApp derived class' header file.
Nov 23, 2009 at 4:44pm UTC
2. Can you post your CWinApp derived class' header file.This is the headder file code.
// test2.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#ifdef POCKETPC2003_UI_MODEL
#include "resourceppc.h"
#endif
#ifdef SMARTPHONE2003_UI_MODEL
#include "resourcesp.h"
#endif
// Ctest2App:
// See test2.cpp for the implementation of this class
//
class Ctest2App : public CWinApp
{
public:
Ctest2App();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
public:
int g_n_filmID;
int g_n_location;
int g_n_time;
int a;
CString b; // This is the most useful part
};
extern Ctest2App theApp;
1. Can you use the code formatting tag to format your code. what do you mean by that?
thz
Nov 24, 2009 at 5:16pm UTC
I just cannot pass the string to a public CString let say b
Nov 24, 2009 at 5:19pm UTC
theApp.b is a public CString. That means the rest of the program has unfettered access to it.