1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <windows.h>
#include <commctrl.h>
char className[]="TabControl";
LRESULT CALLBACK WindowProcedure(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil){
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance=hInstance;
wincl.lpszClassName=className;
wincl.lpfnWndProc=WindowProcedure;
wincl.style=0;
wincl.cbSize=sizeof(WNDCLASSEX);
wincl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wincl.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
wincl.hCursor=LoadCursor(NULL,IDC_ARROW);
wincl.lpszMenuName=NULL;
wincl.cbClsExtra=0;
wincl.cbWndExtra=0;
wincl.hbrBackground=HBRUSH(COLOR_3DFACE+1);
if(!RegisterClassEx(&wincl))return 0;
HWND windowHandle=CreateWindow(className,"TabControl",WS_OVERLAPPEDWINDOW,200,325,480,320,NULL,NULL,hInstance,NULL);
ShowWindow(windowHandle,SW_SHOW);
HWND tabHandle=CreateWindow(WC_TABCONTROL,"",WS_CHILD,6,0,474,320,windowHandle,NULL,hInstance,NULL);
TCITEM tab1Data;
tab1Data.mask=TCIF_TEXT;
tab1Data.pszText="Tab1";
TabCtrl_InsertItem(tabHandle,0,&tab1Data);
TCITEM tab2Data;
tab2Data.mask=TCIF_TEXT;
tab2Data.pszText="Tab2";
TabCtrl_InsertItem(tabHandle,0,&tab2Data);
HWND tab1Handle=CreateWindow(WC_STATIC,"",WS_CHILD,6,40,474,320,tabHandle,NULL,hInstance,NULL);
HWND tab2Handle=CreateWindow(WC_STATIC,"",WS_CHILD,6,40,474,320,tabHandle,NULL,hInstance,NULL);
ShowWindow(tab1Handle,SW_SHOW);
while(GetMessage(&messages,NULL,0,0)){
TranslateMessage(&messages);
DispatchMessage(&messages);
};
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure (HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
switch(message){
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
};
return 0;
}
|