Code:
//Options dialog
BOOL CALLBACK OptionsProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hDC, hdc, t_hDC;
//PAINTSTRUCT 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){
//Show these windows
ShowWindow(GetDlgItem(hwnd,SU_UPDATES),SW_SHOW);
ShowWindow(GetDlgItem(hwnd,SU_TEXT),SW_SHOW);
//Hide these windows
ShowWindow(GetDlgItem(hwnd,SU_BEEP),SW_HIDE);
}
if(tabnum == 1){
//Show these windows
ShowWindow(GetDlgItem(hwnd,SU_BEEP),SW_SHOW);
//Hide these windows
ShowWindow(GetDlgItem(hwnd,SU_UPDATES),SW_HIDE);
ShowWindow(GetDlgItem(hwnd,SU_TEXT),SW_HIDE);
}
ReleaseDC(hwndTab, hDC);
}
break;
}
case WM_INITDIALOG:
{
//LOAD TABS
RECT rect;
OptionsHwnd = hwnd;
//Get the size of the initial window space to work with
GetClientRect(hwnd, &rect);
InitCommonControls();
//Create tabbed window
hwndTab = CreateWindow(WC_TABCONTROL,"",WS_CHILD|WS_VISIBLE,
0,0,rect.right,rect.bottom,hwnd,NULL,
(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
//Set up tabs
tcitem.mask = TCIF_TEXT;
tcitem.iImage = -1;
//Create tabs
tcitem.pszText = "Startup"; tabctrl[0] = TabCtrl_InsertItem(hwndTab, 0, &tcitem);
tcitem.pszText = "Run Time"; tabctrl[1]= TabCtrl_InsertItem(hwndTab, 1, &tcitem);
//Change tab font
SendMessage (hwndTab,WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
//Get the size of the tab window
GetClientRect(hwndTab, &rect);
//DONE LOADING TABS
GetCurrentDirectory(GetCurrentDirectory(0,NULL)+1,startupiniDir);
strcat(startupiniDir,"\\startup.ini");
char* su_answer = new char[10];
//See if automatic updates is on or off
GetPrivateProfileString("startup","updateonstartup","no",su_answer,
sizeof(su_answer),startupiniDir);
//Check automatic updates if needed
if((strcmp("yes",su_answer)) == 0)
SendDlgItemMessage(hwnd,SU_UPDATES,BM_SETCHECK,BST_CHECKED,0);
//Find out if BeepOnFile is set to true or false
GetPrivateProfileString("startup","beeponfile","no",su_answer,
sizeof(su_answer),startupiniDir);
//Check BeepOnFile if needed
if((strcmp("yes",su_answer)) == 0)
SendDlgItemMessage(hwnd,SU_BEEP,BM_SETCHECK,BST_CHECKED,0);
delete [] su_answer;
ShowWindow(GetDlgItem(hwnd,SU_BEEP),SW_HIDE); //Hide run time options
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case SU_DONE:
{
//Do stuff
PostMessage(hwnd,WM_CLOSE,0,0);
}
break;
}
break;
case WM_CLOSE:
EndDialog(hwnd,0);
break;
default: /* for messages that we don't deal with */
return false;
}
return 0;
}
OPT_DIALOG DIALOGEX 75,55,300,100
STYLE WS_CAPTION|WS_MINIMIZEBOX
CAPTION "Options"
FONT 9, "MS Sans Serif"
BEGIN
//LTEXT "These are the options you can select for each start up.\n",
//SU_TEXT,5,5,250,19
AUTOCHECKBOX "Automatically check for updates on each start up",
SU_UPDATES,5,28,225,10
AUTOCHECKBOX "Beep on start up",
SU_BEEP,5,28,100,10
LTEXT "Changes will take effect on next start up",SU_TEXT,5,85,135,10
PUSHBUTTON "Apply",SU_DONE,260,78,30,14
END