i'm just start to learn C++ for Win and now i at the three part of tut . so i have this code :
#include <Windows.h>
#include <stdio.h>
#define WIN_WIDTH 300
#define WIN_HEIGHT 200
#define class_name L"HDC"
LRESULT CALLBACK WinProc(HWND hwnd , UINT Message ,WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hinstance ,HINSTANCE hPrev,PSTR cmdline ,int ishow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wndclassex ={0};
wndclassex.style = CS_HREDRAW | CS_VREDRAW;
wndclassex.cbSize = sizeof(wndclassex);
wndclassex.lpfnWndProc;
wndclassex.hInstance = hinstance;
wndclassex.lpszClassName = class_name;
wndclassex.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
RegisterClassEx(&wndclassex);
hwnd = CreateWindow(class_name,L"My Second WinDow Application",
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
WIN_WIDTH,WIN_HEIGHT,NULL,NULL,hinstance,NULL);
if(!hwnd)
return EXIT_FAILURE;
HDC hdc = GetDC(hwnd);
if(!hdc)
return EXIT_FAILURE;
ShowWindow(hwnd,ishow);
UpdateWindow(hwnd);
RECT shen;
GetClientRect(hwnd,&shen);
FillRect(hdc,&shen,(HBRUSH)GetStockObject(WHITE_BRUSH));
while(1)
{
if(PeekMessage(&msg,hwnd,0,0,PM_REMOVE))
{
if(msg.message==WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
ReleaseDC(hwnd,hdc);
UnregisterClass(class_name,hinstance);
return msg.wParam;
}
LRESULT CALLBACK DefWinProc(HWND hwnd,UINT Message,WPARAM wParam ,LPARAM lParam)
{
switch(Message)
{
case WM_DESTROY:
case WM_CLOSE:
PostQuitMessage(0);
return 0;
}
return DefWinProc(hwnd,Message,wParam,lParam);
}
but i'm not lucky the system notice that :
'device context.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'device context.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Symbols loaded (source information stripped).
'device context.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Symbols loaded (source information stripped).
First-chance exception at 0x00000000 in device context.exe: 0xC0000005: Access violation.
First-chance exception at 0x00000000 in device context.exe: 0xC0000005: Access violation.
First-chance exception at 0x00000000 in device context.exe: 0xC0000005: Access violation.
The program '[15148] device context.exe: Native' has exited with code 1 (0x1).
Please Somebody know that error just help me fix it , I'm just wanna lean window Programming . Thank you first.