今天在
开发板上用Win CE输出了Hello Forlinx OK210,是不是很酷!
好了,说一下步骤吧!
1)在vs2005中新建一个Hello Forlinx OK210的C++项目文件
2)输入如下代码:
- #include
- #include
- LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
- int WINAPI WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPTSTR lpCmdLine,
- int nCmdShow)
- {
- //1.创建一个窗体类
- WNDCLASS ws;
- ws.cbClsExtra = 0;
- ws.cbWndExtra = 0;
- ws.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- ws.hCursor = NULL;
- ws.hIcon = NULL;
- ws.hInstance = hInstance;
- ws.lpfnWndProc = WndProc;
- ws.lpszClassName = TEXT("Hello");
- ws.lpszMenuName = NULL;
- ws.style = CS_VREDRAW | CS_HREDRAW;
- //2.注册窗体类
- if (! RegisterClass(&ws)) return -1;
- //3.创建窗体
- HWND hwnd = CreateWindow(TEXT("Hello"),TEXT("My Forlinx OK21O"),WS_VISIBLE | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPtiON,
- 300,30,200,150,
- NULL,NULL,hInstance,NULL);
- //4.更新窗体内容
- UpdateWindow(hwnd);
- ShowWindow(hwnd,nCmdShow);
- MSG msg;
- //5.获取系统消息
- while(GetMessage(&msg,NULL,0,0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 1;
- }
- LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
- {
- PAINTSTRUCT ps;
- HDC hdc;
- RECT rect;
- GetClientRect(hwnd,&rect);
- if (message == WM_DESTROY)
- {
- PostQuitMessage(1);
- }
- if (message == WM_PAINT)
- {
- hdc = BeginPaint(hwnd,&ps);
- DrawText(hdc,TEXT("hello Forlinx OK21O"),-1,&rect,DT_VCENTER | DT_CENTER);
- EndPaint(hwnd,&ps);
- }
- return DefWindowProc(hwnd,message,wParam,lParam);
- }
3)编译后连接开发板,在开始菜单下Microsoft Visual Studio 2005=Visual Studio Remote Tools=>远程放大镜下就能看到第一个图啦!
注意事项
1:编译在OK210-CE6-SDK(ARMV4不)下编译。
2:开发板上电启动完成后再连接USBOTG线,要在装好驱动的情况下才正确连接开发板,才能在 远程放大镜 中查看到运行的情况。