|
|
#1 |
|
FFR Player
Join Date: Jun 2006
Location: New York
Age: 34
Posts: 504
|
EDIT: Sorry this is in the wrong forum, could a moderator move it please?
![]() Hello all ![]() I am trying to learn c++ for win32 apps in Visual Studio 2005. I followed a tutorial here: http://www.winprog.org/tutorial/simple_window.html but the code doesn't work in 2005. I got it to work by adding (LPCWSTR) before all the errors saying it couldn't convert. Now it runs, but it has Chinese text in the title, when it is supposed to say Random1Pscho :s Here is the code, just compile it in Visual Studio 2005 and run. I have no idea why it has chinese characters, can anybody here help? Code:
#include <windows.h>
const char g_szClassName[] = "myWindowClass";
const char name[] = "Random1Pscho";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_CROSS);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+4);
wc.lpszMenuName = NULL;
wc.lpszClassName = (LPCWSTR)g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, (LPCWSTR)"Window Registration Failed!", (LPCWSTR)"Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
(LPCWSTR)g_szClassName,
(LPCWSTR)name,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 350, 150,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL,(LPCWSTR)"Window Creation Failed!",(LPCWSTR)"Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
Last edited by RandomPscho; 12-22-2006 at 05:17 AM.. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|