コード例 #1
0
ファイル: UNICODE.CPP プロジェクト: venkatarajasekhar/repo
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	TCHAR szHello[MAX_LOADSTRING];

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDOK:
					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
					SendMessage (hWnd, WM_CLOSE, 0, 0);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			s_sai.cbSize = sizeof(SHACTIVATEINFO);
			hwndCB = CreateRpCommandBar(hWnd);
			break;
		case WM_PAINT:
			RECT rt;
			hdc = BeginPaint(hWnd, &ps);
			GetClientRect(hWnd, &rt);
			LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
			DrawText(hdc, szHello, _tcslen(szHello), &rt, 
				DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			
			// Call bi-modal function.
			ExtTextOut(hdc, 10, 10, 0, NULL, _T("Call to ExtTextOut"), 18, NULL);

			// Call Unicode-only function.
			ExtTextOutW(hdc, 10, 30, 0, NULL, L"Call to ExtTextOutW", 19, NULL);
			EndPaint(hWnd, &ps);
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
コード例 #2
0
ファイル: CARET.CPP プロジェクト: venkatarajasekhar/repo
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	TCHAR szHello[MAX_LOADSTRING];

	switch (message) 
	{
        HANDLE_MSG(hWnd, WM_KEYDOWN, OnKey);
        HANDLE_MSG(hWnd, WM_KILLFOCUS, OnKillFocus);
        HANDLE_MSG(hWnd, WM_LBUTTONDOWN, OnLButtonDown);
        HANDLE_MSG(hWnd, WM_SETFOCUS, OnSetFocus);
        HANDLE_MSG(hWnd, WM_SIZE, OnSize);
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDOK:
					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
					SendMessage (hWnd, WM_CLOSE, 0, 0);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			s_sai.cbSize = sizeof(SHACTIVATEINFO);
			hwndCB = CreateRpCommandBar(hWnd);
			break;
		case WM_PAINT:
			RECT rt;
			hdc = BeginPaint(hWnd, &ps);
			GetClientRect(hWnd, &rt);
			LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
			DrawText(hdc, szHello, _tcslen(szHello), &rt, 
				DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			EndPaint(hWnd, &ps);
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
コード例 #3
0
ファイル: LIST.CPP プロジェクト: venkatarajasekhar/repo
/*---------------------------------------------------------------------------*\
 |                                                                           |
\*---------------------------------------------------------------------------*/
BOOL OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
{
#define COUNT 10
    TCHAR * tch[] = { TEXT("Japan"), TEXT("Denmark"), TEXT("Albania"),
                            TEXT("Saudi Arabia"), TEXT("Kiribati"),
                            TEXT("Taiwan"), TEXT("Cameroon"), TEXT("Uganda"),
                            TEXT("France"), TEXT("Canada")};
    HWND hwndList;

    HDC        hdc;
    int        i;
    int        x, y, cx, cy;
    TEXTMETRIC tm;

    hdc = GetDC (NULL);
    GetTextMetrics (hdc, &tm);
    ReleaseDC (NULL, hdc);

    x  = 25;
    y  = 25;
    cx = tm.tmAveCharWidth * 25;
    cy = tm.tmHeight * 5;

	hwndList =
	CreateWindowEx(0,                /* Ext-style. */
					TEXT("listbox"), /* Class name.*/
					0L,              /* Title.     */
					WS_BORDER       |/* Style bits.*/
					WS_CHILD        |
					WS_VISIBLE      |
					WS_CLIPSIBLINGS |
					WS_VSCROLL      |
					LBS_NOTIFY      |
					LBS_SORT,
					x,               /* x.         */
					y,               /* y.         */
					cx,              /* cx.        */
					cy,              /* cy.        */
					hWnd,            /* Parent.    */
					(HMENU)ID_LIST,  /* Child Id.  */
					hInst,           /* Creator.   */
					NULL);           /* Params.    */

    for (i=0;i<COUNT;i++)
    {
        SendMessage (hwndList, LB_ADDSTRING, 0,
                     (LONG)(LPTSTR)tch[i]);
    }

	s_sai.cbSize = sizeof(SHACTIVATEINFO);
	hwndCB = CreateRpCommandBar(hWnd);

    return TRUE;
}
コード例 #4
0
ファイル: EDITOR.CPP プロジェクト: venkatarajasekhar/repo
/*---------------------------------------------------------------------------*\
 |                                                                           |
\*---------------------------------------------------------------------------*/
BOOL OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
{
    hwndEdit = CreateWindow (TEXT("edit"),    /* Class name.   */
                        0,                    /* Title.        */
                        WS_CHILD       |      /* Style bits.   */
                        WS_VISIBLE     |
                        WS_VSCROLL     |
                        WS_BORDER      |
                        ES_LEFT        |
                        ES_MULTILINE,
                        0,                    /* x.            */
                        0,                    /* y.            */
                        300,                    /* cx.           */
                        300,                    /* cy.           */
                        hWnd,                 /* Parent.       */
                        (HMENU)100,           /* Child Id.     */
                        hInst,                /* Creator.      */
                        NULL);                /* Params.       */

	s_sai.cbSize = sizeof(SHACTIVATEINFO);
	hwndCB = CreateRpCommandBar(hWnd);

    return TRUE;
}
コード例 #5
0
ファイル: UPnP Light.cpp プロジェクト: optman/upnpstack
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	wchar_t* str;
	wchar_t* s;
	HBRUSH brush;
	COLORREF color;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDOK:
				case IDM_EXIT:
					SendMessage(hWnd, WM_CLOSE, 0, 0);
					break;
				case ID_FILE_TOGGLESWITCH:
					SwitchPower = !SwitchPower;
					InvalidateRect(hWndMainWindow,NULL,false);
					UPnPSetState_SwitchPower_Status(UPnPmicroStack,SwitchPower);
					break;
				case ID_FILE_DIMMERUP:
					DimmingService += 20;
					if (DimmingService > 100) DimmingService = 100;
					InvalidateRect(hWndMainWindow,NULL,false);
					UPnPSetState_DimmingService_LoadLevelStatus(UPnPmicroStack,DimmingService);
					break;
				case ID_FILE_DIMMERDOWN:
					DimmingService -= 20;
					if (DimmingService < 0) DimmingService = 0;
					InvalidateRect(hWndMainWindow,NULL,false);
					UPnPSetState_DimmingService_LoadLevelStatus(UPnPmicroStack,DimmingService);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CLOSE:
			ILibStopChain(UPnPmicroStackChain);
			break;
		case WM_CREATE:
			g_hwndCB = CreateRpCommandBar(hWnd);
            // Initialize the shell activate info structure
            memset (&s_sai, 0, sizeof (s_sai));
            s_sai.cbSize = sizeof (s_sai);
			UPnPThread = CreateThread(NULL, 0, &UPnPMain, 0, 0, NULL ); 
			break;
		case WM_PAINT:
			RECT rt;

			hdc = BeginPaint(hWnd, &ps);

			color = RGB(128,128,128);
			if (SwitchPower == true)
			{
				color = RGB(128+DimmingService,128+DimmingService,128-DimmingService);
			}

			GetClientRect(hWnd, &rt);
			brush = CreateSolidBrush(color);
			SetBkColor(hdc,color);
			FillRect(hdc,&rt,brush);
			DeleteObject(brush);

			if (SwitchPower == true) s = TEXT("ON"); else s = TEXT("OFF");
			str = (unsigned short*)malloc(400);
			swprintf(str,TEXT("Power %s, Dimmer %d"),s,DimmingService);
			DrawText(hdc, str, -1, &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			free(str);

			EndPaint(hWnd, &ps);
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(g_hwndCB);
			PostQuitMessage(0);
			break;
		case WM_ACTIVATE:
            // Notify shell of our activate message
			SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
     		break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
コード例 #6
0
ファイル: RASTER.CPP プロジェクト: venkatarajasekhar/repo
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDOK:
					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
					SendMessage (hWnd, WM_CLOSE, 0, 0);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			s_sai.cbSize = sizeof(SHACTIVATEINFO);
			hwndCB = CreateRpCommandBar(hWnd);
			break;
		case WM_PAINT:
		{
			hdc = BeginPaint(hWnd, &ps);
			HDC hdcBitmap;
			HBITMAP hbm, hbmOld;
			HBRUSH hbr, hbrOld;

			// Create bitmap & DC.
			{
				hdcBitmap = CreateCompatibleDC(hdc);
				hbm = CreateCompatibleBitmap(hdc, 100, 100);
				hbmOld = SelectBitmap(hdcBitmap, hbm);
			}

			// Draw into bitmap and copy bitmap to drawing surface.
			{
				SelectObject(hdcBitmap, GetStockObject(GRAY_BRUSH));
				Rectangle(hdcBitmap, 0, 0, 100, 100);

				SelectObject(hdcBitmap, GetStockObject(WHITE_BRUSH));
				Rectangle(hdcBitmap, 20, 20, 80, 80);

				SelectObject(hdcBitmap, GetStockObject(BLACK_BRUSH));
				Rectangle(hdcBitmap, 40, 40, 60, 60);

				SetTextColor(hdcBitmap, RGB(255, 0, 0));
				ExtTextOut(hdcBitmap, 5, 5, 0, NULL, TEXT("Hello World"), 11, NULL);

				BitBlt(hdc, 0, 0, 100, 100, hdcBitmap, 0, 0, SRCCOPY);

			}

			// Cleanup bitmap & DC.
			{
				SelectObject(hdc, hbmOld);
				DeleteDC(hdcBitmap);
				DeleteObject(hbm);
			}

			// Fill an area with a blue brush.
			hbr = CreateSolidBrush(RGB(0, 0, 255));
			hbrOld = SelectBrush(hdc, hbr);
			BitBlt(hdc, 10,  110, 80, 20, NULL, 0, 0, PATCOPY);
			SelectObject(hdc, hbrOld);
			DeleteObject(hbr);

			BitBlt(hdc, 20, 140, 40, 40, NULL, 0, 0, BLACKNESS);
			BitBlt(hdc, 30, 150, 20, 20, NULL, 0, 0, WHITENESS);
			EndPaint(hWnd, &ps);
		}
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
コード例 #7
0
ファイル: BootBlaster.cpp プロジェクト: mobiaqua/tools
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;

	switch (message) 
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam); 
		wmEvent = HIWORD(wParam); 
		// Parse the menu selections:
		switch (wmId)
		{	
		case IDM_HELP_ABOUT:
			DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
			break;
		case IDM_FILE_EXIT:
			SendMessage (hWnd, WM_CLOSE, 0, 0);
			break;
		case IDM_FLASH_ERASE:
			if (gSystemErrorHasOccured != TRUE){
				LoadString(hInst, IDS_FLASH_ERASE, szStatus, MAX_LOADSTRING);
				InvalidateRect(hWnd,NULL,TRUE);
				UpdateWindow(hWnd);
				Sleep(100);
				EraseFlash(hWnd);
				LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING);
				InvalidateRect(hWnd,NULL,TRUE);
				UpdateWindow(hWnd);
				Sleep(100);
						
			}
			else
				SystemErrorAlert(hWnd);
			break;
		case IDM_FLASH_TEST_TIMED:
			LoadString(hInst, IDS_FLASH_TEST_TIMED, szStatus, MAX_LOADSTRING);
			InvalidateRect(hWnd,NULL,TRUE);
			gTimerID = SetTimer(hWnd,BB_TEST_FLASH,50,NULL);
			break;
		case IDM_FLASH_TEST_STRAIGHT:
			TestFlash(hWnd);
			break;
		case IDM_FLASH_SAVE:
			LoadString(hInst, IDS_FLASH_SAVE_BL, szStatus, MAX_LOADSTRING);					
			InvalidateRect(hWnd,NULL,TRUE);
			UpdateWindow(hWnd);
			Sleep(100);
			SaveFlash(hWnd);
			LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING);
			InvalidateRect(hWnd,NULL,TRUE);
			UpdateWindow(hWnd);
			Sleep(100);
			break;
		case IDM_FLASH_SAVE_WINCE:
			LoadString(hInst, IDS_FLASH_SAVE_WINCE, szStatus, MAX_LOADSTRING);					
			InvalidateRect(hWnd,NULL,TRUE);
			UpdateWindow(hWnd);
			Sleep(100);
			SaveFlashWince(hWnd);
			LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING);
			InvalidateRect(hWnd,NULL,TRUE);
			UpdateWindow(hWnd);
			Sleep(100);
			break;
		case IDM_FLASH_PROTECT_WINCE:
			LoadString(hInst, IDS_FLASH_PROTECT_WINCE, szStatus, MAX_LOADSTRING);					
			InvalidateRect(hWnd,NULL,TRUE);
			UpdateWindow(hWnd);
			Sleep(100);
			ProtectWince(hWnd);
			LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING);
			InvalidateRect(hWnd,NULL,TRUE);
			UpdateWindow(hWnd);
			Sleep(100);
			break;
		case IDM_FLASH_SAVE_GZ:
			LoadString(hInst, IDS_FLASH_SAVE_BL_GZ, szStatus, MAX_LOADSTRING);					
			InvalidateRect(hWnd,NULL,TRUE);
			UpdateWindow(hWnd);
			Sleep(100);
			SaveFlashGZ(hWnd);
			LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING);
			InvalidateRect(hWnd,NULL,TRUE);
			UpdateWindow(hWnd);
			Sleep(100);
			break;
		case IDM_FLASH_PROGRAM:
			if (gSystemErrorHasOccured != TRUE){
				if (LoadImage(hWnd) != TRUE) //loaded, so program it
					return 0;
				LoadString(hInst, IDS_FLASH_PROTECT_WINCE, szStatus, MAX_LOADSTRING);
				InvalidateRect(hWnd,NULL,TRUE);
				UpdateWindow(hWnd);
				Sleep(100);
				ProtectWince(hWnd);

				if (gSystemErrorHasOccured == TRUE)
					return 0;

				LoadString(hInst, IDS_FLASH_ERASE, szStatus, MAX_LOADSTRING);
				InvalidateRect(hWnd,NULL,TRUE);
				UpdateWindow(hWnd);
				Sleep(100);
				EraseFlash(hWnd);

				LoadString(hInst, IDS_FLASH_PROGRAM, szStatus, MAX_LOADSTRING);
				InvalidateRect(hWnd,NULL,FALSE);
				UpdateWindow(hWnd);
				Sleep(100);
				if (ProgramFlash(hWnd) == TRUE)
					VerifyFlash(hWnd);						
				LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING);
				InvalidateRect(hWnd,NULL,TRUE);
				UpdateWindow(hWnd);
				Sleep(100);
			}
			else
				SystemErrorAlert(hWnd);
			break;
		case IDM_FLASH_PROGRAM_XPLE:
			if (gSystemErrorHasOccured != TRUE){
				if (LoadImage(hWnd) != TRUE) //loaded, so program it
					return 0;
				for (int i=0; i < 50; i++){
					LoadString(hInst, IDS_FLASH_PROTECT_WINCE, szStatus, MAX_LOADSTRING);
					InvalidateRect(hWnd,NULL,TRUE);
					UpdateWindow(hWnd);
					Sleep(100);
					ProtectWince(hWnd);

					if (gSystemErrorHasOccured == TRUE)
						return 0;

					LoadString(hInst, IDS_FLASH_ERASE, szStatus, MAX_LOADSTRING);
					InvalidateRect(hWnd,NULL,TRUE);
					UpdateWindow(hWnd);
					Sleep(100);
					EraseFlash(hWnd);

					LoadString(hInst, IDS_FLASH_PROGRAM, szStatus, MAX_LOADSTRING);
					InvalidateRect(hWnd,NULL,FALSE);
					UpdateWindow(hWnd);
					Sleep(100);
					ProgramFlash(hWnd);
					LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING);
					InvalidateRect(hWnd,NULL,TRUE);
					UpdateWindow(hWnd);
					Sleep(100);
				}
				VerifyFlash(hWnd);
			}
			else
				SystemErrorAlert(hWnd);
			break;
				
		case IDM_FLASH_SHOW:
			ShowFlash(hWnd);
			break;
		case IDM_FLASH_VERIFY:
			VerifyFlash(hWnd);
			break;
		case IDOK:
			//SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
			//SendMessage (hWnd, WM_CLOSE, 0, 0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_TIMER:
		// this method isn;t used anymore, really
		KillTimer(hWnd,wParam);
		if (wParam == BB_TEST_FLASH){
			TestFlash(hWnd);
			LoadString(hInst, IDS_IDLE, szStatus, MAX_LOADSTRING);
			InvalidateRect(hWnd,NULL,TRUE);
		}
		else{}

	case WM_CREATE:
		hwndCB = CreateRpCommandBar(hWnd);
		break;
	case WM_PAINT:
		RECT rt;
		hdc = BeginPaint(hWnd, &ps);
		GetClientRect(hWnd, &rt);
		DrawText(hdc, szStatus, _tcslen(szStatus), &rt, 
			 DT_CENTER);
		EndPaint(hWnd, &ps);
		break; 
	case WM_DESTROY:
		CommandBar_Destroy(hwndCB);
		PostQuitMessage(0);
		break;
	case WM_SETTINGCHANGE:
		SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
