vc++6.0怎么写Windows简单窗口代码

2022-05-19 14:00:18   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《vc++6.0怎么写Windows简单窗口代码》,欢迎阅读!
窗口,Windows,代码,简单,怎么
问: vc++6.0怎么写Windows简单窗口代码啊,求各位大虾发一下代码啊,还有是要用一个c++文件还是要一个win3工程

答:新建工程里选win32 APPLICATION 一个简单的win32程序即可 你不写代码 当然会没东西。。 你想看的话可以建立一个经典的hello world 方案二:

只用两个函数,够简单了吧! #include

LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {

int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc;

switch( msg ) {

case WM_COMMAND:

wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); break;

case WM_PAINT:

hdc = BeginPaint(hWnd, &ps); // TODO: 在此添加任意绘图代码... EndPaint(hWnd, &ps); break;

case WM_DESTROY: PostQuitMessage(0); break; default:

return DefWindowProc(hWnd, msg, wParam, lParam); }

return 0; }

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ) {

// Register the window class

WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, (HBRUSH)(COLOR_WINDOW+1), NULL, "Tutorial", NULL };

wc.hCursor=LoadCursor(0,IDC_ARROW); RegisterClassEx( &wc );

// Create the application's window

HWND hWnd = CreateWindow( "Tutorial", "Tutorial 01",


WS_OVERLAPPEDWINDOW, 100, 100, 600, 500, NULL, NULL, wc.hInstance, NULL ); ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); MSG msg;

ZeroMemory(&msg,sizeof(msg)); HACCEL hAccelTable;

hAccelTable = LoadAccelerators(wc.hInstance, NULL);//(LPCTSTR)IDC_SAMPLEWIN // 主消息循环:

while (GetMessage(&msg, NULL, 0, 0)) {

if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {

TranslateMessage(&msg); DispatchMessage(&msg); } }

UnregisterClass( "Tutorial", wc.hInstance ); return 0; }




本文来源:https://www.wddqxz.cn/0ddc121b80eb6294dc886c93.html

相关推荐