回 帖 发 新 帖 刷新版面

主题:我写的第一个SDK程序,执行怎么没反映?

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

LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

int APIENTRY WinMain ( HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPSTR lpCmdLine,
                       int nCmdShow )
{
    MSG msg;
    static TCHAR szAppName[] = TEXT ("Mine") ;
    HWND hWnd;
    HACCEL hAccelTable;

    WNDCLASS wndclass;
    wndclass.style                = CS_HREDRAW | CS_VREDRAW ;
    wndclass.lpfnWndProc        = (WNDPROC) WndProc ;
    wndclass.cbClsExtra            = 0 ;
    wndclass.cbWndExtra            = 0 ;
    wndclass.hInstance            = hInstance ;
    wndclass.hIcon                = LoadIcon ( NULL, (LPCTSTR)IDI_APP) ;
    wndclass.hCursor            = LoadCursor ( NULL, IDC_ARROW) ;
    wndclass.hbrBackground        = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
    wndclass.lpszMenuName        = MAKEINTRESOURCE ( IDM_MENU) ;
    wndclass.lpszClassName        = szAppName ;
    return RegisterClass( &wndclass) ;
    hWnd = CreateWindow ( szAppName,
                          "扫雷",
                          WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX,
                          CW_USEDEFAULT,             
                          CW_USEDEFAULT,            
                          400,             
                          400,       
                          NULL,
                          NULL,
                          hInstance,
                          NULL);
    ShowWindow (hWnd ,nCmdShow );
    UpdateWindow (hWnd) ;
    
    while (GetMessage (&msg, NULL , 0, 0))
    {
        if (TranslateAccelerator ( hWnd, hAccelTable, &msg))
        {
            TranslateMessage (&msg) ;
            DispatchMessage (&msg) ;
        }
    }
    
    return msg.wParam;

}

LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    return DefWindowProc(hWnd,message,wParam,lParam);
}

回复列表 (共7个回复)

沙发

仔细想了一下
return RegisterClass( &wndclass) ;
遇到return函数就断了,所以把return删了

板凳

呵呵,加油,最好用DEBUG跟踪是最方便的

3 楼

呵呵
谢谢^_^

4 楼

你好厉害呀 居然可以变这么长的程序

5 楼

寥寥几行也叫长?

6 楼

汗SDK程序是什么还是第一次听说~你这个叫win32程序
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
这里你要做处理啊比如显示图像等等,不然你什么都没做,空循环干吗
用vc自己带得向导可以生成一个正确有代码得程序自己看一下

7 楼

呵呵,随便写写,现在懂了点了

我来回复

您尚未登录,请登录后再回复。点此登录或注册