Почему ничего не записывается в listBox?
Ещё в sprintf в фамилии только первая буква записывается
INT_PTR CALLBACK JobDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
static Worker workers[100]; //все рабочие
static HWND hListBox = GetDlgItem(hDlg,IDC_LIST1);
StructEnd structEnd;
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
hListBox = GetDlgItem(hDlg, IDC_LIST1);
return (INT_PTR)TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
//Worker worker;
//GetDlgItemText(hDlg, IDC_AGE, worker.lastName, 100);
//SaveWorker(worker);
//Worker worker = GetWorker(hDlg);
//StructEnd structEnd = { worker,TEXT("") };
//out(p, worker, sizeof(worker));
structEnd.worker = GetWorker(hDlg);
putStudEndIntoStroka(structEnd);
//SendMessageA(hListBox, LB_ADDSTRING, 0, (LPARAM)structEnd.str);
ListBox_AddString(hListBox,structEnd.str);
SendMessageW(hListBox, LB_ADDSTRING, NULL, (LPARAM)structEnd.str);
MessageBoxA(hDlg, structEnd.str, NULL, MB_OK);
MessageBoxA(NULL, "Saved", "Warning", MB_OK | MB_ICONWARNING);
EndDialog(hDlg, 0);
break;
case IDCANCEL:
EndDialog(hDlg, 0);
break;
}
break;
}
return (INT_PTR)FALSE;
}
JobStruct.cpp
#pragma once
#include "resource.h"
#include "stdafx.h"
#define _CRT_NON_CONFORMING_SWPRINTFS
#pragma(disable:4996)
struct Worker {
WCHAR lastName[100];
int age;
int experianceAge;
int countOut;
int payment;
bool markedAsDeleted;
};
struct StructEnd {
Worker worker;
char str[100];
};
Worker GetWorker(HWND hWnd) {
Worker worker;
GetDlgItemText(hWnd, IDC_LAST_NAME, worker.lastName, 100);
worker.age = GetDlgItemInt(hWnd, IDC_AGE, NULL, FALSE);
worker.experianceAge = GetDlgItemInt(hWnd, IDC_EXPERIANCE_AGE, NULL, FALSE);
worker.countOut = GetDlgItemInt(hWnd, IDC_COUNT, NULL, FALSE);
worker.payment = GetDlgItemInt(hWnd, IDC_PAYMENT, NULL, FALSE);
return worker;
}
void putStudEndIntoStroka(StructEnd& u) {
//swprintf_s(u.str, TEXT(" %-25s ║ %d ║ %d ║ %d ║ %d"), u.worker.lastName, u.worker.age, u.worker.experianceAge, u.worker.countOut,
//u.worker.payment);
//sprintf(u.str, "%-25s ║ %d ║ %d ║ %d", u.worker.lastName, u.worker.age, u.worker.experianceAge,
//u.worker.payment);
snprintf(u.str, sizeof(u.str), "%s | %d | %d | %d", u.worker.lastName, u.worker.age, u.worker.experianceAge,
u.worker.payment);
}