Code:
BOOL CALLBACK MathTableProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
HDC hDC, MemDCMathTable, hdc, t_hDC;
PAINTSTRUCT Ps, ps;
HBITMAP bmpMathTable;
TCITEM tcitem;
NMHDR *pNMHdr;
int tabctrl[10];
switch(Message)
{
case WM_NOTIFY:
{
pNMHdr = (NMHDR *) lParam;
if (pNMHdr->code == TCN_SELCHANGE)
{
int tabnum = TabCtrl_GetCurSel((HWND)pNMHdr->hwndFrom);
hDC = GetDC(hwndTab);
if(tabnum == 0){/* nothing right now */}
ReleaseDC(hwndTab, hDC);
}
break;
}
case WM_INITDIALOG:
{
RECT rect;
mathtablehwnd = hwnd;
GetClientRect(hwnd, &rect);
InitCommonControls();
//Create tabbed window
hwndTab = CreateWindow(WC_TABCONTROL,"",WS_CHILD|WS_VISIBLE,
0,0,rect.right,rect.bottom,mathtablehwnd,NULL,
(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
//Set up tabs
tcitem.mask = TCIF_TEXT;
tcitem.iImage = -1;
//Create tabs
tcitem.pszText = "Pre-Algebra"; tabctrl[0] = TabCtrl_InsertItem(hwndTab, 0, &tcitem);
tcitem.pszText = "Algebra"; tabctrl[1] = TabCtrl_InsertItem(hwndTab, 1, &tcitem);
tcitem.pszText = "Trigonometry"; tabctrl[2]= TabCtrl_InsertItem(hwndTab, 2, &tcitem);
tcitem.pszText = "Geometry"; tabctrl[3] = TabCtrl_InsertItem(hwndTab, 3, &tcitem);
tcitem.pszText = "Calculus"; tabctrl[4] = TabCtrl_InsertItem(hwndTab, 4, &tcitem);
//Change tab font
SendMessage (hwndTab,WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
GetClientRect(hwndTab, &rect);
/*
prealghwnd = CreateWindow("STATIC","",WS_CHILD|WS_VISIBLE,
rect.left+5,rect.top+25,rect.right-7,rect.bottom-27,hwndTab,NULL,
(HINSTANCE)GetWindowLong(hwndTab,GWL_HINSTANCE),NULL);
*/
TabCtrl_SetCurSel(hwndTab,0);
ShowWindow(prealghwnd,SW_SHOW);
}
break;
case WM_PAINT:
hDC = BeginPaint(hwndTab, &Ps);
// Load the bitmap from the resource
if(!(bmpMathTable = LoadBitmap(hInstance, MAKEINTRESOURCE(IDD_MATH))))
MessageBox(hwnd,"error","error",MB_OK);
// Create a memory device compatible with the above DC variable
MemDCMathTable = CreateCompatibleDC(hDC);
// Select the new bitmap
SelectObject(MemDCMathTable, bmpMathTable);
// Copy the bits from the memory DC into the current dc
BitBlt(hDC, 15, 45, 250, 150, MemDCMathTable, 0, 0, SRCCOPY);
// Restore the old bitmap
DeleteDC(MemDCMathTable);
DeleteObject(bmpMathTable);
EndPaint(hwndTab, &Ps);
break;