1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include "stdafx.h"
#include <Windows.h>
#include "WindowsProject1.h"
#include <stdio.h>
//variable declaration
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
//UART initialization
//500ms timer initialization
for (; ; ) {
// Main message loop:
while (GetMessage(&msg, nullptr, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
ATOM MyRegisterClass(HINSTANCE hInstance)
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message){
case WM_TIMER:
if (WaitCommEvent(hComm, &dwEventMask, NULL))
//read UART data and store it
case WM_PAINT:
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
TCHAR V1[20];
...
...
...
_stprintf_s(V1, TEXT("%.1f m"), Altitude);
TextOut(hdc, 150, 20, V1, _tcslen(V1));
...
...
...
EndPaint(hWnd, &ps);
}
}
|