|
What's the problem ? Do you want to pass each value of j in ? You'll need to nest your statements. I take it this is a contrived example ( i will always equal j ), but as they all stay in scope, I don't see what the problem is unless you need to nest the commands to use every value of j in your second loop.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
|
while(i<10)
{
while(j<10)
{
}
}
Can I recommend you buy Stroustrup ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
It's hard to tell exactly what you're doing, but I think you meant something more along the lines of:
while(i<10)
{
//statement
if( /*something to do with j */ )
{
m_pSet->Move(j);
while(k<20)
{
//statement
}
}
}
But I can't tell without a better idea of what you're trying to do. Hopefully though you can see it better now that some people have shown you some more ways to nest things.
Regards,
John
|
|
|
|
|
I have a function
int GetSize(void *a_pPointer)
{
<code>
}
How can I do it ???
thanks.
|
|
|
|
|
It is not possible in standard C/C++, but see Microsoft-specific _msize in malloc.h . Note that values returned by this function might be slightly rounded up in CRT release mode when the sizes are small.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am trying to create a CCommandBarCtrl control, however
it isn't in the traditional sense (as the wizard does it).
I am not creating it in a top-level window, I am creating
a command bar as a child of a child window itself; and it
doesn't really seem to work. It will draw the top-level
menus on the toolbar, however clicking them does nothing.
None of the menus pop up, or anything.
Its creation pretty much goes like this:
m_hMenu = LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDM_MENUBAND));
m_cmdbar.AttachMenu(m_hMenu);
m_cmdbar.LoadImages(IDR_TOOLBAR);
...which is in essence exactly the same as the wizard code
does it.
Can someone help?
|
|
|
|
|
How can i handle unexpected exits to the program (i.e. a user hits ctrl+break) so that i can clean up memory allocated? Thanks!
|
|
|
|
|
See signal .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I think this should server your purpose:
BOOL WINAPI ConsoleHandler(DWORD dwCtrlType)
{
switch(dwCtrlType)
{
case CTRL_CLOSE_EVENT:
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
{
// Cleanup code
return TRUE;
}
}
return FALSE;
}
int _tmain( ...)
{
SetConsoleCtrlHandler(ConsoleHandler, TRUE);
//
// Other code goes here
}
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Hi,
I am trying to make a VERSIONABLE_SCHEMA for future versions of a program, but I allways receive '-1' as version number when I call GetObjectSchema() function this is the probe code: (What could be the problem?)
//METEOGRAFICADOC.H
class CMeteoGraficaDoc : public CDocument
{
protected: // create from serialization only
CMeteoGraficaDoc();
DECLARE_SERIAL(CMeteoGraficaDoc)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMeteoGraficaDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMeteoGraficaDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMeteoGraficaDoc)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//METEOGRAFICADOC.CPP
IMPLEMENT_SERIAL(CMeteoGraficaDoc, CDocument,1| VERSIONABLE_SCHEMA)
// CMeteoGraficaDoc serialization
void CMeteoGraficaDoc::Serialize(CArchive& ar)
{
CDocument::Serialize(ar);
if (ar.IsStoring())
{
ar<<dia<<mes<<anno<<horaactual<<titulo;
}
="" else
="" {
="" int="" nversion="ar.GetObjectSchema();" always="" '-1'
="" ar="">>dia>>mes>>anno>>horaActual>>Titulo;
}
}
NOTE: Where ar< appears, the code is right but I don't know why I cannot look what appears after the first < in The Code Project screen.
|
|
|
|
|
This is a classic problem. MFC serialization versioning works only for CObject-derived objects serialized with a call to one of these functions:
CArchive& operator <<(CArchive & ar, const CObject* pOb);
void CArchive::WriteObject(const CObject* pOb);
They save metadata about object type and version before actual object bits written by Serialize method.
The problem is that CDocument is saved with a direct call to Serialize inside CDocument::OnSaveDocument. There's no metadata about document itself. There may be some metadata about document members if you save them using functions listed above. So if you need a version number at the beginning of MFC-serialized file, write it yourself. It's much easier than rewriting OnSaveDocument (but this option is also possible).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi I have built this MFC Wizard using the Visual C utility for building Wizards.
all is fine, except for i don't seem to have control over the next and back buttons in terms of enabling and disabling them. I would like to keep them all disbaled until all fields on the dialog are entered. How do I do this , since I can't find the resource id for these buttons?
|
|
|
|
|
There's a CPropertySheet::SetWizardButtons used to enable/disable buttons.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I can't add a variable to my static text.
I have a dialog box to which I added a static text labelled IDC_STATIC_TEMP. When I open ClassWizard, the ID is not visible and therefore I can not add a variable to IDC_STATIC_TEMP. At an earlier stage of my project I added other variables to other ID's but now, they are not visible anymore. What is wrong?
From the main dialog I can open two other dialogs. That makes three dialogs. To distinguish all dialog items from each other (which dialog they belong to) and to be able to use some "automatic" features, I have re-numbered the ID's. Dialog 1: 1XXX, Dialog 2: 2XXX etc.
Is this the problem? In all other dialogs but the main dialog I can se all ID's and add variables to them. Why???
The program works perfectly so far, even if I (in ClassWizard) can not see the variables and ID's belonging to the main dialog. All data exchange between main and sub dialogs are working perfect...
/Mattias
|
|
|
|
|
Try rebuilding the classwizard database.
Close VC, delete the projectname.clw file open VC again, and launch the classwizard to rebuild the files.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I can create a link to a file programmatically but how can I create a link to a folder?
Thanks
|
|
|
|
|
|
Hi Friends,
I have a Propertysheet class. I had set the TCS_BOTTOM style for this propertysheet. If I execute this application in a system which has IE4.0 or above, all the tabs are coming at the bottom as expected. But if I run this exe on a system which has IE 3.0, the tabs appear at the top.
But the same thing i tried with a tab control whose styles are set to BOTTOM tabs. They seem to work well both in IE 3.0 as well as IE 4.0 and above.
How can i make a Propertysheet control have tabs at the bottom with IE3.0 ?
Below is my code :
{
CntrlLevelSheet.AddPage(&MajorPage1);
CntrlLevelSheet.AddPage(&MajorPage2);
CntrlLevelSheet.AddPage(&MajorPage3);
CntrlLevelSheet.Create(this, WS_CHILD, 0);
CntrlLevelSheet.GetTabControl()->ModifyStyle (0,TCS_BOTTOM);
CntrlLevelSheet.SetActivePage(0);
CntrlLevelSheet.ShowWindow(TRUE);
}
|
|
|
|
|
The difference is because the two computers has different versions of commctrl.dll
I don't remember if the newest version is included in the Platform SDK, and can be installed without IE. If not, you have to upgrade IE to make it work...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
This might help you to install the latest ComCtl32.dll along with your app on the user's system:
http://www.codeproject.com/miscctrl/commctrls.asp
There are other articles that show how to test for the existence of a specific version of this DLL.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
How can I determine the size of dynamic array?
double *dynAr = new double[5]
This array has 5 items but if there is a condition that resize this array and then I want to know its size.
|
|
|
|
|
You can't do this. Use std::vector<double> instead - it has a size() method that does exactly what you want.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Actually you *can* do it - sizeof(array)/sizeof(int). Apparantly it's not recommended, but it works.
I second you though - vector is the obvous solution.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
No, you can't. He's using new and array is allocated on the heap, so sizeof(array) will be the size of pointer. This trick works only with global or stack-allocated arrays; I don't beleive it's not recommended in such case.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|