- 积分
- 16
贡献71
飞刀20 FD
注册时间2018-10-4
在线时间9 小时
扫一扫,手机访问本帖
|
在NewQoMobileSDK的环境中编写如下代码:- #include <Windows.h>
- #include <wingdi.h>
- LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
- int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine,int nShowCmd)
- {
- //1、创建一个窗体类对象
- WNDCLASSW 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 world");
- ws.lpszMenuName = NULL;
- ws.style = CS_VREDRAW | CS_HREDRAW;
- //2、注册窗体类
- if (! RegisterClass(&ws))
- {
- return -1;
- }
- //3、创建窗体
- HWND hwnd = CreateWindow(TEXT("hello world"),TEXT("My First Window"),WS_VISIBLE | WS_BORDER | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CAPTION,
- 10,10,400,300,
- NULL,NULL,hInstance,NULL);
- //4、更新并显示窗体内容
- UpdateWindow(hwnd);
- ShowWindow(hwnd,CS_VREDRAW | CS_HREDRAW);
- 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;
- switch(message)
- {
- case WM_DESTROY:
- PostQuitMessage(1);
- break;
- case WM_PAINT:
- GetClientRect(hwnd,&rect);
- hdc = BeginPaint(hwnd,&ps);
- DrawText(hdc,TEXT("hello world"),-1,&rect,DT_VCENTER | DT_CALCRECT);
- EndPaint(hwnd,&ps);
- break;
- default:
- DefWindowProc(hwnd,message,wParam,lParam);
- break;
- }
- /*if(message == WM_DESTROY)
- {
- PostQuitMessage(1);
- }
- GetClientRect(hwnd,&rect);
- if (message == WM_PAINT)
- {
- hdc = BeginPaint(hwnd,&ps);
- DrawText(hdc,TEXT("hello world"),-1,&rect,DT_VCENTER | DT_CALCRECT);
- EndPaint(hwnd,&ps);
- }
- return DefWindowProc(hwnd,message,wParam,lParam);*/
- return 0;
- }
复制代码 这是模拟器产生的结果:
就是不知道为什么不能和视频那样显示hello world
那位知道的指点一下,谢谢! |
|