For Tyro

Discussion in 'Programming General' started by Govind, Dec 25, 2010.

For Tyro
  1. Unread #1 - Dec 25, 2010 at 4:17 PM
  2. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    For Tyro

    Code:
    #define IDT_TIMER1 1001
    #include <Windows.h>
    LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
    BOOL CALLBACK FontProc(HWND hWnd, LPARAM lParam);
    VOID CALLBACK TimerProc(HWND hWnd, UINT Msg, UINT_PTR idEvent, DWORD dwTime);
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
    	WNDCLASSEX wc;
    	MSG msg;
    	HWND hwnd, hCursor;
    	wc.cbClsExtra = 0;
    	wc.cbSize = sizeof(WNDCLASSEX);
    	wc.cbWndExtra = 0;
    	wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
    	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    	wc.hInstance = hInstance;
    	wc.lpfnWndProc = WndProc;
    	wc.lpszClassName = TEXT("CurPosWnd");
    	wc.lpszMenuName = NULL;
    	wc.style = 0;
    
    	RegisterClassEx(&wc);
    
    	hwnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, TEXT("CurPosWnd"), TEXT("Cursor"), WS_VISIBLE | WS_SYSMENU, 10, 10, 100, 100, NULL, NULL, hInstance, NULL);
    	hCursor = CreateWindowEx(0, TEXT("STATIC"), TEXT("0, 0"), WS_VISIBLE | WS_CHILD, 10, 25, 70, 20, hwnd, NULL, hInstance, NULL);
    
    	ShowWindow(hwnd, SW_SHOW);
    	EnumChildWindows(hwnd, FontProc, 0);
    	SetTimer(hwnd, IDT_TIMER1, 50, TimerProc);
    	UpdateWindow(hwnd);
    	//PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
    	while(GetMessage(&msg, NULL, 0, 0) > 0)
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    	return msg.wParam;
    
    }
    
    VOID CALLBACK TimerProc(HWND hWnd, UINT Msg, UINT_PTR idEvent, DWORD dwTime)
    {
    	HWND hCursor = FindWindowEx(hWnd, 0, TEXT("STATIC"), NULL);
    	TCHAR cursorBuf[20];
    	POINT p;
    	GetCursorPos(&p);
    	wsprintf(cursorBuf, TEXT("(%d, %d)"), p.x, p.y);
    	SetWindowText(hCursor, cursorBuf);	
    }
    
    BOOL CALLBACK FontProc(HWND hWnd, LPARAM lParam)
    {
    	HFONT hfDefault = (HFONT) GetStockObject(DEFAULT_GUI_FONT);
    	SendMessage(hWnd, WM_SETFONT, (WPARAM) hfDefault, MAKELPARAM(FALSE, 0));
    	return TRUE;
    }
    LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
    	switch(Msg)
    	{
    	case WM_CLOSE:
    		DestroyWindow(hWnd);
    		break;
    	case WM_DESTROY:
    		KillTimer(hWnd, IDT_TIMER1);
    		PostQuitMessage(0);
    		break;
    	default:
    		return DefWindowProc(hWnd, Msg, wParam, lParam);
    	}
    	return 0;
    }
    
    Coordinate-finder source.
     
< This is a PROGRAMMING forum | Is there any way to build rs bots with visual basic? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site