Hi all...
I'm making an application using project sheet..I did this in MFC and successfully completed now trying in WIN32...
My problem is that whenever i press OK button(I don't want to do anything in OK button) and then when i click on other tab it gets hang...
I mean i'm using 4 tabs..If i press OK from first tab and then if i click on rest of 3 tabs it shows first tab's data.. Again when i come back to first tab from where i clicked OK and then i click to rest of the tabs it shows right data...
No matter from where i start(Whether 1st,2nd,3rd or 4th tab) the moment i press OK it gets hang for rest of the tabs, and works properly when i click to the tab from which i pressed OK...
What could be the problem???
here's my code...
Any reply will be appreciated..
#include "stdafx.h"
#include "resource.h"
HINSTANCE g_hInst;
HWND g_hwndPropSheet;
const char *job_combo[] = { "Never quit automatically",
"Do not quit if virus detected",
"Always quit"
};
const char *virus_check1[] = { "Log only",
"Disinfect (if not possible, rename file)",
"Disinfect (if not possible, delete file)",
"Rename infected file",
"Delete infected file",
"Automatic"
};
const char *virus_check2[] = { "High (short runtime)",
"Normal (normal runtime)",
"Low (long runtime)"
};
const char *virus_check3[] = { "Automatic type recognition",
"Only program files",
"User defined"
};
BOOL InitInstance(HINSTANCE, int);
HWND CreatePropSheet();
LRESULT CALLBACK Page1DlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Page2DlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Page3DlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Page4DlgProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
while (GetMessage(&msg, NULL, 0, 0))
{
if(!PropSheet_IsDialogMessage(g_hwndPropSheet, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
g_hInst = hInstance;
g_hwndPropSheet = CreatePropSheet();
if(-1 == (int)g_hwndPropSheet)
{
return -1;
}
ShowWindow(g_hwndPropSheet, nCmdShow);
UpdateWindow(g_hwndPropSheet);
return TRUE;
}
LRESULT CALLBACK Page1DlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnmhdr;
switch (uMessage)
{
case WM_INITDIALOG:
int i;
HWND hCombo;
hCombo = GetDlgItem(hdlg , IDC_COMBO1);
CheckRadioButton(hdlg, IDC_RADIO1, IDC_RADIO2, IDC_RADIO1);
CheckDlgButton(hdlg, IDC_CHECK1, BST_CHECKED);
for(i = 0 ; i<3 ;i++)
{
SendMessage(hCombo , CB_ADDSTRING , 0 , (unsigned long)job_combo[i]);
}
SendMessage(hCombo,CB_SETCURSEL,1,0);
return TRUE;
break;
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
break ;
case PSN_RESET:
PostQuitMessage(0);
break;
case PSN_SETACTIVE:
return IDD_PROPPAGE2;
case PSN_KILLACTIVE:
return FALSE;
}
}
return FALSE;
}
LRESULT CALLBACK Page2DlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnmhdr;
switch (uMessage)
{
case WM_INITDIALOG:
CheckRadioButton(hdlg, IDC_RADIO1, IDC_RADIO2, IDC_RADIO1);
break;
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
break;
case PSN_RESET:
PostQuitMessage(0);
break;
case PSN_SETACTIVE:
return 1;
case PSN_KILLACTIVE:
return FALSE;
}
break;
}
return FALSE;
}
LRESULT CALLBACK Page3DlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnmhdr;
switch (uMessage)
{
case WM_INITDIALOG:
CheckRadioButton(hdlg, IDC_RADIO1, IDC_RADIO6, IDC_RADIO1);
break;
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
break;
case PSN_RESET:
PostQuitMessage(0);
break;
case PSN_SETACTIVE:
return 1;
case PSN_KILLACTIVE:
return FALSE;
}
}
return FALSE;
}
LRESULT CALLBACK Page4DlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnmhdr;
switch (uMessage)
{
case WM_INITDIALOG:
int j;
int k;
int l;
HWND hCombo1;
HWND hCombo2;
HWND hCombo3;
hCombo1 = GetDlgItem(hdlg , IDC_COMBO1);
hCombo2 = GetDlgItem(hdlg , IDC_COMBO2);
hCombo3 = GetDlgItem(hdlg , IDC_COMBO3);
for(j = 0 ; j<6 ;j++)
{
SendMessage(hCombo1 , CB_ADDSTRING , 0 , (unsigned long)virus_check1[j]);
}
SendMessage(hCombo1,CB_SETCURSEL,5,0);
for(k = 0 ; k<3 ;k++)
{
SendMessage(hCombo2 , CB_ADDSTRING , 0 , (unsigned long)virus_check2[k]);
}
SendMessage(hCombo2,CB_SETCURSEL,1,0);
for(l = 0 ; l<3 ;l++)
{
SendMessage(hCombo3 , CB_ADDSTRING , 0 , (unsigned long)virus_check3[l]);
}
SendMessage(hCombo3,CB_SETCURSEL,0,0);
CheckRadioButton(hdlg, IDC_RADIO1, IDC_RADIO6, IDC_RADIO1);
CheckDlgButton(hdlg, IDC_CHECK1, BST_CHECKED);
CheckDlgButton(hdlg, IDC_CHECK2, BST_CHECKED);
CheckDlgButton(hdlg, IDC_CHECK5, BST_CHECKED);
CheckDlgButton(hdlg, IDC_CHECK6, BST_CHECKED);
CheckDlgButton(hdlg, IDC_CHECK7, BST_CHECKED);
break;
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
break;
case PSN_RESET:
PostQuitMessage(0);
break;
case PSN_SETACTIVE:
return 1;
case PSN_KILLACTIVE:
return FALSE;
}
}
return FALSE;
}
int CALLBACK PSheetCallback(HWND hwndPropSheet, UINT uMsg, LPARAM lParam)
{
switch(uMsg)
{
case PSCB_PRECREATE:
{
((LPDLGTEMPLATE)lParam)->style &= ~DS_CONTEXTHELP;
return TRUE;
}
break;
case PSCB_INITIALIZED:
break;
}
return FALSE;
}
HWND CreatePropSheet()
{
PROPSHEETPAGE psp[4];
PROPSHEETHEADER psh;
memset(psp, 0, sizeof(PROPSHEETPAGE) * 4);
memset(&psh, 0, sizeof(PROPSHEETHEADER));
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = NULL;
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE1);
psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = (DLGPROC)Page1DlgProc;
psp[0].pszTitle = TEXT("Job");
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = NULL;
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE2);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = (DLGPROC)Page2DlgProc;
psp[1].pszTitle = TEXT("Analysis Extent");
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USETITLE;
psp[2].hInstance = NULL;
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM);
psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = (DLGPROC)Page3DlgProc;
psp[2].pszTitle = TEXT("Schedule");
psp[3].dwSize = sizeof(PROPSHEETPAGE);
psp[3].dwFlags = PSP_USETITLE;
psp[3].hInstance = NULL;
psp[3].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM1);
psp[3].pszIcon = NULL;
psp[3].pfnDlgProc = (DLGPROC)Page4DlgProc;
psp[3].pszTitle = TEXT("Virus Check");
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_MODELESS;
psh.hwndParent = NULL;
psh.hInstance = g_hInst;
psh.pszIcon = NULL;
psh.pszCaption = "Automatic Virus Check";
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.nStartPage = 0;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
psh.pfnCallback = (PFNPROPSHEETCALLBACK)PSheetCallback;
return (HWND)PropertySheet(&psh);
}
Ash..
|