启动界面的实现(SDK)

这个是主窗口的消息处理函数
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
case WM_CREATE: //处理WM_CREATE消息,弹出对话框, 这里我就用了系统自己添加的关于窗口,你可以自己再添加个窗口
        DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
        break;
}

//这是关于窗口
// “关于”框的消息处理程序。
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
#define ID_TIMER    1  //计时器的ID
    UNREFERENCED_PARAMETER(lParam);
    HDC hdc;
    HDC hMemDC;
    HBITMAP hBmp;
    PAINTSTRUCT ps;

    switch (message)
    {
    case WM_INITDIALOG:
        SetTimer(hDlg, ID_TIMER, 2000, NULL);    //初始化窗口时开户计时器    
        return (INT_PTR)TRUE;

    case WM_PAINT:
        hdc = BeginPaint(hDlg, &ps);
        //这里就是加载并显示位图,
        hMemDC = CreateCompatibleDC(hdc);
        hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
        SelectObject(hMemDC, hBmp);
        BitBlt(hdc, 0,0,1024, 768, hMemDC, 0, 0, SRCCOPY);    //你可以根据窗口的大小,设置参数的大小
        DeleteDC(hMemDC);
        DeleteObject(hBmp);

        EndPaint(hDlg, &ps);
        break;

    case WM_TIMER:        
        KillTimer(hDlg, ID_TIMER);
        EndDialog(hDlg, LOWORD(wParam)); //时间到就关闭这个模式对话框,弹出主窗口
        break;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
        {
            EndDialog(hDlg, LOWORD(wParam));
            return (INT_PTR)TRUE;
        }
        break;
    }
    return (INT_PTR)FALSE;
}

 

你可能感兴趣的:(启动界面的实现(SDK))