我想学习做标签页控件,照着msdn写了一个程序,出了点出错误,就不知道怎么改了,请大家帮帮忙,或者提供一个简单的样板也行。谢谢了下面的程序的错误提示是:(我用的是windows xp sp2系统)
c1_1.obj : error LNK2001: unresolved external symbol __imp__InitCommonControls@0
Debug/wintest.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.#include <windows.h>
#include "c1_1.h"
#include <stdlib.h>
#include <string.h>
#include <commctrl.h>HINSTANCE g_hinst;
char g_achTemp[256];
HWND g_hwndTab;
HWND g_hwndDisplay;
HWND hWndMain;long WINAPI WndProc(HWND,UINT,WPARAM,LPARAM);
BOOL InitWindowsClass(HINSTANCE);
BOOL InitWindows(HINSTANCE,int);
HWND WINAPI DoCreateTabControl(HWND hwndParent);
HWND WINAPI DoCreateDisplayWindow(HWND hwndParent);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
MSG Message;
if(!InitWindowsClass(hInstance))
return FALSE;
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
g_hwndTab=DoCreateTabControl(hWndMain);
g_hwndDisplay=DoCreateDisplayWindow(hWndMain); while(GetMessage(&Message,0,0,0)){
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
long WINAPI WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam){
switch(iMessage){
case WM_SIZE:
                HDWP hdwp; 
                RECT rc; 
 
                // Calculate the display rectangle, assuming the 
                // tab control is the size of the client area. 
                SetRect(&rc, 0, 0, LOWORD(lParam), HIWORD(lParam)); 
                TabCtrl_AdjustRect(g_hwndTab, FALSE, &rc); 
 
                // Size the tab control to fit the client area. 
                hdwp = BeginDeferWindowPos(2); 
                DeferWindowPos(hdwp, g_hwndTab, NULL, 0, 0, 
                    LOWORD(lParam), HIWORD(lParam), 
                    SWP_NOMOVE | SWP_NOZORDER 
                    ); 
 
                // Position and size the static control to fit the 
                // tab control's display area, and make sure the 
                // static control is in front of the tab control. 
                DeferWindowPos(hdwp, 
                    g_hwndDisplay, HWND_TOP, rc.left, rc.top, 
                    rc.right - rc.left, rc.bottom - rc.top, 0 
                    ); 
                EndDeferWindowPos(hdwp); 
 
            break; 
case WM_NOTIFY: 
            switch (HIWORD(wParam)) {
                case TCN_SELCHANGE:  
                        int iPage = TabCtrl_GetCurSel(g_hwndTab); 
                        LoadString(g_hinst, IDS_FIRSTDAY + iPage,g_achTemp, sizeof(g_achTemp)); 
                        SendMessage(g_hwndDisplay, WM_SETTEXT, 0 ,(LPARAM) g_achTemp); 
                    } 
                    break; 
            break;  case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,iMessage,wParam,lParam);
}
return 0;
}
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow){
HWND hWnd;
hWnd=CreateWindow("5_1","菜单显示实例程序",WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS,CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);
if(!hWnd)
return FALSE;
hWndMain=hWnd;
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
BOOL InitWindowsClass(HINSTANCE hInstance){
WNDCLASS WndClass;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName="5_1";
WndClass.lpszMenuName="Menu";
WndClass.style=0;
return RegisterClass(&WndClass);
}
HWND WINAPI DoCreateTabControl(HWND hwndParent) { 
    RECT rcClient; 
    HWND hwndTab; 
    TCITEM tie; 
    int i;    GetClientRect(hwndParent, &rcClient); 
    InitCommonControls(); 
    hwndTab = CreateWindow( 
        WC_TABCONTROL, "", 
        WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 
        0, 0, rcClient.right, rcClient.bottom, 
        hwndParent, NULL, g_hinst, NULL 
        ); 
    if (hwndTab == NULL) 
        return NULL;     tie.mask = TCIF_TEXT | TCIF_IMAGE; 
    tie.iImage = -1; 
    tie.pszText = g_achTemp; 
 
    for (i = 0; i < 7; i++) { 
        LoadString(g_hinst, IDS_FIRSTDAY + i,g_achTemp, sizeof(g_achTemp)); 
        if (TabCtrl_InsertItem(hwndTab, i, &tie) == -1) { 
            DestroyWindow(hwndTab); 
            return NULL; 
        } 
    } 
    return hwndTab; 

HWND WINAPI DoCreateDisplayWindow(HWND hwndParent) { 
    HWND hwndStatic = CreateWindow("STATIC", "", 
        WS_CHILD | WS_VISIBLE | WS_BORDER, 
        0, 0, CW_USEDEFAULT, CW_USEDEFAULT, 
        hwndParent, NULL, g_hinst, NULL); 
 
    return hwndStatic; 
}