Passing Parameters in Visual C++

This is a discussion on Passing Parameters in Visual C++ within the C++ Programming forums, part of the General Programming Boards category; Hi I am trying to create a Visual C++ porgram, my first one, just trying to get to know it ...

  1. #1
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128

    Passing Parameters in Visual C++

    Hi I am trying to create a Visual C++ porgram, my first one, just trying to get to know it really, I have a form and on that for is a combo box and an edit control and a browse button, could someone help me as I am asking for a in put file from the combo box and the output file from the browse button, ghow would I get the parameters to the ok button where I will do my final piece of coding?

    Don't know if code is necessary but here is some anyway:
    Code:
    void CVisTestDlg::OnDropdownCombo1() 
    {
    	CComboBox* getFile = (CComboBox*)GetDlgItem(IDC_COMBO1);
    
    	getFile->ResetContent();
    
    	getFile->Dir(DDL_DRIVES | DDL_READONLY | DDL_EXCLUSIVE, "C:\\*.*");
    
    	// TODO: Add your control notification handler code here	
    }
    
    void CVisTestDlg::OnButton1() 
    {
    	CString fileName;
    	
    	CFileDialog saveas(false, ".zip", "Thingy in a file");
    
    	saveas.DoModal();
    
    	fileName = saveas.GetPathName();
    	// TODO: Add your control notification handler code here
    	
    }
    
    void CVisTestDlg::OnOK() 
    {
    	// TODO: Add extra validation here
    	
    	CDialog::OnOK();
    }
    Thanks people.

    Ben.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  2. #2
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    You can simply add member variables to the dialog class to hold the values you need from the other events. This way when OnOK is called you will have access to them.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  3. #3
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128
    Cheers Velius, maybe I should change the name of my project to Velius VisTest, so basically make them global? right well i will give it a go and if I can't figure out how to do it I am sure I will be back, again thanks.

    Ben.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

  4. #4
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    Not global. Public members. Of course the best way to do it is to make them private and create helper functions to access them.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  5. #5
    ResurgentBarbecue UnclePunker's Avatar
    Join Date
    May 2002
    Posts
    128
    Cheers Vel8ius, I completely agree about making them private but creating GetFileName() and stuff but this is the first time I have used Visual C++ and its a bit of a nightmare getting used to looking through someone elses code to do your own, I am much happier writing my own classes so i know what functions do what and what relates to what and at least where to put my code, thanks man you have been a great help, it is all working now, just a little more error handling to be done, its only a throw away program to help me learn, and you have certainly done that. Thanks again.

    Ben.
    Compiler == Visual C++ 6.0
    "Come Out Fighting."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 01:17 AM
  2. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 09:26 AM
  3. header file bringing errors?
    By bluehead in forum Windows Programming
    Replies: 4
    Last Post: 08-19-2003, 01:51 PM
  4. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 10:04 PM
  5. odd errors from msvc std library files
    By blight2c in forum C++ Programming
    Replies: 6
    Last Post: 04-30-2002, 01:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21