Thread: easy visual c++ program problem,

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    15

    easy visual c++ program problem,

    there my program ( i am a newbie

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    15

    and here is my code for the prog

    Code:
    // TODO: Add extra initialization here
    
    	//Put a default message in the message edit
    	m_strMessage = "Place a message here";
    
    	//Set all the chek boxed to cheked
    	m_bShowMsg = TRUE;
    	m_bShowPgm = TRUE;
    	m_bEnableMsg = TRUE;
    	m_bEnablePgm = TRUE;
    
    	//Update the dialog with this values
    	UpdateData(FALSE);
    	
    	return TRUE;  // return TRUE  unless you set the focus to a control
    }
    
    void CDaialosDlg::OnSysCommand(UINT nID, LPARAM lParam)
    {
    	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    	{
    		CAboutDlg dlgAbout;
    		dlgAbout.DoModal();
    	}
    	else
    	{
    		CDialog::OnSysCommand(nID, lParam);
    	}
    }
    
    // If you add a minimize button to your dialog, you will need the code below
    //  to draw the icon.  For MFC applications using the document/view model,
    //  this is automatically done for you by the framework.
    
    void CDaialosDlg::OnPaint() 
    {
    	if (IsIconic())
    	{
    		CPaintDC dc(this); // device context for painting
    
    		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
    
    		// Center icon in client rectangle
    		int cxIcon = GetSystemMetrics(SM_CXICON);
    		int cyIcon = GetSystemMetrics(SM_CYICON);
    		CRect rect;
    		GetClientRect(&rect);
    		int x = (rect.Width() - cxIcon + 1) / 2;
    		int y = (rect.Height() - cyIcon + 1) / 2;
    
    		// Draw the icon
    		dc.DrawIcon(x, y, m_hIcon);
    	}
    	else
    	{
    		CDialog::OnPaint();
    	}
    }
    
    // The system calls this to obtain the cursor to display while the user drags
    //  the minimized window.
    HCURSOR CDaialosDlg::OnQueryDragIcon()
    {
    	return (HCURSOR) m_hIcon;
    }
    
    void CDaialosDlg::OnExit() 
    {
    	// TODO: Add your control notification handler code here
    
    	//Exit the program
    	OnOK();
    	
    }
    
    void CDaialosDlg::OnShwmsg() 
    {
    	// TODO: Add your control notification handler code here
    
    	//update the mesage variable with what the user entered
    	UpdateData(TRUE);
    
    	//display the message for the user
    	MessageBox(m_strMessage);
    	
    }
    
    void CDaialosDlg::OnClrmsg() 
    {
    	// TODO: Add your control notification handler code here
    
    	//Clear the screen
    	m_strMessage = "";
    
    	//update the screen
    	UpdateData(FALSE);
    }
    
    void CDaialosDlg::OnCkenblmsg() 
    {
    	// TODO: Add your control notification handler code here
    
    	//get the current values for the screen
    	UpdateData(TRUE);
    
    	//is the enable message action chek box cheked?
    	if (m_bEnableMsg == TRUE)
    	{
            //yes, so enable all controls that have anything
    		//to do this showing the user message
    	GetDlgItem(IDC_MSG)->EnableWindow(TRUE);
    	   GetDlgItem(IDC_SHWMSG)->EnableWindow(TRUE);
    	GetDlgItem(IDC_DFLTMSG)->EnableWindow(TRUE);
    	GetDlgItem(IDC_CLRMSG)->EnableWindow(TRUE);
    	GetDlgItem(IDC_STATICMSG)->EnableWindow(TRUE);
    	}
    	else
    	{
            //No, so disable all controls that have anything
    		//to do with the user message
    	    GetDlgItem(IDC_MSG)->EnableWindow(FALSE);
    	    GetDlgItem(IDC_SHWMSG)->EnableWindow(FALSE);
    	GetDlgItem(IDC_DFLTMSG)->EnableWindow(FALSE);
    	GetDlgItem(IDC_CLRMSG)->EnableWindow(FALSE);
    	GetDlgItem(IDC_STATICMSG)->EnableWindow(FALSE);
    	}
    }
    
    
    
    void CDaialosDlg::OnCkshwmsg() 
    {
    	// TODO: Add your control notification handler code here
    
    	//get the current values from the screen
    	UpdateData(TRUE);
    
    	//is the show message action check box cheked?
    	if (m_bShowMsg == TRUE)
    	{
    		//yes, so show all controls that have anything
    		//to do with showing the user
    	GetDlgItem(IDC_MSG)->ShowWindow(TRUE);
    	GetDlgItem(IDC_SHWMSG)->ShowWindow(TRUE);
    	GetDlgItem(IDC_DFLTMSG)->ShowWindow(TRUE);
    	GetDlgItem(IDC_CLRMSG)->ShowWindow(TRUE);
    	GetDlgItem(IDC_STATICMSG)->ShowWindow(TRUE);
    	}
    	else
    	{
    		//No, so hide all controls that have anything
    		//to do with showind the user
            GetDlgItem(IDC_MSG)->ShowWindow(FALSE);
    	GetDlgItem(IDC_SHWMSG)->ShowWindow(FALSE);
    	GetDlgItem(IDC_DFLTMSG)->ShowWindow(FALSE);
    	GetDlgItem(IDC_CLRMSG)->ShowWindow(FALSE);
    	GetDlgItem(IDC_STATICMSG)->ShowWindow(FALSE);
    	}
    }
    
    void CDaialosDlg::OnRunpgm() 
    {
    	// TODO: Add your control notification handler code here
    
    	//get the current values from the screen
    	UpdateData(TRUE);
    
    	//declare a locar variable for holfing the program name
    	CString strPgmName;
    
    
    	//copy the program name to the local variable
    		strPgmName.MakeUpper();
    
    	//did the user select to run the paint program?
    		if(strPgmName == "PAINT")
    			//run the program paint
    			WinExec("pbrush.exe", SW_SHOW);
    
    	//did the user select to run Notepad program?
    		if (strPgmName == "NOTEPAD")
    			//run the notepad program
    		WinExec("notepad.exe", SW_SHOW);
    
    	//did the user select tu run the solitaire program?
    		if (strPgmName == "SOLITAIRE")
    			//yes, run the solitaire program
    			WinExec("sol.exe", SW_SHOW);
    }
    
    void CDaialosDlg::OnCkenblpgm() 
    {
    	// TODO: Add your control notification handler code here
    
    	//get the current values to the screen
    	UpdateData(TRUE);
    
    	//is the enbale program chek box cheked?
    	if (m_bEnablePgm == True)
    	{
    		//yes, so enable all contro of pograms
    	GetDlgItem(IDC_PROGTORUN)->EnableWindow(TRUE);
    		GetDlgItem(IDC_RUNPGM)->EnableWindow(TRUE);
    	}
        else
    	{
    	GetDlgItem(IDC_PROGTORUN)->EnableWindow(FALSE);
    	GetDlgItem(IDC_RUNPGM)->EnableWindow(FALSE);
    	}
    }
    
    
    
    
    void CDaialosDlg::OnCkshwpgm() 
    {
    	// TODO: Add your control notification handler code here
    
    	UpdateData(TRUE);
    
    	if (m_bShowPgm == TRUE)
    
    	{
    	GetDlgItem(IDC_PROGTORUN)->ShowWindow(TRUE);
    	GetDlgItem(IDC_RUNPGM)->ShowWindow(TRUE);
    	}
    	else
    	{
    	GetDlgItem(IDC_PROGTORUN)->ShowWindow(FALSE);
    	GetDlgItem(IDC_RUNPGM)->ShowWindow(FALSE);
    	}
    	
    }

    [code][/code]tagged by Salem

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    15

    HERE IS MY PROBLEM

    the problem i got is with the disabling and hiding check boxes just work 1

    and with the part or opening another programs using my program: this part:




    //get the current values from the screen
    UpdateData(TRUE);

    //declare a locar variable for holfing the program name
    CString strPgmName;


    //copy the program name to the local variable
    strPgmName.MakeUpper();

    //did the user select to run the paint program?
    if(strPgmName == "PAINT")
    //run the program paint
    WinExec("pbrush.exe", SW_SHOW);

    //did the user select to run Notepad program?
    if (strPgmName == "NOTEPAD")
    //run the notepad program
    WinExec("notepad.exe", SW_SHOW);

    //did the user select tu run the solitaire program?
    if (strPgmName == "SOLITAIRE")
    //yes, run the solitaire program
    WinExec("sol.exe", SW_SHOW);
    }











    PLZ I NEED UR GUYS HELP

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. Problem with my program i cant figure out...
    By youareafever in forum C Programming
    Replies: 7
    Last Post: 11-01-2008, 11:56 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. SetDialogBkColor( ) Problem in Visual C++.net
    By dhrodrigues in forum Windows Programming
    Replies: 3
    Last Post: 07-28-2004, 08:50 AM
  5. errors in my class....
    By o0obruceleeo0o in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2003, 03:22 AM