我正在使用CSV文件。我有一个显示带ID的数据的程序,但我需要用按钮和输入字段更改ID。现在我可以mannualy改变int i =#;但我需要字段,用户输入他的号码,然后编程显示或更改数据。
case WM_PAINT:
{
hdc = BeginPaint(hwnd,&ps);
TextOut(hdc, 5, 5, txt_companyName, _tcslen(txt_companyName));
TextOut(hdc, 110, 5, txt_programName, _tcslen(txt_programName));
/* Headers */
TextOut(hdc, 5, 23, txt_opened, _tcslen(txt_opened));
TextOut(hdc, 250, 23, txt_time, _tcslen(txt_time));
TextOut(hdc, 290+15, 23, txt_input, _tcslen(txt_input));
TextOut(hdc, 428+15, 23, txt_time, _tcslen(txt_time));
TextOut(hdc, 468+25, 23, txt_timeSpent, _tcslen(txt_timeSpent));
TextOut(hdc, 578+25, 23, txt_timeRemain, _tcslen(txt_timeRemain));
/* Data printing in row */
int i = 3;
std::string data_component_label = getElementFromFileLine("data.csv",i,8,0);
std::string data_component_mslLvl = getElementFromFileLine("data.csv",i,8,1);
std::string data_component_opened = getElementFromFileLine("data.csv",i,8,2);
std::string data_component_timeOpened = getElementFromFileLine("data.csv",i,8,3);
std::string data_component_input = getElementFromFileLine("data.csv",i,8,4);
std::string data_component_timeInput = getElementFromFileLine("data.csv",i,8,5);
std::string data_component_timeSpent = getElementFromFileLine("data.csv",i,8,6);
std::string data_component_timeRemain = getElementFromFileLine("data.csv",i,8,7);
//std::string data_component_Status = getElementFromFileLine("data.csv",2,8,2);
//TextOut(hdc, 5, 23+18, data_component_opened, _tcslen(data_component_opened));
TextOut(hdc, 5, 23+18, data_component_opened.c_str(), _tcslen(data_component_opened.c_str()));
TextOut(hdc, 250, 23+18, data_component_timeOpened.c_str(), _tcslen(data_component_timeOpened.c_str()));
TextOut(hdc, 290+15, 23+18, data_component_input.c_str(), _tcslen(data_component_input.c_str()));
TextOut(hdc, 428+15, 23+18, data_component_timeInput.c_str(), _tcslen(data_component_timeInput.c_str()));
TextOut(hdc, 468+25, 23+18, data_component_timeSpent.c_str(), _tcslen(data_component_timeSpent.c_str()));
TextOut(hdc, 578+25, 23+18, data_component_timeRemain.c_str(), _tcslen(data_component_timeRemain.c_str()));
EndPaint(hwnd,&ps);
}
break;
我在WM_CREATE和WM_COMMAND中有一个按钮并输入,但是当我尝试在WM_PAINT中使用缓冲区时,例如在MessageBox中打印它,期望一个带有数据的消息框,用户输入,但是,有编译错误 -
main.cpp |错误:'缓冲区'未在此范围内声明
所以我需要以某种方式从WM_COMMAND获取数据到WM_PAINT
case WM_CREATE:
{
hEdit=CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"",
WS_CHILD|WS_VISIBLE|
ES_MULTILINE|ES_AUTOVSCROLL|ES_AUTOHSCROLL,
95,
80,
200,
30,
hwnd,
(HMENU)IDC_MAIN_EDIT,
GetModuleHandle(NULL),
NULL);
HGDIOBJ hfDefault=GetStockObject(DEFAULT_GUI_FONT);
HWND hWndButton=CreateWindowEx(NULL,
"BUTTON",
"NEXT",
WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
5,
80,
75,
30,
hwnd,
(HMENU)IDC_MAIN_BUTTON,
GetModuleHandle(NULL),
NULL);
SendMessage(hWndButton,
WM_SETFONT,
(WPARAM)hfDefault,
MAKELPARAM(FALSE,0));
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_MAIN_BUTTON:
{
char buffer[265];
SendMessage(hEdit,
WM_GETTEXT,
sizeof(buffer)/sizeof(buffer[0]),
reinterpret_cast<LPARAM>(buffer));
中断;