End Google Ads 201810 - BS.net 01 -->
#include <windows.h>
#include <tchar.h>

LRESULT WINAPI WndProc(HWND,UINT,WPARAM,LPARAM);
// Main Function to Create Window
int APIENTRY WinMain(HINSTANCE hInst,HINSTANCE pi,LPSTR,int cmd)
{
WNDCLASSEX wcx;
wcx.lpszClassName=_T("MyClass");
wcx.lpfnWndProc=WndProc;
wcx.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wcx.hCursor=LoadCursor(NULL,IDC_ARROW);
wcx.hIcon=LoadIcon(NULL,IDI_WINLOGO);
wcx.hInstance=hInst;
wcx.cbSize=sizeof(wcx);
wcx.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
wcx.style=CS_HREDRAW|CS_VREDRAW;
wcx.lpszMenuName=NULL;
wcx.cbClsExtra=0;
wcx.cbWndExtra=0;
RegisterClassEx(&wcx);
HWND hWnd=CreateWindowEx(0,_T("MyClass"),_T("My First Window"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInst ,0);
ShowWindow(hWnd,cmd);
UpdateWindow(hWnd);
MSG msg;
while(GetMessage(&msg,hWnd,0,0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0l;
}
// Function used to draw line with fixed endpoints
void DrawLine(HDC hdc)
{
// Move to first point
MoveToEx(hdc,50,50,NULL);
// Draw line to end point
LineTo(hdc,150,150);
}
// Function to handle window events
LRESULT WINAPI WndProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp)
{
PAINTSTRUCT ps;
int xPos,yPos; // represent current mouse position
switch(msg)
{
case WM_PAINT: // Drawing Event
BeginPaint(hWnd,&ps);
DrawLine(ps.hdc);
EndPaint(hWnd,&ps);
break;
case WM_LBUTTONDOWN : // Left Button Event Handling
xPos = LOWORD(lp); // Mouse X-position
yPos = HIWORD(lp); // Mouse Y-position
//InvalidateRect(hWnd,NULL,FALSE); // *******/Repaint window
break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,msg,wp,lp);
}
return 0;
}






دا كووود بيرسم line
بس بمعرفة نقطة البدايه والنهايه
انا عاوزه اعدل الكود دا
بحيث يرسم line
ب mouse



فى انتظار الرد بليييييييييييييييييييييز