+ -
当前位置:首页 → 问答吧 → DATETIMEPACK_CLASS自己创建怎么不显示?

DATETIMEPACK_CLASS自己创建怎么不显示?

时间:2011-12-28

来源:互联网

C/C++ code

#include <windows.h>
#include <commctrl.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HINSTANCE hInstance;
    HWND hwndDTP;
    
    switch(message)
    {
    case WM_CREATE :
        hInstance  = ((LPCREATESTRUCT)lParam)->hInstance;

        hwndDTP = CreateWindow (DATETIMEPICK_CLASS, TEXT (""), 
            WS_BORDER | WS_CHILD | WS_VISIBLE | DTS_TIMEFORMAT,
            120, 20, 100, 50, 
            hwnd, (HMENU)1, hInstance, NULL) ;

        return 0;

    case WM_DESTROY :
        PostQuitMessage(0);
        return 0;
    }
    
    return DefWindowProc(hwnd, message, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
    static TCHAR szAppName[] = TEXT("Test");
    HWND hwnd;
    MSG msg;
    WNDCLASS wndclass;
    
    wndclass.style = CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc = WndProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName = NULL;
    wndclass.lpszClassName = szAppName;
    
    RegisterClass(&wndclass);
    
    hwnd = CreateWindow(szAppName, TEXT("Test"),
        WS_OVERLAPPEDWINDOW, 
        CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT,
        NULL, NULL, hInstance, NULL);

    ShowWindow(hwnd, iCmdShow);
    UpdateWindow(hwnd);
    
    while(GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    
    return msg.wParam;
}


为什么窗口上不显示用DATETIMEPACK_CLASS创建的time picker??换成创建button啊就可以可以显示啊。。这是怎么回事?

作者: ProgrammingRing   发布时间: 2011-12-28

我刚试了下。。直接在对话框里托控件,编译没有错误,但是运行对话款不显示啊,去掉就可以。。晕死

作者: ProgrammingRing   发布时间: 2011-12-28