Click here to Skip to main content
15,925,309 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to inject a dll into another process ? Pin
David Crow4-Mar-08 3:56
David Crow4-Mar-08 3:56 
GeneralRe: How to inject a dll into another process ? Pin
ThatsAlok4-Mar-08 20:39
ThatsAlok4-Mar-08 20:39 
GeneralProgress bar on Mainfram, while lengthy prosses on Dialog btn press event Pin
ptr_Electron4-Mar-08 2:49
ptr_Electron4-Mar-08 2:49 
GeneralRe: Progress bar on Mainfram, while lengthy prosses on Dialog btn press event Pin
David Crow4-Mar-08 3:20
David Crow4-Mar-08 3:20 
GeneralRe: Progress bar on Mainfram, while lengthy prosses on Dialog btn press event Pin
ptr_Electron4-Mar-08 3:37
ptr_Electron4-Mar-08 3:37 
GeneralRe: Progress bar on Mainfram, while lengthy prosses on Dialog btn press event Pin
David Crow4-Mar-08 3:48
David Crow4-Mar-08 3:48 
GeneralRe: Progress bar on Mainfram, while lengthy prosses on Dialog btn press event Pin
Randor 4-Mar-08 4:02
professional Randor 4-Mar-08 4:02 
GeneralProblem in property sheet.. Pin
Ashish Chauhan4-Mar-08 2:06
Ashish Chauhan4-Mar-08 2:06 
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..

// Win32EmbedPropSheet.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"





// Global Variables:
HINSTANCE g_hInst;								// current instance
HWND g_hwndPropSheet;
//HWND g_hwndMain;
//HWND hWndComboBox=NULL;

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"
                             };



// Foward declarations of functions included in this code module:
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)
{
	// TODO: Place code here.
	MSG msg;

	// Initialize global strings
	if (!InitInstance (hInstance, nCmdShow)) 
	{
		return FALSE;
	}
	
// Main message loop:
	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; // Store instance handle in our global variable
	
	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:   
			//	MessageBox(hdlg , "Ok Pressed" , "Check" , MB_OK);
				break ;
				
			case PSN_RESET:
				PostQuitMessage(0);
							
				break;
				
			case PSN_SETACTIVE:
				return IDD_PROPPAGE2;

			case PSN_KILLACTIVE:
				return FALSE;
			
		}

		//break;
	}
	
	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;
			
		}
		//break;
		
	}
	
	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;
			
		}
		//break;
		
	}
	
	return FALSE;
}

int CALLBACK PSheetCallback(HWND hwndPropSheet, UINT uMsg, LPARAM lParam)
{
	switch(uMsg)
	{
		//called before the dialog is created, hwndPropSheet = NULL, lParam points to dialog resource
	case PSCB_PRECREATE:
		{
			((LPDLGTEMPLATE)lParam)->style &= ~DS_CONTEXTHELP;
			return TRUE;
		}
		break;
		
		//called after the dialog is created
	case PSCB_INITIALIZED:
		break;
		
	}
	return FALSE;
}

