Please tell me that how can i add the Triangle code in WM_PAINT i tried but failed. please this problem
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX mainWindow; // The Structure that will hold the Properties set for the Main Window of the Program
ATOM registeredWindow; // The Atom that will hold the internal identifier for the Main Window
MSG messageStructure; // Represents the Window Message Sent to the Window
HWND mainWindowHandle; // The Handle to Main Window
mainWindow.cbSize = sizeof(WNDCLASSEX);
// gray background brush
mainWindow.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
// defining cursor of type arrow
mainWindow.hCursor = LoadCursor(hInstance, IDC_ARROW);
mainWindow.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
// defining default icon
mainWindow.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
// handle to instance
mainWindow.hInstance = hInstance;
// points to window procedure
mainWindow.lpfnWndProc = (WNDPROC)WindowProcedure;
// name of window class
mainWindow.lpszClassName = "WindowApp";
// no menu
mainWindow.lpszMenuName = NULL;
// setting window style to top most
mainWindow.style = WS_EX_TOPMOST;
// no extra window memory
mainWindow.cbWndExtra = 0;
// no extra class memory
mainWindow.cbClsExtra = 0;
// Register the window class, if fail quit the program
if(registeredWindow = (RegisterClassEx(&mainWindow)) == NULL)
return 0;
// creating tiled window
mainWindowHandle = CreateWindowEx(
0, // extended possibilites for variation
"WindowApp", // Classname
"WndApi", // Title Text
WS_TILEDWINDOW , // Tiled window
CW_USEDEFAULT, // Windows decides the position
CW_USEDEFAULT, // where the window ends up on the screen
250, // The programs width
280, // and height in pixels
HWND_DESKTOP, // The window is a child-window to desktop
NULL, // No menu
hInstance, // Program Instance handler
NULL // No Window Creation data
);
// Make the window visible on the screen
ShowWindow(mainWindowHandle,nCmdShow);
UpdateWindow(mainWindowHandle);
// run the message loop. It will run until GetMessage( ) returns 0
while(GetMessage(&messageStructure, NULL, 0, 0)!=NULL)
{
// translate virtual-key messages into character messages
TranslateMessage(&messageStructure);
// send message to WindowProcedure
DispatchMessage(&messageStructure);
}
// the program return value is 0 - The value that PostQuitMessage( ) gave
return 0;
}
// This function is called by the Windows function DispatchMessage( )
LRESULT CALLBACK WindowProcedure(HWND mainWindowHandle, int message, WPARAM wparam, LPARAM lParam )
{
switch (message)
{
case WM_PAINT:
PAINTSTRUCT ps;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(mainWindowHandle, message, wparam, lParam);
}
return 0;
}