“函数”: 从“char [7]”到“LPCWSTR”的类型不兼容
“函数”: 从“char [7]”到“LPCWSTR”的类型不兼容Main.c
#include "stdafx.h"
#include "Win32Project15.h"
#include"Resource.h"
#include<COMMCTRL.H>
#pragma comment(lib,"comctl32.lib")
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nCmdShow)
{
InitCommonControls();
DialogBox(hPrevInstance,MAKEINTRESOURCE(IDD_MAIN),NULL,Main_Proc);
return 0;
}
Win32Project15.c
#include "stdafx.h"
#include<windows.h>
#include<windowsx.h>
#include"Resource.h"
#include "Win32Project15.h"
#pragma comment(lib,"comctl32.lib")
BOOL WINAPI Main_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
HANDLE_MSG(hwnd, WM_INITDIALOG, Main_onlnicDialog);
HANDLE_MSG(hwnd, WM_COMMAND, Main_onCommand);
HANDLE_MSG(hwnd, WM_CLOSE, Main_Close);
}
return FALSE;
}
BOOL Main_onlnicDialog(HWND hwnd, HWND hwndm, LPARAM lParam)
{
return TRUE;
}
void Main_onCommand(HWND hwnd, int id, HWND hwndCTl, UINT codeNotify)
{
switch (id)
{
case IDOK:
{
TCHAR name[256];
GetDlgItemText(hwnd, IDC_EDITNAME,name , sizeof(name));
TCHAR msg[256];
wsprintf(msg,"%s你好",name);
MessageBox(hwnd, msg, msg, MB_OK);
break;
}
default:
break;
}
}
void Main_Close(HWND hwnd)
{
EndDialog(hwnd, 0);
}
Win32Project15.h
#pragma once
#include "resource.h"
#ifndef __WIN32PROJECT_H__
#define __WIN32PROJECT_H__
BOOL WINAPI Main_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL Main_onlnicDialog(HWND hwnd, HWND hwndm, LPARAM lParam);
void Main_onCommand(HWND hwnd, int id, HWND hwndCTl, UINT codeNotify);
void Main_Close(HWND hwnd);
#endif