|
Christian..
Method B works perfectly...and I could even use a const although I had to do this:
Organism aOrgArray [20];
instead of
Organism [20] aOrgArray;
but that's no biggie.
Damn...now I owe you lunch...
|
|
|
|
|
student() wrote:
Method B works perfectly...
great !!!
student() wrote:
and I could even use a const
Cool - I wasn't sure, I gave it about a 50/50
student() wrote:
although I had to do this
Yeah, the syntax did not look right when I typed it, but it was 4:30 am and I was burning a DVD, which means I cannot really fire up a compiler because the PC is so slow.
student() wrote:
Damn...now I owe you lunch...
See you at 12:00..... :P
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I have some questions regarding Arrays of Controls. I have two arrays declared as follows:
<br />
#define MAX_NUMBER 10<br />
<br />
CStatic m_cStaticArray[MAX_NUMBER];<br />
CString m_strStringArray[MAX_NUMBER];<br />
Now what I would like to do is be able to set the m_strStringArray to a value and then use DDX to update the Static control that relates to it. My problem is that the application may not actuall use all 10 of the CStatic controls. Depending on the user it may only use 1, none, some or all of them. The controls are created depending on certain variables that occur during run time. I have defined all the IDs ahead of time in the Resource.h file for the static controls.
Do I have to perform the movement of the data from the CString variable to the CStatic control manually or can I still use DDX in some way to automate this?
As a side question that I just thought of, if I override the OnHScroll method of a CScrollView derived class do I have to then perform all the various functions required to get the view to scroll or can I do just a small amount of data manipulation and still let the CScrollView handle moving the view?
Thanks for any help,
-Eric
|
|
|
|
|
You should be able to do this with the DDX mechanism. You need to add the entries to map them manually:
DDX_Control(pDX, IDC_DROP_GRAPHS, m_DropGraphs);
DDX_Control(pDX, IDC_RESULTS, m_lcResults);
DDX_Control(pDX, IDC_PKA_LIST, m_lcpKaList);
DDX_Control(pDX, IDC_GRAPH, m_YSExtrapolation);
for (int i = 0 ; i < number_of_controls ; i++)
{
DDX_Control(pDX, IDC_OF_FIRST_STATIC + i, m_cStaticArray[i]);
}
Just don't put your code inside the AFX_DATA_MAP tags otherwise class wizard will complain.
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
Roger Allen wrote:
<br />
DDX_Control(pDX, IDC_DROP_GRAPHS, m_DropGraphs);<br />
DDX_Control(pDX, IDC_RESULTS, m_lcResults);<br />
DDX_Control(pDX, IDC_PKA_LIST, m_lcpKaList);<br />
DDX_Control(pDX, IDC_GRAPH, m_YSExtrapolation);<br />
for (int i = 0 ; i < number_of_controls ; i++)<br />
{<br />
DDX_Control(pDX, IDC_OF_FIRST_STATIC + i, m_cStaticArray[i]);<br />
}<br />
Just don't put your code inside the AFX_DATA_MAP tags otherwise class wizard will complain.
Thanks for the help, but I still get an assertion error on the UpdateData() method in my OnInitialUpdate function.
Here is what my DoDataExchange looks like:
<br />
void CMyView::DoDataExchange(CDataExchange *pDX)<br />
{<br />
for(int i = 0; i < MAX_USERS; i++)<br />
{<br />
DDX_Text(pDX, IDC_STATIC_ONE + i, m_strUsers[i]);<br />
}<br />
}<br />
Any other thoughts?
-Eric
|
|
|
|
|
You should only call DDX_Text on an item is you actually create it. Thinking on it, you may need to move this code into your OnInitDialog() as the DDX stuff gets called for you by the CDialog::OnInitDialog() implementation which will be before you create your controls properly (unless you do it in the WM_CREATE message handler).
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
Roger,
Thanks for the help. I got it working properly now by adding a member variable to my View class indicating the number of controls created. Then in the DoDataExchange function I just did a simple for loop until I reached that number.
Thanks again for the help!
-Eric
|
|
|
|
|
Hi,
I'm creating an app with single document but multiple views.
I'm trying to dynamically change the toolbar as different views are activated.
At the moment, I overwrite the ActivateView() function of each view to make a call to the following function:
BOOL CMainFrame::SetupMainFrameToolbar(UINT ToolbarResourceID, BOOL loadToolbar)<br />
{
if (loadToolbar == TRUE)<br />
{ if (!m_wndToolBar.LoadToolBar(ToolbarResourceID))<br />
{ TRACE0("Failed to create toolbar\n");<br />
return (FALSE); <br />
}<br />
}<br />
<br />
int tempID, location;<br />
CString stringToDisplay, tempString;<br />
UINT ButtonCounter = m_wndToolBar.GetCount();<br />
for (int index = 0; index < ButtonCounter; index++)<br />
{
tempID = m_wndToolBar.GetItemID (index);<br />
tempString.LoadString(tempID);<br />
location = tempString.GetLength() - tempString.ReverseFind ('\n') - 1;<br />
stringToDisplay = tempString.Right (location);<br />
m_wndToolBar.SetButtonText (index, _T((LPCTSTR) stringToDisplay));<br />
}<br />
<br />
m_wndToolBar.SetSizes (TOOLBAR_BUTTON_SIZE, TOOLBAR_BUTTON_IMAGE_SIZE);<br />
<br />
if (loadToolbar == TRUE)<br />
{
FloatControlBar(&(m_wndToolBar), CPoint(50,50));<br />
DockControlBar (&(m_wndToolBar), AFX_IDW_DOCKBAR_TOP);<br />
}<br />
RecalcLayout();<br />
m_wndToolBar.InvalidateRect (NULL, TRUE);<br />
return (TRUE);<br />
}
As you can see, I was forced to float and redock the toolbar, as AutoSize() doesn't work (it clips my new toolbar to the width of the old toolbar) and RecalcLayout() makes my toolbar buggy (text is only displayed after first a mouse has hovered over the toolbar).
Anybody has ever done this before? Like totally replace the main toolbar everytime a new view is activated?
Help ^^
|
|
|
|
|
Again, no reply.. and again, I've solved the problem ^^
What I do is I create an array of toolbars in my MainFrame, and turn them on and off and redock them as the need arise.
Okay.. thanks.
|
|
|
|
|
Can anyone provide me some more details of how to add the MFC grid control (wrote by Christ Maunder) to a dialog? I can't make it work using his instruction in the article.
Many thanks,
peter.
|
|
|
|
|
It's probably appropriate that you ask this in the forum for the article, as Chris is the best person to answer you, and he will get a copy via email if you ask there. It would also help to explain what difficulty you're having. What are the errors you are getting ? What is not working ? etc.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
If you dont mind using it as a activex control, there is an article here on CP porting it to COM. Using Activex control in dialog is very simple. Would work similar to flexgrid.
ATL Grid control[^]
Cheers
Kannan
|
|
|
|
|
Need to disabled mouse and Alt + TAB and Ctrl, Alt, Del
Anyone??
\Larsson
|
|
|
|
|
You can prevent the CTRL+ALT+DEL and ALT+TAB key combinations from opening a task list in Windows 95, Windows 98, or Windows Me by calling the SystemParametersInfo function in the Win32 API.
NOTE: This is possible only in Windows 95, Windows 98, or Windows Me.
|
|
|
|
|
|
Does anyone know of a utility that will scan through your Visual C++ project and list out unused header files, multiply-included headers and the like?
We have a big project with some old code that really could use a cleaning like this.
Thanks in advance.
Andrew
|
|
|
|
|
hello @all,
i connected my mfc program and an access database with ODBC.
CDatabase db;<br />
db.Open(_T( "MyDatabase" ), FALSE,<br />
FALSE, _T( "ODBC"));<br />
the ODBC driver of my database is called 'MyDatabase'. but when i use this code, the database is not selected. i must select it myself!
what must i change to select my odbc driver from the program (i have to do nothing, after i start the program)?
thanks
mfc
|
|
|
|
|
Hi
I have two CPropertyPages dialogs, handled by CPropertySheet. I'm executing some code in the second page OnInitDialog handler. This code should be executed during creation of CTreeCtrl located on the second page. After executing this code I receive the data that is needed in first page OnInitDialog handler. Of course I can repeat execution of this code in first page OnInitDialog handler but it would be time consuming (or I can store result of this code so as to use it in second page OnInitDialog, but it means storing it in tree and I want to find easier solution). I have an idea how to solve this problem: second page must be displayed on the beginning (not a problem for me) and after that first page should be activated. The problem is that I cannot fully activate first page. I was able only to change active tab, not the active window inside propertysheet dialog. Thanks in advance for any hints.
Mariusz Popiolek
|
|
|
|
|
I am working with some legacy code where a vector<string> t is passed into my function. I created an iterator to read through the vector: vector<string>iterator p
I then pass the vector into another function. I want to also pass the iterator so that the new function continues to know where in the vector it is. What is the best way to pass this information? Thanks.
|
|
|
|
|
You want to know the index ? Why ? I guess you could pass the index as a number, I just don't get why you would do so.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
This program needs to read through the vector and essentially reads off strings sequentially as it is passed through the functions. This is old code but there is too much to rewrite anew. So the first function reads several "lines" (i.e. strings) an then the vector is passed to another function which needs to read off a variable number of "lines" and passes to other functions, etc. Each read takes the next string, thus, I am hopint to pass the iterator to keep track where it is (each function using the iterator to know which index is next to read). I have not used iterators except in very basic uses within one fuction and have not figured out how to pass one. Thanks.
|
|
|
|
|
I don't see why it would be hard to pass one - where are you stuck ?
Iterators from a vector support random access, so you can both use ++ and -- to step.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Here is what I have:
static int read_layout(std::vector<std::string> &, vector<std::string>iterator, char *)
static int read_layout(std::vector<std::string> & trs, vector<std::string>iterator pr, char *szName)
{
}
void StartReading(std::vector<std::string> & trs)
{
vector<std::string>::iterator pr;
pr = trs.begin();
string s = *pr;
strcpy( szHeader, s.c_str() );
pr++; //there are several of these types of access prior to function call
iStatus = read_layout_truss(trs, pr, szName)
}
I am not able to get this to compile as is. Hopefully I did not post this previously as my keyboard seems to be freezing on me. Thanks for your input.
|
|
|
|
|
I see - damn typedefs. They should not do any harm, beyond obsfucating your code.
I suspect you need to pass them by reference, as the vector is also being passed.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I guess you can pass the pointer to the vector!!
|
|
|
|
|