|
You have a few options available.
As the structure exists in the application class (CMyApp), you can create a member function that returns the address of this structure.
Now, if this method is called from inside CMyDoc, the document has the address of the structure, and can operate on it freely, providing that both objects reside on the same thread. If they do not, things get more complicated.
Alternatively, taking an advanced step from the section above, you can create a structure into CMyDoc as well, then get a pointer from CMyApp and use memcpy to copy the structure data from CMyApp to CMyDoc. Now, CMyDoc contains a copy of the structure.
The previous posted created an example piece to show you how to access the application object at run-time. Use this method to call the function that returns the structure address.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi everyone I get an assertion error when I try to iniatialize the contents of the controls of CDialog derived class of Edit boxes and Combo boxes. I try to initialise them at the constructor. Of course I have attached member variables to each control.
The initialization code works well when for instance I trigger, execute it by a button click.
Can anyone help?
|
|
|
|
|
One solution is to initialize the controls in OnInitDialog().
Kuphryn
|
|
|
|
|
The assertion is probably something like ASSERT( ::IsWindow( m_hWnd ) );
This happens because while in the constructor, your dialog is not actually a real window yet. The MFC classes, such as CDialog, are wrappers around the real windows which are represented by HWNDs. This means that there is two stage initialisation: firstly the CDialog (or equivalent) object must be created, and then secondly, the real window must be created, or the MFC object must be attached to an existing real window. The consequence of this is that within the object's constructor, you cannot call any methods or use any member variables that expect the dialog to be created as yet. The member variables for the edit boxes get attached to the real edit controls during the first call to DoDataExchange(), but this is not called until somewhere inside CDialog::OnInitDialog(). Until that has been called, your member variables are not yet attached to real windows, and so will assert if you try to call methods that assume otherwise.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Can anyone think of a reason why
keybd_event(45,NULL,KEYEVENTF_KEYUP,NULL);//for keyup message
would work, but not
keybd_event(45,NULL,NULL,NULL);//for keydown message
?
halblonious
|
|
|
|
|
Anyone know what a game engine is and what it does?? HELP??
<marquee>Universal Project
|
|
|
|
|
Well google is your friend, but I'll have a go anways
A game engine is typically a library of code that is dedicated to handling the low level graphics functionality, and then packaging this up with nice easy to use high level function calls. They typically are 3D oriented, and allow for building a full scenegraph, managing the graph, rendering the shapes, adding textures, animating the shapes, and possibly add extra things like collision detections, a set of physics rules for objects, etc. Some engines may even include rudimentary AI that can be assigned to characters.
Basically the game engine takes care of the graphics basics so you can concentrate more on the specifics of your game rather than worrying how to display a 3D toroid.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
(as far as I understand )
a game engine is exactly what the name implies, it is what makes the game run, usually provide the basic framework for animation, level designs, weapons, game sequences, rendering, maybe some physics.
it helps you focus on the meat of the game, instead of the skeleton of the game.
google for unreal game engine or Bioware Infinity Engine
or have a look at http://www.gamasutra.com/[^] for computer game programming issues.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
hi.,
I have a MDI program with a few dialog boxes,
whenever i call the UpdateData() function within the dialog box
i get an ASSERT error,
is there any other way to update my data in the dialog box??
Ehsan Behboudi
|
|
|
|
|
Avoid using UpdateData() unless you really understand it and know that an alternative does not exist. Use control variables instead and things will be much smoother.
What is the file/line that is firing the assertion? Chances are that it is in the DoDataExchange() function of your dialog class. Have you stepped into the code to see what is happening?
|
|
|
|
|
i use UpdateData() in my other dialog box with in the same program, and it never gave me any problems,
The part/line that fires the ASSERT is within the UpdateData() code.
you mentioned that I can use control variables !!!
what is that? and how can I use that?
in my dialog, i have 5 boxes that i just need to update their numbers (double)
Ehsan Behboudi
|
|
|
|
|
Problems aren't guaranteed, but they can appear if precautions aren't taken.
http://flounder.com/updatedata.htm
double d1, d2, d3;
CString strText;
strText.Format("", d1);
m_edit1.SetWindowText(strText);
strText.Format("", d2);
m_edit2.SetWindowText(strText);
strText.Format("", d3);
m_edit3.SetWindowText(strText);
is the easiest, most straightforward, and doesn't mess with any of the other controls/variables like UpdateData() does.
|
|
|
|
|
okay,,, thanks, i read the website too
but what i don't get is,, what is m_edit1???
in my dialog i have few edit box,, and assigned a double variable to each.
i don't really get what m_edit1 is?
Ehsan Behboudi
|
|
|
|
|
It's a CEdit control variable.
|
|
|
|
|
Find out why you get the ASSERT. It usually means you're doing something wrong.
Other ways to update controls are:
- SetDlgItemText(CONTROL_ID, ...)
- SetDlgItemInt(CONTROL_ID, ...)
- GetDlgItem(CONTROL_ID)->SetWindowText(...)
- GetDlgItem(CONTROL_ID)->SendMessage(BM_SETCHECK, ...)
To retrieve the data, look for Get versions of these.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Set a breakpoint in the UpdateData instruction and "step into" the line of code that gives the assertion error. The ASSERT condition usually tells you what's wrong. I would also check the DoDataExchange method for control incompatibilities(Wrong DDX function)
|
|
|
|
|
Override the window message handler WM_INITDIALOG and initialize your variables. You can only call UpdateData() after the dialog has been initialized.
Do not call UpdateData before CDialog::OnInitDialog(), otherwise it will crash.
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
myText = "something";
UpdateData();
}
|
|
|
|
|
Hi. I posted an Article Request/Ideas about this subject in the "Article Request/Ideas" forum. If anyone is interested in co-writing it, please let me know!!!
|
|
|
|
|
Does anyone know how to implement the usage of this indicator? I put it in:
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
ID_INDICATOR_OVR,
};
But I have no clue where to go from there to make the little guy in the bottom right corner actually toggle on and off.
halblonious
|
|
|
|
|
You'll need to add a UI handler for it. In the appropriate message map, add the ON_UPDATE_COMMAND_UI macro (outside the “{{AFX” comments), for ID_INDICATOR_OVR (in Mainfrm.cpp):
ON_UPDATE_COMMAND_UI(ID_INDICATOR_OVR, OnUpdateOver)
void CMainFrame::OnUpdateOver(CCmdUI *pCmdUI)
{
if (some_condition)
pCmdUI->SetText("Over");
else
pCmdUI->SetText("");
}
|
|
|
|
|
|
Actually, I am a begginer in C/C++ programming as I always programmed my add-ins for Excel in VBA, but recently I´ve been impressed by the advantages of C/C++ language and I decided to program my old VBA functions in a C dll. The results are great, but I have some troubles when exporting arrays output to Excel.
The thing is that, as it´s not possible for a function to return an array in C, the only way to export a matrix or a simple array is just to either use a pointer to an array or to wrap the array in a structure. I have tried it all, but this doesn´t work and, as the code is compiled with no error in Visual C++, Iam afraid I don´t import the function correctly from Excel. I have found the following sample in some pages I have visited. It´s just a function that returns the sum of two vectors:
The c# code for the dll:
__declspec(dllexport) double *vectoradd(double *vector_x,double *vector_y,int arr_length)<br />
{ <br />
<br />
int i; <br />
double *vector_z; <br />
vector_z = (double*) calloc(arr_length,sizeof(double)); <br />
for (i=0;i<arr_length;i++) { <br />
vector_z[i] = vector_x[i] + vector_y[i];<br />
} <br />
return vector_z; <br />
}
Once the dll is created, I try to use it in Excel. First, I use id.register Excel formula to register the function and get the id( in Excel:=register.id ("C:\function.dll","vectoradd","EEEJ" ) This works fine. But, when I try to call the function ( =call(A1,B1:B3,C1:C3,3) for instance to sum both vectors B1:B3, C1:c3 ) all I get is "FALSE". What´s wrong?
If it´s possible, what code should I write in VBA to register the dll function when it returns an array output (either pointer to or structure)?
Thanks.
|
|
|
|
|
This sounds like a job for SAFEARRAY .
|
|
|
|
|
is there a way I can add Comments to the INI file . I am actually using the
GetPrivateProfile method. I want the comments to leave the operation unaltered !
|
|
|
|
|
A line that starts with a semi-colon ';' is treated as a comment and ignored by all the GetXxxProfileXxx() functions.
Brad
|
|
|
|
|