1

LPTSTRからに変換する必要がありLPCWSTRます。から取得LPTSTRしているのでGetDlgItemTextExtTextOutこれが必要です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);
}
4

3 に答える 3

2

これは、 を介して行うことができますMultiByteToWideChar

于 2013-06-14T17:55:09.840 に答える