コード例 #8
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	TCHAR szHello[MAX_LOADSTRING];

	TCHAR szMsgDbg[1000];

	wsprintf(szMsgDbg, TEXT("rcvd msg #%d (0x%04X)\n"), message, message);
	OutputDebugStringW(szMsgDbg);

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDM_TEST:
					main();
					break;
				case IDOK:
					SendMessage (hWnd, WM_CLOSE, 0, 0);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_KILLFOCUS:
			SendMessage (hWnd, WM_CLOSE, 0, 0);
			break;
		case WM_CREATE:
			g_hwndCB = CreateRpCommandBar(hWnd);
            // Initialize the shell activate info structure
            memset (&s_sai, 0, sizeof (s_sai));
            s_sai.cbSize = sizeof (s_sai);
			break;
		case WM_PAINT:
			RECT rt;
			hdc = BeginPaint(hWnd, &ps);
			GetClientRect(hWnd, &rt);
			LoadString(g_hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
			DrawText(hdc, szHello, _tcslen(szHello), &rt, 
				DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			EndPaint(hWnd, &ps);
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(g_hwndCB);
			PostQuitMessage(0);
			break;
		case WM_CLOSE:
			DestroyWindow(hWnd);
			break;
		case WM_ACTIVATE:
            // Notify shell of our activate message
			SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
     		break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
コード例 #9
0
ファイル: SAVE.CPP プロジェクト: venkatarajasekhar/repo
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	TCHAR szHello[MAX_LOADSTRING];

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_SAVE:
				{
					TCHAR szPathName[_MAX_PATH];
					OPENFILENAME ofn;
					int cbSize = sizeof(OPENFILENAME);

					szPathName[0] = 0;

					memset(&ofn, 0, cbSize);

					ofn.lStructSize = cbSize;
					ofn.hwndOwner = hWnd;
					ofn.lpstrFilter = TEXT("Text files\0*.txt\0All files\0*.*\0");
					ofn.lpstrCustomFilter = NULL;
					ofn.nFilterIndex = 1;
					ofn.lpstrFile = szPathName;
					ofn.nMaxFile = sizeof(szPathName) / sizeof(TCHAR);
					ofn.Flags = OFN_OVERWRITEPROMPT | OFN_SHOWHELP;
					ofn.lpstrDefExt = TEXT("txt");

					GetSaveFileName(&ofn);

					MessageBox(hWnd, szPathName, _T("File Name Selected"), MB_OK);
				}
				    break;
				case IDM_HELP_ABOUT:
					DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDOK:
					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
					SendMessage (hWnd, WM_CLOSE, 0, 0);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			s_sai.cbSize = sizeof(SHACTIVATEINFO);
			hwndCB = CreateRpCommandBar(hWnd);
			break;
		case WM_PAINT:
			RECT rt;
			hdc = BeginPaint(hWnd, &ps);
			GetClientRect(hWnd, &rt);
			LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
			DrawText(hdc, szHello, _tcslen(szHello), &rt, 
				DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			EndPaint(hWnd, &ps);
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
コード例 #10
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	unsigned short* str[100];
	RECT rt;
	int i;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDOK:
					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
					SendMessage(hWnd, WM_CLOSE, 0, 0);
					break;
				case ID_TOOLS_EXIT:
					ILibStopChain(TheChain);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			g_hwndCB = CreateRpCommandBar(hWnd); // Initialize the shell activate info structure

			// Clear up all of the active transfers.
			for (i=0;i<10;i++) {g_DownloadStatsMapping[i] = -1;}

			// Load all of the icon resources we will need to draw the UI.
			HICON_MEDIASERVER  = LoadIcon(g_hInst, (LPCTSTR)IDI_MEDIASERVER);
			HICON_MEDIASERVER2 = LoadIcon(g_hInst, (LPCTSTR)IDI_MEDIASERVER2);
			HICON_RIGHTARROW   = LoadIcon(g_hInst, (LPCTSTR)IDI_RIGHTARROW);
			HICON_LEFTARROW    = LoadIcon(g_hInst, (LPCTSTR)IDI_LEFTARROW);

			// Create the Micro Media Server thread. This thread will exist for
			// the duration of the application and will be owned by the media
			// server library.
			CreateThread(NULL, 0, &UPnPMain, 0, 0, NULL ); 

            memset (&s_sai, 0, sizeof (s_sai));
            s_sai.cbSize = sizeof (s_sai);

			break;
		case WM_PAINT:
		
			// Paint the complete screen here. Quite workout to get the UI looking
			// event half decent using Win32 directly.
			GetClientRect(hWndMainWindow, &rt);
			hdc = BeginPaint(hWnd, &ps);
			
			// Paint the top portion of the screen
			RECT r;
			r.left = 1;
			r.right = rt.right-1;
			r.top = 0;
			r.bottom = 40;
			FillRect(hdc,&r,GetSysColorBrush(COLOR_SCROLLBAR));
			DrawEdge(hdc,&r,EDGE_RAISED,BF_RECT);
			DrawIcon(hdc,8,5,HICON_MEDIASERVER2);
			SetBkColor(hdc,GetSysColor(COLOR_SCROLLBAR));
			
			// Paint the title
			r.left = 50;
			r.right = rt.right-1;
			r.top = 4;
			r.bottom = 50;
			DrawText(hdc,TEXT("Intel Micro Media Server"),-1,&r,0);

			// Paint the transfer count stat label & value
			r.left = 50;
			r.right = rt.right-1;
			r.top = 20;
			r.bottom = 50;
			if (MmsCurrentTransfersCount == 0)
			{
				DrawText(hdc,TEXT("No File Transfers          "),-1,&r,0);
			}
			if (MmsCurrentTransfersCount == 1)
			{
				DrawText(hdc,TEXT("1 File Transfer          "),-1,&r,0);
			}
			if (MmsCurrentTransfersCount > 1)
			{
				wsprintf((unsigned short*)str,TEXT("%d File Transfers        "),MmsCurrentTransfersCount);
				DrawText(hdc,(unsigned short*)str,-1,&r,0);
			}

			// Paint the main portion of the screen
			r.left = 1;
			r.right = rt.right-1;
			r.top = 42;
			r.bottom = 267;
			FillRect(hdc,&r,GetSysColorBrush(COLOR_SCROLLBAR));

			// Paint global media server stats labels
			r.left = 8;
			r.right = 150;
			r.top = 50;
			r.bottom = 70;
			DrawText(hdc,TEXT("Browse Requests"),-1,&r,0);
			r.left = 8;
			r.right = 150;
			r.top = 70;
			r.bottom = 90;
			DrawText(hdc,TEXT("HTTP Requests"),-1,&r,0);

			// Paint global media server stats values
			wsprintf((unsigned short*)str,TEXT("%d"),MmsBrowseCount);
			r.left = 180;
			r.right = rt.right-5;
			r.top = 50;
			r.bottom = 70;
			DrawText(hdc,(unsigned short*)str,-1,&r,DT_RIGHT);
			wsprintf((unsigned short*)str,TEXT("%d"),MmsHttpRequestCount);
			r.left = 180;
			r.right = rt.right-5;
			r.top = 70;
			r.bottom = 90;
			DrawText(hdc,(unsigned short*)str,-1,&r,DT_RIGHT);

			// Paint the transfer window edge
			r.left = 2;
			r.right = rt.right-1;
			r.top = 94;
			r.bottom = 264;
			DrawEdge(hdc,&r,EDGE_SUNKEN,BF_RECT);

			// Paint the white transfer window
			r.left = 4;
			r.right = rt.right-5;
			r.top = 96;
			r.bottom = 262;
			FillRect(hdc,&r,GetSysColorBrush(COLOR_MENU));

			// Draw all of the active transfers on the screen (up to 5)
			for (i=0;i<5;i++)
			{
				DrawTransferInfo(hdc,i,g_DownloadStatsMapping[i]);
			}

			EndPaint(hWnd, &ps);
			break;

		case WM_CLOSE:
			ILibStopChain(TheChain);
			break;
		case WM_DESTROY:
			DestroyIcon(HICON_MEDIASERVER);
			DestroyIcon(HICON_MEDIASERVER2);
			DestroyIcon(HICON_RIGHTARROW);
			DestroyIcon(HICON_LEFTARROW);
			CommandBar_Destroy(g_hwndCB);
			PostQuitMessage(0);
			break;
		case WM_ACTIVATE:
            // Notify shell of our activate message
			SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
     		break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
コード例 #11
0
ファイル: VECTOR.CPP プロジェクト: venkatarajasekhar/repo
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDOK:
					SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
					SendMessage (hWnd, WM_CLOSE, 0, 0);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_CREATE:
			s_sai.cbSize = sizeof(SHACTIVATEINFO);
			hwndCB = CreateRpCommandBar(hWnd);
			break;
		case WM_PAINT:
		{
			hdc = BeginPaint(hWnd, &ps);

			HPEN hpen1, hpen2;
			HBRUSH hbr1, hbr2;

			hpen1 = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
			hpen2 = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
			hbr1 = CreateSolidBrush(RGB(0, 255, 0));
			hbr2 = CreateSolidBrush(RGB(0, 255, 255));

			SelectObject(hdc, hpen1);
			POINT pt[2];
			pt[0].x = 10;
			pt[0].y = 10;
			pt[1].x = 110;
			pt[1].y = 10;
			Polyline(hdc, pt, 2);

			SelectObject(hdc, hbr1);
			Rectangle(hdc, 40, 40, 80, 80);

			SelectObject(hdc, hpen2);
			pt[0].x = 20;
			pt[0].y = 20;
			pt[1].x = 20;
			pt[1].y = 120;
			Polyline(hdc, pt, 2);

			SelectObject(hdc, hbr2);
			Rectangle(hdc, 100, 100, 150, 150);

			// Clean Up all objects created.
			SelectObject(hdc, GetStockObject(BLACK_PEN));
			SelectObject(hdc, GetStockObject(WHITE_BRUSH));
			DeleteObject(hpen1);
			DeleteObject(hpen2);
			DeleteObject(hbr1);
			DeleteObject(hbr2);
			EndPaint(hWnd, &ps);
		}
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(hwndCB);
			PostQuitMessage(0);
			break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}