|
How'bout:
Point3* tempVerts = new Point3[600];
memcpy(tempVerts, verts, sizeof(Point3)*600); ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Correct (+5)... but if it's dynamic then it would be more like (to clarify for OP)...
Point3* tempVerts = new Point3[array_size];
memcpy(tempVerts, verts, sizeof(Point3)*array_size);
|
|
|
|
|
Also correct (+5).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
thanks
|
|
|
|
|
There's a caveat to this: the data must be blittable.
Steve
|
|
|
|
|
You are right, i simply assumed that Point3 is made up of simple types like 3 coordinates stored as floats or integers, but of course this might not be the case.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
The C++ way to do this would be
copy(verts, verts + 600, tempVerts);
For this you have to add the following lines first -
#include <algorithm>
using namespace std;
You will get a warning which you can avoid by using checked_array_iterator class.
|
|
|
|
|
Thanks Everyone For Reply.
Regards
Yogesh
|
|
|
|
|
Hi all. I have an MDI application that have more then 2 kind of documents : CMy1Doc, CMy2Doc, CMy3Doc, etc. How can I know for sure if an document is already open, if yes then I bring it to foreground, if not then open it ? Thank you.
|
|
|
|
|
You would normally open your documents as a result of user action: button click, menu selection etc. So your program does not need to know whether the document is loaded, it just displays the content in the child window which the user then moves to front or back or tiled as required. Unless of course, your design is totally different from the Windows model. You might also like to consider using more meaningful names for your documents.
|
|
|
|
|
Try and open it with CreateFile[^], specifying 0 (no sharing) for the dwShareMode parameter. If the file is already open, CreateFile will return INVALID_HANDLE_VALUE and GetLastError will return ERROR_SHARING_VIOLATION.
The code below will fail, printing the value of ERROR_SHARING_VIOLATION if the file a.a is already open.
HANDLE f = CreateFile("a.a", GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (f == INVALID_HANDLE_VALUE)
{
std::cout << GetLastError() << std::endl;
return 0;
}
source: http://www.codeproject.com/Messages/3046449/Re-Check-file-is-open-or-not.aspx[^]
|
|
|
|
|
I forget to tell you that I will not serialize the documents ... In CMy1Doc I spread a CScrollView, in CMy2Doc I spread a CFormView, and in CMy3Doc I spread a CListView. So, in my application I want to open just once scroll view, form view, list view ... as I said, if one specific view is not open I need open it, if is already open then just bring it to front ...
(CMy1Doc, CMy2Doc and CMy3Doc is just sample names).
|
|
|
|
|
|
I don't think that your sample is written in MFC ... but is good to see the solution way.
|
|
|
|
|
That sample is C# - this forum is C++. Anyway it's the same method as mentioned above - i.e. try to open the file with share = none.
|
|
|
|
|
|
I made in follow way :
POSITION posTemplate = theApp.GetFirstDocTemplatePosition();
while(posTemplate)
{
CDocTemplate* pDocTemplate = theApp.GetNextDocTemplate(posTemplate);
POSITION posDoc = pDocTemplate->GetFirstDocPosition();
while(posDoc)
{
CDocument* pDoc = pDocTemplate->GetNextDoc(posDoc);
if(pDoc->IsKindOf(RUNTIME_CLASS(CMy2Doc)))
{
POSITION posView = pDoc->GetFirstViewPosition();
if(posView)
{
CView* pView = pDoc->GetNextView(posView);
pView->GetParentFrame()->BringWindowToTop();
}
return;
}
}
}
POSITION pos = theApp.GetFirstDocTemplatePosition();
CMultiDocTemplate* pDocTemplate = (CMultiDocTemplate*)theApp.GetNextDocTemplate(pos);
if(pos)
{
pDocTemplate = (CMultiDocTemplate*)theApp.GetNextDocTemplate(pos);
pDocTemplate = (CMultiDocTemplate*)theApp.GetNextDocTemplate(pos);
if(pDocTemplate)pDocTemplate->OpenDocumentFile(NULL);
}
|
|
|
|
|
I finished my c++ code, and now I want to add forms to it.
So I used the VS2010 and created a Win32 Application, and it made a main window container for me. I have a menu bar, in which I want to click on a subject (Install Web Server), and have a window form created, and install the Web Server with a progress bar, status of events....
I'm sort of confused here, I remember in vb, we just made a form for each window we needed, and designed the graphics on it. If we wanted a MDI, we just used the properties to set the main window to MDI parent and MDI Child. I don't want to deal with the .net stuff for this project, by adding a windows form, and prefer to learn by writing it in c++.
I'm not sure about c++, it how it's done.
The question is, would that extra window be considered an MDI child window, or just a regular window.
If it's just a window, then I just create a window for each task I need?, or is the same window used over and over?
|
|
|
|
|
If I understand you correctly, I see no reason for such windows to be MDI - it doesn't quite seem to make sense to me. I can't think of an example of an app that gives a constantly updated Installation status via an MDI child - they're always just a pop-up, child window or a Modal dialog.
Being just a window, I'd be inclined to create them all as resources and pull them out from the resource section & run them using
DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DialogProc);
On account of the ease of generating a window in a resource editor is often considerably easier, quicker and often more easily maintainable than hard-coding all of the controls onto each window.
ResEdit is free and will create dialogs - allowing you to save as an RC file or showing the equivalent C code needed to create the same dialog. I often copy and paste this code. Since it allows me to develop an app with the same ease as drawing up a dialog in a resource editor, while still giving me access to the more powerful WindowProcedure, rather than DialogPocedure. (Can only return true/false from a DialogProc - precluding all matter of extra functionality)
|
|
|
|
|
The setup wizard program scans for SQL servers, and programs the initial credentials into the new SQL server, and then creates the first database. Then it goes out and write the settings to an INI file in the web application. So there's a lot of combo and text boxes throughout the 5 stages. It's a windows program that runs after the initial program setup via Installshield. It's about 5 screens till you print out the results.
I'll give the dialog a try first and see how it goes.
Thank you.
|
|
|
|
|
jkirkerx wrote: The question is, would that extra window be considered an MDI child window, or just a regular window.
it would be considered extra window, for creating MDI application in the win32 you have to create MDI container and then create window into it. it's quite different the way MDI application is created in VB. if you have liberty of using MFC, VS provide wizard to create skeleton MDI application.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
The following code puts my compiler into never never land.
CString text = "?";
SetDlgItemText(IDC_EDIT1,text);
Whan needs to be done to accomplish this?
I can type as many ? into the box as I desire, but I cannot set any text which has ? in it. Also getting "Invalid cursor error", but not sure from where.
Any constructive help will be as always appreciated.
Vaclav
|
|
|
|
|
Are you saying it gives a compile error, or a runtime error?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Run time problem, the program does not respond when I set a break point at the SetDlgItemText(IDC_EDIT1,text);
I guess the real question is - can ? be considered an alpha character?
Sorry - my mistake - I cannot test it this way. It sets the OnChangeEdit1() and comes right back to my test - that is way the program does not respond because it is in the loop.
I''ll put some flag before the test so it does not get into loop.
But I thing it should accept ? without any problems.
The Invalid cursor error must be coming from somewhere else.
|
|
|
|