|
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.
|
|
|
|
|
If the breakpoint doesn't work, that implies that the source and the executable don't match. Try a Clean and a complete Rebuild.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Found it - putting the ? within the text my SQL which goes thru each character and then "translates" it into a string ( Morse code) did not have ? in the data.
So as I originally suspected- the error message was coming from SQL.
Little cryptic, but nevertheless a valid error.
|
|
|
|
|
Glad you figured it out.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
There is nothing special about ? nor any printable character in a text box.
If, as you imply, that you are setting IDC_EDIT1 during the OnChangeEdit1() callback, that is a loop. Code changing the window content or user entering data both trigger the OnChange type events. Happens with all the major controls, pulldown menus, tree controls, etc. In those, changing the selection is the same as the user clicking on them.
because it's looping, it never gets around to drawing the contents on the screen.
|
|
|
|
|
Hi, I have a modeless dialog with a edit control, and two button.
I show the dialog maximized, I got maximized the edit control with
void CEjemplo::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
if (GetDlgItem(IDC_EDIT1))
{
GetDlgItem(IDC_EDIT1)->MoveWindow(5,5,cx-1,cy-1);
}
}
But I dont know how to move the button at the botton of the dialog.
Now, when I maximized the dialog the button dont move itself and it is at back of edit control
I tried to do
if (GetDlgItem(IDC_EDIT1))
{
GetDlgItem(IDC_EDIT1)->MoveWindow(5,5,cx-1,cy-1);
GetDlgItem(IDC_button1)->MoveWindow(5,5,cx-1,cy-1);
}
But not run.
|
|
|
|
|
antonio343 wrote: But not run
Crash or not moving the controls in the good position ?
When doing something like that, moving controls around, I play dumb and use the dialog client area rectangle (GetClientRect ).
Play around with the values to move to the bottom of the rect returned by GetClientRect;
Note: be careful with the coordinate being in either relative to the client or window .
Watched code never compiles.
|
|
|
|
|
Not moving the controls in the good position.
I dont know how to use this function.
Maybe on this way:
void CEjemplo::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
CRect myRect;
GetClientRect(&myRect);
if (GetDlgItem(IDC_EDIT1))
{
m_Edit.MoveWindow(5,5,cx-55,cy-55);
m_Button1.MoveWindow(myRect.right, myRect.bottom,
myRect.Width(), myRect.Height());
}
}
But I dont want to change the size, only the position. I'd like to move at the right botton corner.
|
|
|
|
|
use SetWindowPos (with the SWP_NOSIZE option, check the documentation ) function instead of MoveWindow.
M.
Watched code never compiles.
|
|
|
|
|
I've tried with this:
void CEjemplo::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
CRect myRect;
const CWnd &p=wndBottom;
GetClientRect(&myRect);
if (GetDlgItem(IDC_EDIT1))
{
GetDlgItem(IDC_EDIT1)->MoveWindow(5,5,cx-50,cy-80);
m_Button1.SetWindowPos(&p,5,5,cx-50,cy-75,SWP_NOSIZE);
}
}
But when I run the application it crash
|
|
|
|
|
antonio343 wrote: But when I run the application it crash
Exception thrown? Assertion fired? Have you stepped into the code to see what is actually going on?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I'm sorry , the error wasn't due to the setwindowspos. I solved the error.
It run well, but I need know the coordinates of the right bottom corner.
|
|
|
|
|