HWND CreatePropSheet()
{
	PROPSHEETPAGE psp[4];
	PROPSHEETHEADER psh;
	
	memset(psp, 0, sizeof(PROPSHEETPAGE) * 4);
	memset(&psh, 0, sizeof(PROPSHEETHEADER));
	
	//Fill out the PROPSHEETPAGE data structure page 1
	psp[0].dwSize		 = sizeof(PROPSHEETPAGE);
	psp[0].dwFlags		 = PSP_USETITLE;
	psp[0].hInstance	 = NULL;//g_hInst;
	psp[0].pszTemplate	 = MAKEINTRESOURCE(IDD_PROPPAGE1);
	psp[0].pszIcon		 = NULL;
	psp[0].pfnDlgProc	 = (DLGPROC)Page1DlgProc;
	psp[0].pszTitle 	 = TEXT("Job");
	//psp[0].lParam		 = 0;
	
	//Fill out the PROPSHEETPAGE data structure for page 2
	psp[1].dwSize		 = sizeof(PROPSHEETPAGE);
	psp[1].dwFlags		 = PSP_USETITLE;
	psp[1].hInstance	 = NULL;//g_hInst;
	psp[1].pszTemplate	 = MAKEINTRESOURCE(IDD_PROPPAGE2);
	psp[1].pszIcon		 = NULL;
	psp[1].pfnDlgProc	 = (DLGPROC)Page2DlgProc;
	psp[1].pszTitle 	 = TEXT("Analysis Extent");
	//	psp[1].lParam		 = 0;
	
	//Fill out the PROPSHEETPAGE data structure page 3
	psp[2].dwSize		 = sizeof(PROPSHEETPAGE);
	psp[2].dwFlags		 = PSP_USETITLE;
	psp[2].hInstance	 = NULL;//g_hInst;
	psp[2].pszTemplate	 = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM);
	psp[2].pszIcon		 = NULL;
	psp[2].pfnDlgProc	 = (DLGPROC)Page3DlgProc;
	psp[2].pszTitle 	 = TEXT("Schedule");

	//Fill out the PROPSHEETPAGE data structure page 4
	psp[3].dwSize		 = sizeof(PROPSHEETPAGE);
	psp[3].dwFlags		 = PSP_USETITLE;
	psp[3].hInstance	 = NULL;//g_hInst;
	psp[3].pszTemplate	 = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM1);
	psp[3].pszIcon		 = NULL;
	psp[3].pfnDlgProc	 = (DLGPROC)Page4DlgProc;
	psp[3].pszTitle 	 = TEXT("Virus Check");
	
	//Fill out the PROPSHEETHEADER
	psh.dwSize			 = sizeof(PROPSHEETHEADER);
	psh.dwFlags 		 = PSH_PROPSHEETPAGE | PSH_USECALLBACK  | PSH_MODELESS;
	psh.hwndParent		 = NULL;//*g_hwndMain;*/g_hwndPropSheet;
	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..

AnswerRe: Problem in property sheet.. Pin
Rajkumar R4-Mar-08 4:59
Rajkumar R4-Mar-08 4:59 
GeneralRe: Problem in property sheet.. Pin
Maxwell Chen4-Mar-08 18:29
Maxwell Chen4-Mar-08 18:29 
GeneralRe: Problem in property sheet.. Pin
Ashish Chauhan4-Mar-08 18:41
Ashish Chauhan4-Mar-08 18:41 
GeneralRe: Problem in property sheet.. Pin
ThatsAlok4-Mar-08 20:40
ThatsAlok4-Mar-08 20:40 
GeneralRe: Problem in property sheet.. Pin
toxcct4-Mar-08 9:58
toxcct4-Mar-08 9:58 
GeneralRe: Problem in property sheet.. Pin
ThatsAlok4-Mar-08 20:40
ThatsAlok4-Mar-08 20:40 
Questionhow to add an image in the form in vc++?? Pin
savitri4-Mar-08 1:15
savitri4-Mar-08 1:15 
GeneralRe: how to add an image in the form in vc++?? Pin
jossion4-Mar-08 1:24
jossion4-Mar-08 1:24 
GeneralRe: how to add an image in the form in vc++?? Pin
Hamid_RT4-Mar-08 4:21
Hamid_RT4-Mar-08 4:21 
AnswerRe: how to add an image in the form in vc++?? [modified] Pin
Rajkumar R4-Mar-08 1:31
Rajkumar R4-Mar-08 1:31 
GeneralRe: how to add an image in the form in vc++?? Pin
Hamid_RT4-Mar-08 4:20
Hamid_RT4-Mar-08 4:20 
GeneralMessage Pass Pin
john56324-Mar-08 0:42
john56324-Mar-08 0:42 
GeneralRe: Message Pass Pin
CPallini4-Mar-08 0:53
mveCPallini4-Mar-08 0:53 
GeneralRe: Message Pass Pin
Mark Salsbery4-Mar-08 5:29
Mark Salsbery4-Mar-08 5:29 
GeneralRe: Message Pass Pin
ThatsAlok4-Mar-08 20:41
ThatsAlok4-Mar-08 20:41 
Generalerror C2440 Pin
neha.agarwal273-Mar-08 23:58
neha.agarwal273-Mar-08 23:58 
AnswerRe: error C2440 Pin
Rajkumar R4-Mar-08 0:10
Rajkumar R4-Mar-08 0:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.