LPTSTR
からに変換する必要がありLPCWSTR
ます。から取得LPTSTR
しているのでGetDlgItemText
、ExtTextOut
これが必要ですLPCWSTR
。
編集: から値を渡す前に、値をGetDlgItemText
に保存しますstd::vector
。その後、から値を取得するstd::vector
と、空/意味不明なメッセージが返されます。
ダイアログボックス:
WORD lineLength = (WORD) SendDlgItemMessage(hwnd,IDC_EDIT1, EM_LINELENGTH, (WPARAM) 0, (LPARAM) 0);
if(lineLength > 0){
TCHAR line[16];
int number = GetDlgItemTextW(hwnd, IDC_EDIT1, line, 16);
HWND parent = (HWND)GetWindowLongPtr(hwnd, GWLP_HWNDPARENT);
LPCWSTR line2(line);
SendMessage(parent, WM_COMMAND, MAKEWPARAM(ADD_COMBO_ITEM,0), (LPARAM)line);
親ウィンドウにメッセージが送信され、この値がベクトル ( push_back
) に追加されます。親ウィンドウを持つクラス:
std::vector<LPCWSTR> comboItems
これは、次を使用して値を出力するために使用する関数の一部ですExtTextOut
。
RECT temp;
temp.left = listItemWidth;
temp.right = width;
SetBkColor(hdc, RGB(240,240,260));
LPCWSTR comboName = L"";
for(std::vector<item>::size_type i=0; i != comboItems.size(); i++){
temp.left = listItemWidth;
temp.right = width;
temp.top = (currentlyClicked + 1) * listItemHeight + i * listItemHeight;
temp.bottom = temp.top + listItemHeight;
comboName = comboItems[i];
ExtTextOut(hdc, temp.left+2, temp.top + 1, ETO_OPAQUE,
&temp, comboName, lstrlen(comboName), 0);
DrawEdge(hdc, &temp, EDGE_RAISED, BF_RECT | BF_FLAT | BF_ADJUST);
}