Deutsch

Воспоминание Embedded ч2 27.11.2024

3 дня назад, 21:26
Re: Воспоминание Embedded ч2 27.11.2024
 
uscheswoi_82 коренной житель
uscheswoi_82
в ответ uscheswoi_82 3 дня назад, 19:24

Сегодня пойдёт речь о Microsoft Smartphone 2002.

Короче был прототип такой у Microsoft, назывался Stinger:



Вот так выглядел смартфон 2003 версии:









Вот так выглядет Microsoft eMbedded Visual C++ 3.0:

1. Нажмём File->New.., и выберем во вкладке Projects, выберем масте WCE Smartphone 2002 Application:



2. Появится диалоговое окно "WCE Smartphone 2002 Application", выберим "A typical "Hello World" application":



Создастся такой код test_sp2002.cpp:

#include <windows.h>
#include <aygshell.h>
#include "resource.h"

HINSTANCE g_hInst = NULL;
HWND hwndMain = NULL;

TCHAR szAppName[] = TEXT("Smartphone 2002 Application");
TCHAR szTitle[]   = TEXT("Smartphone 2002");
TCHAR szMessage[] = TEXT("Hello Smartphone 2002!");

//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 msg, WPARAM wp, LPARAM lp) {
  LRESULT lResult = TRUE;
  HDC hdc;
  PAINTSTRUCT ps;
  RECT rect;
  switch(msg) {
    case WM_CREATE:
      SHMENUBARINFO mbi;
      ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
      mbi.cbSize = sizeof(SHMENUBARINFO);
      mbi.hwndParent = hwnd;
      mbi.nToolBarId = IDR_HELLO_MENUBAR;
      mbi.hInstRes = g_hInst;

      if(!SHCreateMenuBar(&mbi)) {
        PostQuitMessage(0);
      }
    break;
    case WM_COMMAND:
      switch(wp) {
        case IDOK:
          SendMessage(hwnd, WM_CLOSE, 0, 0);
        break;
        default:
          return DefWindowProc(hwnd, msg, wp, lp);
      }
    break;
    case WM_PAINT: 
      hdc = BeginPaint(hwnd, &ps);
      GetClientRect(hwnd, &rect);
      DrawText(hdc, szMessage, -1, &rect, DT_SINGLELINE | 
      DT_CENTER | DT_VCENTER);
      EndPaint(hwnd, &ps);
    break;
    case WM_CLOSE:
      DestroyWindow(hwnd);
    break;
    case WM_DESTROY:
      PostQuitMessage(0);
    break;
    default:
      lResult = DefWindowProc(hwnd, msg, wp, lp);
    break;
  }
  return(lResult);
}

//FUNCTION: InitInstance(HANDLE, int)
//PURPOSE: Saves instance handle and creates main window
//COMMENTS:
//  In this function, we save the instance handle in a global variable and
//  create and display the main program window.
BOOL InitInstance(HINSTANCE hInstance, int CmdShow) {
  g_hInst = hInstance;
  hwndMain = CreateWindow(szAppName,                        
  szTitle,
  WS_VISIBLE,
  CW_USEDEFAULT,
  CW_USEDEFAULT,
  CW_USEDEFAULT,
  CW_USEDEFAULT,
  NULL, 
  NULL, 
  hInstance, 
  NULL);
  if(!hwndMain) {
    return FALSE;
  }
  ShowWindow(hwndMain, CmdShow);
  UpdateWindow(hwndMain);
  return TRUE;
}

//FUNCTION: InitApplication(HANDLE)
//PURPOSE: Sets the properties for our window.
BOOL InitApplication(HINSTANCE hInstance) {
  WNDCLASS wc;
  BOOL f;
  wc.style = CS_HREDRAW | CS_VREDRAW;
  wc.lpfnWndProc = (WNDPROC)WndProc;
  wc.cbClsExtra = 0;
  wc.cbWndExtra = 0;
  wc.hIcon = NULL;
  wc.hInstance = hInstance;
  wc.hCursor = NULL;
  wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  wc.lpszMenuName = NULL;
  wc.lpszClassName = szAppName;
  f = (RegisterClass(&wc));
  return f;
}

//  FUNCTION: WinMain(HANDLE, HANDLE, LPWSTR, int)
//  PURPOSE: Entry point for the application
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int CmdShow) {
  MSG msg;
  HWND hHelloWnd = NULL; 
  hHelloWnd = FindWindow(szAppName, szTitle); 
  if(hHelloWnd) {
    SetForegroundWindow(hHelloWnd);    
    return 0;
  }

  if(!hPrevInstance) {
    if(!InitApplication(hInstance)) { 
      return(FALSE); 
    }
  }

  if(!InitInstance(hInstance, CmdShow)) {
    return(FALSE);
  }
 
  while(GetMessage(&msg, NULL, 0,0) == TRUE) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  return(msg.wParam);
}



Потом test_sp2002.rc:

//Microsoft Developer Studio generated resource script.
#include "resource.h"

// Menu
IDR_HELLO_MENUBAR RCDATA
BEGIN
  0,
  1,
  I_IMAGENONE, 
  IDOK, 
  TBSTATE_ENABLED, 
  TBSTYLE_BUTTON | 
  TBSTYLE_AUTOSIZE,
  IDS_HELLO_OK, 
  0, 
  NOMENU,
END

STRINGTABLE DISCARDABLE
BEGIN
  IDS_HELLO_OK "OK"
END



И resource.h:

// Microsoft Developer Studio generated include file.
// Used by TEST_SP2002.RC
#include <windows.h>
#include <aygshell.h>
#include <tpcuser.h>

// BUGBUG
#define TPC

#define IDC_STATIC  (-1)
#define IDR_HELLO_MENUBAR  101
#define IDS_HELLO_OK  102

// Next default values for new objects
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC  1
#define _APS_NEXT_RESOURCE_VALUE  103
#define _APS_NEXT_COMMAND_VALUE  40001
#define _APS_NEXT_CONTROL_VALUE  1000
#define _APS_NEXT_SYMED_VALUE  101
#endif
#endif


Так выглядет эмулятор 2002:



Если я кому-то отвечаю, это не значит что я ему симпатизирую, каждый остаётся при своём мнение Дневник тяжелобольного инвалида
 

Перейти на