CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    31

    Tab control in a Dialog

    Hi!

    After consulting a number of articles/tutorials regarding property sheet, property pages, tab control... I decided to start this thread and ask for futher help. Sorry but I really find it hard to come up with what I want to make.

    I am using Visual C++ Resource Editor, here I can make a dialog and I can make individual PROPERTY PAGES. My problem, I do not know how to makes these PROPERTY PAGES look like a tab control placed into my dialog.

    Please someone help me. Thank You.

  2. #2
    Join Date
    May 2004
    Location
    Michigan, United States
    Posts
    457
    There was a thread about this just a week or so ago:
    http://www.codeguru.com/forum/showthread.php?t=302355
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  3. #3
    Join Date
    Jan 2001
    Posts
    29
    Here is a class that I use, that helps a lot

    Code:
    class PROPERTYSHEET{
    public:
    	_declspec (dllexport) PROPERTYSHEET();
    	_declspec (dllexport) ~PROPERTYSHEET();
    	_declspec (dllexport) BOOL DoDialog(LPCTSTR caption, HWND hwnd);
    	_declspec (dllexport) BOOL AddPage(LPCTSTR title, HINSTANCE hInst, LPCTSTR pszTemplate, DLGPROC pfnDlgProc);
    
    private:
    	PROPSHEETPAGE pPages[MAX_PROP_PAGES];
    	PROPSHEETHEADER psh;
    	int nPages;
    };
    
    /******************************************************************************
    	PROPERTYSHEET();
    
    	Constructs a property sheet object
    ******************************************************************************/
    _declspec (dllexport) PROPERTYSHEET::PROPERTYSHEET(){
    	nPages=0;
    }
    
    /******************************************************************************
    	~PROPERTYSHEET();
    
    	Destroys the property sheet object
    ******************************************************************************/
    _declspec (dllexport) PROPERTYSHEET::~PROPERTYSHEET(){}
    
    /******************************************************************************
    	DoDialog();
    
    	Invokes a modal property sheet
    
    	LPCTSTR caption = Caption of the dialog
    	HWND hwnd = Parent window of the dialog
    ******************************************************************************/
    _declspec (dllexport) BOOL PROPERTYSHEET::DoDialog(LPCTSTR caption, HWND hwnd){
    
    	psh.dwSize = sizeof(PROPSHEETHEADER); 
    	psh.dwFlags = PSH_DEFAULT | PSH_PROPSHEETPAGE | DS_SYSMODAL; 		
    	psh.hwndParent = hwnd; 
    	psh.hInstance = NULL; 
    	psh.pszCaption = caption; 
    	psh.nPages = nPages; 
    	psh.nStartPage = 0; 
    	psh.ppsp = pPages; 
    
    	return ::PropertySheet(&psh);
    }
    
    /******************************************************************************
    	AddPage();
    
    	Adds a page (tab) to the property sheet
    
    	LPCTSTR title = Caption of the tab
    	HINSTANCE hInst = Instance handle for the page
    	LPCTSTR pszTemplate = Address of a resource template for the page's dialog
    	DLGPROC pfnDlgProc = Address of dialog procedure for the page
    ******************************************************************************/
    _declspec (dllexport) BOOL PROPERTYSHEET::AddPage(LPCTSTR title, HINSTANCE hInst, LPCTSTR pszTemplate, DLGPROC pfnDlgProc){
    
    	if(nPages >= MAX_PROP_PAGES){
    		return FALSE;
    	}
    	
    	pPages[nPages].dwSize = sizeof(PROPSHEETPAGE); 
    	pPages[nPages].dwFlags = PSP_DEFAULT | PSP_USETITLE; 
    	pPages[nPages].pszTitle = title;
    	pPages[nPages].hInstance = hInst;
    	pPages[nPages].pszTemplate = pszTemplate;   
    	pPages[nPages].pfnDlgProc = pfnDlgProc; 
    
    
    	nPages++;
    
    	return TRUE;
    }

  4. #4
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    31
    I appreciate your answers.

    I am starting to learn creating windows purely using API calls.
    I am doing it "the hard way"

    Once I'm done, I will make my own tutorial for this. I also want to help those
    who cannot easily figure it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured