468,512 Members | 1,426 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

making triangle

2
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;

}
Aug 5 '06 #1
2 4000
blue_i
2
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;

}
Aug 5 '06 #2
Banfa
9,056 Expert Mod 8TB
Please tell me that how can i add the Triangle code in WM_PAINT i tried but failed. please this problem
This doesn't really make sense, what do you want to draw?

The outline of a triangle? The use MoveTo and LineTo or PolyLine or PolyLineTo

A filled triangle? then use Polygon
Aug 5 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by coinjo | last post: by
16 posts views Thread by VISHNU VARDHAN REDDY UNDYALA | last post: by
geo039
reply views Thread by geo039 | last post: by
19 posts views Thread by lost1 | last post: by
2 posts views Thread by nuimstudent | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.